Sensor can only be of measurement type or increasing; they don't have to be #623
-
|
The problem with which indicates This leaves no room for sensors that always present a negative value and that will accumulate, or sensors whose sums only ever decrease. A practical use is with energy sensors where the sign indicates which way the current is flowing. As such, an energy production system whose current flow upstream (like when exporting energy back to the grid) will be recorded as a negative sensor that keeps growing. The In addition to To determine rollover or sensor reset, one has to detect if the difference between the last recorded value and the next value has a different sign. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
|
In general, this makes sense, but there are two edge cases which makes this tricky:
Also, please note that Home Assistant's energy dashboard expects all energy sensors to have a positive value; both export and import sensors should have a positive value. |
Beta Was this translation helpful? Give feedback.
-
|
This is an attempt at summarizing cases there state class
|
Beta Was this translation helpful? Give feedback.
-
you don't. And in that case you ignore the value of state[0] and continue as before. In the lifetime of the sensor, that first value will be insignificant Mind you, if we had a last_reset then none of this would be necessary. It would still be be nice to be able to differentiate between punctual reads (temperature, on/off state etc) vs data that should only ever grow or reduce over time but has room for sometimes going both ways (like a solar system that is producing power most of the day, but at night just before the system turns off will start consuming energy)
But over the years, I've dealt with constantly decreasing accumulating value. It happens all the time. |
Beta Was this translation helpful? Give feedback.
-
|
I think this is solved by adding the |
Beta Was this translation helpful? Give feedback.
-
|
Will the energy application accepts those sensors ? |
Beta Was this translation helpful? Give feedback.
I think this is solved by adding the
totalstate class: https://developers.home-assistant.io/blog/2021/09/20/state_class_total