Repository navigation
Conversation
Yesterday's consumption changes once a day in both directions, so HA logs 'state class total_increasing, but its state is not strictly increasing' and long-term statistics are wrong. Other energy sensors keep total_increasing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Home Assistant discovery currently gives every energy-class sensor
state_class: total_increasing. Several of them can decrease:_bvariants as well).HA reads each decrease as a meter reset. The result:
Entity sensor.xxx_energy_yesterday from integration mqtt has state class total_increasing, but its state is not strictly increasing. Triggered by state 7.827 (previous state: 8.436)Change:
stat_cla: total_increasingis sent only forOBK_CONSUMPTION_TOTALandOBK_CONSUMPTION_TODAY; the other energy sensors get nostat_cla.measurementwould not work, because HA does not allow it withdevice_class: energy. Energy Today still works as expected, since HA handles its midnight reset as a new meter cycle. The check is on the sensor index, and both BL twin datasets use the same index, so it covers twin mode too.The selftest
Test_HassDiscoveryexpectedtotal_increasingforenergycounter_last_hour; it now checks the sensor withoutstat_cla.Tested: HA 2026.10, 12 devices (BK7231N + BL0937, LN882H, BK7231N BL0942 twin). Energy Last Hour, Yesterday, 2 and 3 Days Ago come without
stat_cla, Energy Total and Today keeptotal_increasing, other entities unchanged.