I’m attempting to use persistence to store daily rainfall totals in InfluxDB. The Weather Calculation’s RainfallToday contains “5326771653543307 in”, which matches the value in Tempest’s app. The item was created using the UI as Number:Length with unit “in”.
However the value in InfluxDB is 532.7m, it seems to be taking the first four digits. adding a decimal point, and ignoring the units.
I’ve tried various combinations of adding/removing the units on the item, storing the value in a separate item, but nothing I’ve tried has worked.
.Does anyone have a suggestion or an example of storing inches in InfluxDB?
Just to be certain, you mean the unit metadata is set to in, correct? There are other places where the unit could be applied but it’s only the metadata that should affect how the value is stored in persistence.
To go further I think we need the Item definition including any relevant Item metadata and some samples from events.log showing the Item changing.
Thanks for your help. Yes, the unit metadata on the item is set to “in”. The item was created via the UI, accepting the defaults. I’m not sure how to show the item definition.
The Item that I’m persisting is TempestRainToday.:
For this testing I have the persistence strategy set to everyUpdate.
We had rain yesterday but none yet today so I’m using this rule to populate the TempestRainToday Item, triggering it to run manually via the UI.
rule DailyRainfallRule
when Time cron "0 59 23 ? * * *"
then logInfo("DailyRainfallRule", "--- Beginning ---")
logInfo("DailyRainfallRule", "TempestRainYesterday is {}", TempestRainYesterday.state.toString)
TempestRainToday.sendCommand(TempestRainYesterday.state.toString)
logInfo("DailyRainfallRule", "Today's rain total: {}", TempestRainToday.state)
logInfo("DailyRainfallRule", "--- Complete ---")
end
events.log
2025-08-20 11:22:02.193 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'TempestRainToday' received command 0.5326771653543307 in
2025-08-20 11:22:02.194 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'TempestRainToday' predicted to become 0.5326771653543307 in
2025-08-20 11:22:02.194 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TempestRainToday' changed from 0 in to 0.5326771653543307 in
I like YAML but DSL works too. Both will show the Item config, channel link and any relevant Item metadata. Use code fences.
```
code goes here
```
What are your regional settings. In particular did you choose SI or Imperial for the measuring system? You may need to click “show advanced” to see that option.
Why a command? You should only use commands when you want a device to do something. If you are just updating the state of an Item you should use postUpdate.
This log statement is almost certainly going to always show the old state of TempestRainToday. sendCommand and postUpdate happen in the background in parallel with your rule. There has almost certainly not been enough time between your sendCommand and this log statement for the Item to have processed the command and changed state. So you’ll get the state as it was before you sent the command.
You already know what the Item will change to, and you’ve already logged it out so this log statement is worse than useless, it’s misleading.
The Item’s actual state is in inches. Everything looks good so far.
As far as I understand the units are not stored in InfluxDB nor any of the databases OH works with at all. It’s just a number. There is certainly nothing in that screen shot to indicate that the unit is stored there at all.
OH will apply a unit when it reads from the database based on the Item’s unit metadata. But the databases don’t know anything about that.
You might be able to customize the graph to tell this Data Explorer what unit it is to label that y axis, but in the end, as @Mherwege says, as far as InfluxDB is concerned, it’s just a number without units.
Everything inside of OH shows that the units being used is inches so all is good and working as expected as far as I can tell.
Many thanks to both of you. Everything is working as it should, the problem was just my lack of understanding. I assumed the “m” in 532.7m indicated meters, not milli.
I never noticed the “Copy Item’s File Definition” the Item definition
version: 1
items:
TempestRainToday:
type: Number
dimension: Length
label: Rain Today
icon: rain
format: '%.2f %unit%'
unit: in
tags:
- Point
channel: weathercalculations:weathercalculations:WeatherCalculationThing:rainfallToday
No Measurement system was selected. I’ve selected Imperial now.
I had just copied some code from another rule without thinking much about it since the rule was just temporary for testing.
When I’m trying to debug something I frequently log the value before and after I change it, just to make sure the value is updated to what I think it should be. I understand what you’re saying but I’ve never noticed an issue with the after log containing the old value.
Agreed. The issue was just my lack of understanding of what InfluxDB does. Thanks again for your help.
The "Today’s rain total:` should be 0.5326771653543307 in. The line just before that log statement commanded TempestRainToday to be that value. But it’s not changed yet in response to that command so it’s state is 0 in, even though in a hundred milliseconds it’s going to become 0.5326771653543307 in.
That’s what I mean. You cannot pull the state from an Item immediately after you’ve updated it or commanded it because it will often not reflect the Item’s state after the command or update is processed. You are logging stale data.
Notice the timestamp on that log statement. Now notice the timestamp from when the Item actually changed:
2025-08-20 11:22:02.194 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TempestRainToday' changed from 0 in to 0.5326771653543307 in
One or two more milliseconds later and your rule’s log statement would have read:
Instead, it showed the value of TempestRainToday from before your command, not after. You are not achieving your stated goal of verifying that the Item update to what you think it should be. Your log statement runs too soon for that.