Closed BobC76 closed 1 year ago
total_increasing
should be used for resettable meters (e.g., energy meters, that are always counting upwards, unless completely replaced).
Otherwise, the total
class should be used.
../Frenck
Thanks. It is always counting upwards, and then from time to time when the points are turned into a voucher it will reset to zero. It meets the definition of the text in the documentation at https://developers.home-assistant.io/docs/core/entity/sensor/
Similar to total, with the restriction that the state represents a monotonically increasing positive total which periodically restarts counting from 0, e.g. a daily amount of consumed gas, weekly water consumption or lifetime energy consumption. Statistics of the accumulated growth of the sensor's value since it was first added is updated every 5 minutes. A decreasing value is interpreted as the start of a new meter cycle or the replacement of the meter.
And later https://developers.home-assistant.io/docs/core/entity/sensor/#entities-representing-a-total-amount this example also fits:
The sensor's value may reset to 0, and its value can only increase: state class total_increasing. Examples: energy consumption aligned with a billing cycle, e.g. monthly, an energy meter resetting to 0 every time it's disconnected
Doesn't explain why state_class=total_increasing and device_class=monetary are "impossible" combinations.
Probably because this 'is being reset when turned into a Voucher" is a really rare Edge-case.
I would consider to create a template that does Not use the monetary device_class.
Er. It's just like a meter that resets to 0 every month. Just like in the docs. I don't understand the suggestion of not using the monetary device class when the thing it's measuring is money. So 'edge case' or not, nothing these comments have provided explains why it's deemed 'impossible' and the warning is issued.
Doesn't explain why state_class=total_increasing and device_class=monetary are "impossible" combinations.
In general total_increasing
is designed for things like electricity meters. Other cases, should use total
(with an reset parameter to indicate reset time if applicable).
Er. It's just like a meter that resets to 0 every month.
Exactly! So it needs total
, with a reset timestamp.
Why?
The documentation for total increasing says "the state represents a monotonically increasing positive total which periodically restarts counting from 0"
Sorry but you aren't explaining the 'why' here, only repeating the statement that it should use total not total_increasing.
See above answer.
This doesn't explain why just reasserts the statement in the warning. If there is a disadvantage or consequence - somebody bothered to put the code in to issue a warning, why what is it warning for and why isn't it in the docs?
Monetary balances are a total, not monotonically increasing.
This one is derived from the monotonically increasing points total. Until the point are reset to zero. It's not a 'balance'.
The problem
Following upgrade to core-2023.2.1 I received the following warning in my log:
Entity sensor.octopus_energy_saving_session_earnings (<class 'homeassistant.components.template.sensor.TriggerSensorEntity'>) is using state class 'total_increasing' which is impossible considering device class ('monetary') it is using;
The sensor is as follows:Its providing a conversion of accumulating saving session points into GBP. So I don't see why total_increasing is incompatible with "monetary" device types, and I can't find the documentation that explains why they are if so.
What version of Home Assistant Core has the issue?
core-2023.2.1
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
see above
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response