homeassistant-powercalc
homeassistant-powercalc copied to clipboard
Subtract groups generate errors if they don't have state class total
System Health details
System Information
| version | core-2025.5.3 |
|---|---|
| installation_type | Home Assistant OS |
| dev | false |
| hassio | true |
| docker | true |
| user | root |
| virtualenv | false |
| python_version | 3.13.3 |
| os_name | Linux |
| os_version | 6.12.23-haos |
| arch | x86_64 |
| timezone | Asia/Nicosia |
| config_dir | /config |
Home Assistant Community Store
| GitHub API | ok |
|---|---|
| GitHub Content | ok |
| GitHub Web | ok |
| HACS Data | ok |
| GitHub API Calls Remaining | 5000 |
| Installed Version | 2.0.5 |
| Stage | running |
| Available Repositories | 1871 |
| Downloaded Repositories | 41 |
Home Assistant Cloud
| logged_in | true |
|---|---|
| subscription_expiration | June 27, 2025 at 3:00 AM |
| relayer_connected | true |
| relayer_region | eu-central-1 |
| remote_enabled | true |
| remote_connected | true |
| alexa_enabled | false |
| google_enabled | true |
| cloud_ice_servers_enabled | true |
| remote_server | eu-central-1-27.ui.nabu.casa |
| certificate_status | ready |
| instance_id | f5741608d2354931bbe8c53ea678795e |
| can_reach_cert_server | ok |
| can_reach_cloud_auth | ok |
| can_reach_cloud | ok |
Home Assistant Supervisor
| host_os | Home Assistant OS 15.2 |
|---|---|
| update_channel | stable |
| supervisor_version | supervisor-2025.05.3 |
| agent_version | 1.7.2 |
| docker_version | 28.0.4 |
| disk_total | 457.7 GB |
| disk_used | 185.4 GB |
| healthy | true |
| supported | true |
| host_connectivity | true |
| supervisor_connectivity | true |
| ntp_synchronized | true |
| virtualization | |
| board | generic-x86-64 |
| supervisor_api | ok |
| version_api | ok |
| installed_addons | File editor (5.8.0), Frigate (0.15.1), Grafana (11.0.0), Home Assistant Google Drive Backup (0.112.1), InfluxDB (5.0.2), Mosquitto broker (6.5.1), Samba share (12.5.1), Terminal & SSH (9.17.0), Log Viewer (0.17.1), Studio Code Server (5.19.3), OpenThread Border Router (2.13.0), Matter Server (8.0.0), ESPHome Device Builder (2025.5.0), Zigbee2MQTT (2.3.0-1) |
Dashboards
| dashboards | 6 |
|---|---|
| resources | 26 |
| views | 36 |
| mode | storage |
Miele
| component_version | 2025.5.0 |
|---|---|
| reach_miele_cloud | ok |
Network Configuration
| adapters | lo (disabled), enp3s0 (enabled, default, auto), docker0 (disabled), hassio (disabled), veth393edb9 (disabled), veth5e3dbb1 (disabled), vethcc2d193 (disabled), veth548aa77 (disabled), vethec3fa8f (disabled), veth27d0c9a (disabled), vethc1d6892 (disabled), veth24c24c6 (disabled), vetha9bbe34 (disabled), veth0577926 (disabled), vethc39986c (disabled), veth806910f (disabled), veth4431b0a (disabled), vethb5b8811 (disabled), vethd4cd590 (disabled), veth8a957f8 (disabled) |
|---|---|
| ipv4_addresses | lo (127.0.0.1/8), enp3s0 (192.168.11.36/24), docker0 (172.30.232.1/23), hassio (172.30.32.1/23), veth393edb9 (), veth5e3dbb1 (), vethcc2d193 (), veth548aa77 (), vethec3fa8f (), veth27d0c9a (), vethc1d6892 (), veth24c24c6 (), vetha9bbe34 (), veth0577926 (), vethc39986c (), veth806910f (), veth4431b0a (), vethb5b8811 (), vethd4cd590 (), veth8a957f8 () |
| ipv6_addresses | lo (::1/128), enp3s0 (fd2b:9c2b:c465:9326:e27d:1121:a832:c3bb/64, fe80::d79d:7781:7370:4163/64), docker0 (fe80::9cf8:8cff:fe63:7d2e/64), hassio (fe80::2406:1aff:fe5b:6ffd/64), veth393edb9 (fe80::4ccf:84ff:fefd:fcf6/64), veth5e3dbb1 (fe80::8f2:deff:fe13:a48c/64), vethcc2d193 (fe80::8433:b3ff:fe52:7e3b/64), veth548aa77 (fe80::44e1:b0ff:fee4:94ec/64), vethec3fa8f (fe80::f898:97ff:fe33:e646/64), veth27d0c9a (fe80::d860:c9ff:fe6a:a21b/64), vethc1d6892 (fe80::5441:44ff:fed7:60a4/64), veth24c24c6 (fe80::d82a:5aff:fe20:3628/64), vetha9bbe34 (fe80::b8b3:a1ff:fee0:89f5/64), veth0577926 (fe80::861:27ff:fe67:8039/64), vethc39986c (fe80::80f9:e1ff:fe22:332/64), veth806910f (fe80::c0e6:94ff:fee7:32fb/64), veth4431b0a (fe80::8871:bdff:fe42:4e72/64), vethb5b8811 (fe80::8cd2:42ff:fe2e:d56c/64), vethd4cd590 (fe80::78a8:caff:fe3f:aabf/64), veth8a957f8 (fe80::40d0:4fff:fe07:7c88/64) |
| announce_addresses | 192.168.11.36, fd2b:9c2b:c465:9326:e27d:1121:a832:c3bb, fe80::d79d:7781:7370:4163 |
Recorder
| oldest_recorder_run | May 16, 2025 at 4:37 PM |
|---|---|
| current_recorder_run | May 27, 2025 at 10:41 AM |
| estimated_db_size | 4973.07 MiB |
| database_engine | sqlite |
| database_version | 3.48.0 |
Sonoff
| version | 3.8.2 (c4b6fda) |
|---|---|
| cloud_online | 5 / 9 |
| local_online | 4 / 4 |
Checklist
- [x] I have read the FAQ to see if there is a known solution to my problem.
- [x] I have enabled debug logging for my installation.
- [x] I have filled out the issue template to the best of my ability.
- [x] This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
- [x] This issue is not a duplicate issue of currently previous issues..
Describe the issue
I was seeing many errors in the logs for subtract groups that were not strictly total_increasing. I was able to eliminate the errors by changing the state class for all of my yaml created subtraction groups as follows:
homeassistant:
customize:
sensor.carport_motion_light_pc_energy:
state_class: total
sensor.driveway_gate_pc_energy:
state_class: total
sensor.kitchen_sockets_net_pc_energy:
state_class: total
sensor.kitchen_lights_net_pc_energy:
state_class: total
sensor.master_sockets_net_pc_energy:
state_class: total
So far I haven't noticed any problems related to this fix. The issue may be related to #2664
Reproduction steps
- Create a subtract group in yaml with energy sensor
...
Debug logs
Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:366
integration: Sensor (documentation, issues)
First occurred: May 26, 2025 at 7:05:10 PM (3 occurrences)
Last logged: May 26, 2025 at 8:15:10 PM
Entity sensor.carport_motion_light_pc_energy from integration powercalc has state class total_increasing, but its state is not strictly increasing. Triggered by state 10.2830 (10.2833) with last_updated set to 2025-05-26T16:02:15.209938+00:00. Please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues
Entity sensor.driveway_gate_pc_energy from integration powercalc has state class total_increasing, but its state is not strictly increasing. Triggered by state 1.6141 (1.6143) with last_updated set to 2025-05-26T16:52:14.378103+00:00. Please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues
Entity sensor.kitchen_sockets_net_pc_energy from integration powercalc has state class total_increasing, but its state is not strictly increasing. Triggered by state 142.8023 (142.8026) with last_updated set to 2025-05-26T17:13:04.819496+00:00. Please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues
Diagnostics dump or YAML config
Here is an example of how I configured my subtraction groups:
- create_group: Master Sockets Net PC
unique_id: de1209fb-74d4-4927-afd5-55111281b23d
group_type: subtract
entity_id: sensor.circuits_up_4_6_power_b
subtract_entities:
- sensor.master_bedside_light_left_power
- sensor.master_bedside_light_right_power
- sensor.master_picture_frame_power
- sensor.master_balcony_power
- sensor.garden_flood_power
Group energy sensors created by Powercalc should only ever increase in value, so total_increasing is the right one.
Do you have access to the HA database? If so, could you please check states table and look for alle the state values for sensor.carport_motion_light_pc_energy around the time the error was logged?
Hi Bram,
Thanks for looking into this. I can dig into the database further if needed. I was thinking that the info was already in the log entry though:
Triggered by state 10.2830 (10.2833) with last_updated set to 2025-05-26T16:02:15.209938+00:00
I interpreted this to mean that the sensor had returned 10.2830 when the current state at that time was 10.2833. My thought was that it could be a rounding error or maybe an order of operations issue.
hmm yes seems to be some rounding or race condition with timing (maybe 2 state changes at the same time or something like that).
Looking at log line. Previous state: 10.2833, new state: 10.2830.
That's why we need the state history to see when 10.2833 happened. Hopefully that gives insides in the root cause of the issue.
Unfortunately the state history you shared only has data from today.
Might be you have set recorder purge days to only keep 1 day?
You can see three examples of decreases in this set at 6:15, 6:16 and 7:41. The one at 6:16 decreases 3 times in a row over a period of 21 seconds before it starts to increase again at 6:21. I was seeing many errors of this type in the log each day for every subtraction group that I've defined.
Here is the database query from the exact moment that the initial error was generated and the state went from 10.2833 to 10.2830
@RN-Say it's very strange. The energy sensor created for the substract sensor is in essence just an rieman integral sensor. Should behave exactly similar when you create one with the core helpers. So it might be a good idea to setup a second energy sensor for the substract power sensor using the core helper, to see if it has the same issue.
Select "Integral".
And pick the substract power sensor at Input, i.e. sensor.master_sockets_net_pc_power.
Let it run a bit, and see if it records the same values as the riemann sensor created by Powercalc.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.