Open emufan opened 2 weeks ago
Sorry you are experiencing issues after HA and integration upgrades.
Unfortunately I'm not sure, never seen this error before.
Looking at the code where this error is raised in HA it logs an error when the state of the sensor is decreasing.
Triggered by state 113682.0750 (113.6820751)
113682.0750
is the newly received state, 113.6820751
latest recorded.
Seems to be some decimal issue going on where decimals have shifted 3 positions, but I assume the first value is the in Wh and the second one in kWh. It's only an issue in the logging.
So that would mean 113.6820750
is the new value and 113.6820751
the old value, thus the energy sensor is decreasing.
That must be some bug in the rieman integral sensor code, as that's what powercalc is using under the hood for the energy sensor.
Very hard one to debug as I don't have this issue and never heard about is before, and it's only happening on your system.
Few ideas from the top of my head to debug:
Are you using mariaDB of mysqlite as DB engine? Would be nice if you can check out the states
table where HA records all the states, to see what is exactly going on.
Might also be an idea to enable debug logging for integration
integration (this is the rieman sum heloer)
logger:
logs:
homeassistant.components.integration: debug
sensor.flur_energy_counter
. Let it run for a bit, and see if it gives the same error.Could you also share how you configured sensor.flur_energy_counter
in Powercalc?
And also if you have any additional global configuration defined?
Thanks for the quick reply.
ad 1. mysqlite. I will try to finde the values.
ad 2. Will do it.
ad 3. Will try as well.
ad 3. Defined this way
- name: Flur
entity_id: light.flur
standby_power: 0.3
fixed:
power: 175
Here some debug log for the second kind of errors above
2024-11-12 17:34:51.990 DEBUG (MainThread) [custom_components.powercalc.sensors.group.custom] delta for entity sensor.kinderzimmer_mitte_hinten_energy_counter: -0.0001, prev=8698.0752, cur=8698.0751
2024-11-12 17:34:51.991 WARNING (MainThread) [custom_components.powercalc.sensors.group.custom] skipping state for sensor.kinderzimmer_mitte_hinten_energy_counter, probably erroneous value or sensor was reset
defined this way
- create_group: Kinderzimmerdecke
unique_id: unique_id_powercalc_kinderzimmerdecke
entities:
- entity_id: light.kinderzimmer_vorn
- entity_id: light.kinderzimmer_mitte_vorn
- entity_id: light.kinderzimmer_mitte_hinten
- entity_id: light.kinderzimmer_hinten
where the devices are hue lights.
Second one is related to powercalc group sensors. Log lines with custom_components.powercalc.sensors.group.custom
That's calculation routine which is part of powercalc.
Might be a one time issue. as there were some changes few months ago as how the group sensors calculate. I suggest to monitor this a few days and after several reboots. If this issue persists please let me know, than I'll dig further.
Somehow curious.
Here one example
Entity sensor.sonos_schlafzimmer_energy_counter from integration powercalc has state class total_increasing, but its state is not strictly increasing. Triggered by state 54477.3155 (54.477315600000004) with last_updated set to 2024-11-13T00:49:50.415118+00:00. Please create a bug report at https://github.com/bramstroker/homeassistant-powercalc/issues
defined this way
- entity_id: media_player.sonos_schlafzimmer
standby_power: 4.2
fixed:
power: 4.2
states_power:
playing: 5.7
with this settings
powercalc:
enable_autodiscovery: false
# force_update_frequency: 00:10:00 #Default
force_update_frequency: 00:05:00
power_sensor_naming: "{} power"
power_sensor_friendly_naming: "{} POWER"
create_energy_sensors: true
energy_sensor_unit_prefix: none
energy_integration_method: left
energy_sensor_naming: "{} energy_counter"
energy_sensor_friendly_naming: "{} ENERGY_COUNTER"
create_utility_meters: true
utility_meter_types:
- daily
- weekly
- monthly
- yearly
Powercalc created sensor sensor.sonos_schlafzimmer_power is stable:
247712208 | NULL | 4.20| NULL | NULL | NULL | 0 | AZL1vbR3UsmJkIUHW3n5vA== | NULL | NULL | 48
247713276 | NULL | 4.20| NULL | NULL | NULL | 0 | AZL1wkiABVY5akkRKqZx+Q== | NULL | NULL | 48
but here we go
250642590 | NULL | 54478.3656 | NULL | NULL | NULL | NULL | 1731459890.4247851 | NULL | 1731459890.4247851 | 250641590 | 41137989 | NULL | NULL | NULL | 0 | AZMjDTz437Bh6m91iumTVA== | NULL | NULL | 209
250641590 | NULL | 54478.0156 | NULL | NULL | NULL | NULL | 1731459590.4237404 | NULL | 1731459590.4221025 | 250640659 | 41137989 | NULL | NULL | NULL | 0 | AZMjCKkWzKoft+rsTPpFGw== | NULL | NULL | 209
250640659 | NULL | 54477.6655 | NULL | NULL | NULL | NULL | 1731459290.4148781 | NULL | 1731459290.4148781 | 250639802 | 41137989 | NULL | NULL | NULL | 0 | AZMjBBUunB1Rh8CY6ckAfg== | NULL | NULL | 209
250639802 | NULL | 54477.3155 | NULL | NULL | NULL | NULL | 1731458990.415118 | NULL | 1731458990.415118 | 250639698 | 41137989 | NULL | NULL | NULL | 0 | AZMi/4FPS6afXGlkWlB2Cg== | NULL | NULL | 209
250639698 | NULL | 54477.3156 | NULL | NULL | NULL | NULL | 1731458990.414866 | NULL | 1731458990.414866 | 250638769 | 41137989 | NULL | NULL | NULL | 0 | AZMi/4FOYgJJ2wf6QFSjvw== | NULL | NULL | 209
250638769 | NULL | 54476.9655 | NULL | NULL | NULL | NULL | 1731458690.4140928 | NULL | 1731458690.4140928 | 250637894 | 41137989 | NULL | NULL | NULL | 0 | AZMi+u1uh2KvJlt2OYpHlQ== | NULL | NULL | 209
Converted timestamps from the last 4 entries
Mittwoch, 13. November 2024 01:54:50.414 GMT+01:00
Mittwoch, 13. November 2024 01:49:50.415 GMT+01:00
Mittwoch, 13. November 2024 01:49:50.414 GMT+01:00
Mittwoch, 13. November 2024 01:44:50.414 GMT+01:00
So:
Seems integration is calculated twice at the same time, which you already noticed. That would probably be the cause of the issue. Calculating new integration should be triggered each time the power sensor changes state. Could you have a look into state changes of the power sensor?
SELECT * FROM "states" where metadata_id = 48 and last_reported_ts >= 1731457800 and last_reported_ts <= 1731459890.4247851
250639697 | NULL | 4.20 | NULL | NULL | NULL | NULL | 1731458990.4145453 | NULL | 1731458990.4145453 | 250638768 | 52591169 | NULL | NULL | NULL | 0 | AZMi/4FOHNLYIlnHSmykhg== | NULL | NULL | 48
250640658 | NULL | 4.20 | NULL | NULL | NULL | NULL | 1731459290.414584 | NULL | 1731459290.414584 | 250639697 | 52591169 | NULL | NULL | NULL | 0 | AZMjBBUufHwrQbwFfdtqag== | NULL | NULL | 48
250641589 | NULL | 4.20 | NULL | NULL | NULL | NULL | 1731459590.4219007 | NULL | 1731459590.4219007 | 250640658 | 52591169 | NULL | NULL | NULL | 0 | AZMjCKkVlfu2lhP516GyRQ== | NULL | NULL | 48
250642589 | NULL | 4.20 | NULL | NULL | NULL | NULL | 1731459890.4239852 | NULL | 1731459890.4239852 | 250641589 | 52591169 | NULL | NULL | NULL | 0 | AZMjDTz3cyst3z2fge+Y8A== | NULL | NULL | 48
250640658 | NULL | 4.20 | NULL | NULL | NULL | NULL | 1731459290.414584 | NULL | 1731459290.414584 | 250639697 | 52591169 | NULL | NULL | NULL | 0 | AZMjBBUufHwrQbwFfdtqag== | NULL | NULL | 48
converted (and sorted)
Mittwoch, 13. November 2024 02:04:50.423 [GMT+01:00]
Mittwoch, 13. November 2024 01:59:50.421 [GMT+01:00]
Mittwoch, 13. November 2024 01:54:50.414 [GMT+01:00]
Mittwoch, 13. November 2024 01:49:50.414 [GMT+01:00}
Mittwoch, 13. November 2024 01:44:50.413 [GMT+01:00]
So no multiple updates.
Could you try to create energy sensor using Riemann sum helper using HA helpers and see how that one goes?
Here we go. The helper is updating more often as expected as well, but at least without decreasing problems. I wonder if your round is not fitting to all cases.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
251278445 | 54658.9705 | 1731615189.3340845 | Thursday, 14. November 2024 20:13:09.334 | sensor.sonos_schlafzimmer_energy_counter -- | -- | -- | -- | -- 251278444 | 156.8047996538333334650772872 | 1731615189.3328927 | Thursday, 14. November 2024 20:13:09.332 | sensor.sonos_schlafzimmer_test 251278443 | 4.20 | 1731615189.3324125 | Thursday, 14. November 2024 20:13:09.332 | power 251277273 | 54658.6205 | 1731614889.337978 | Thursday, 14. November 2024 20:08:09.337 | sensor.sonos_schlafzimmer_energy_counter 251277344 | 156.4547985198333334765072103 | 1731614889.3370688 | Thursday, 14. November 2024 20:08:09.337 | sensor.sonos_schlafzimmer_test 251277272 | 156.4547997798333334765072264 | 1731614889.3322308 | Thursday, 14. November 2024 20:08:09.332 | sensor.sonos_schlafzimmer_test 251277271 | 4.20 | 1731614889.33144 | Thursday, 14. November 2024 20:08:09.331 | power 251276097 | 54658.2704 | 1731614589.326542 | Thursday, 14. November 2024 20:03:09.326 | sensor.sonos_schlafzimmer_energy_counter 251276096 | 156.1047934553333334618601174 | 1731614589.326352 | Thursday, 14. November 2024 20:03:09.326 | sensor.sonos_schlafzimmer_test 251275989 | 54658.2705 | 1731614589.3261008 | Thursday, 14. November 2024 20:03:09.326 | sensor.sonos_schlafzimmer_energy_counter 251275988 | 156.1047940841666667951934304 | 1731614589.3258154 | Thursday, 14. November 2024 20:03:09.325 | sensor.sonos_schlafzimmer_test 251275987 | 4.20 | 1731614589.3253853 | Thursday, 14. November 2024 20:03:09.325 | power 251274699 | 54657.9204 | 1731614289.3243916 | Thursday, 14. November 2024 19:58:09.324 | sensor.sonos_schlafzimmer_energy_counter 251274806 | 155.7547925605000001290106149 | 1731614289.324209 | Thursday, 14. November 2024 19:58:09.324 | sensor.sonos_schlafzimmer_test 251274698 | 155.7547931403333334623440018 | 1731614289.3237016 | Thursday, 14. November 2024 19:58:09.323 | sensor.sonos_schlafzimmer_test
System Health details
System Information
Home Assistant Community Store
GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok HACS Data | ok GitHub API Calls Remaining | 4999 Installed Version | 2.0.1 Stage | running Available Repositories | 1471 Downloaded Repositories | 50Home Assistant Cloud
logged_in | true -- | -- subscription_expiration | 30. August 2025 um 02:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | false remote_connected | false alexa_enabled | true google_enabled | false cloud_ice_servers_enabled | true remote_server | eu-central-1-5.ui.nabu.casa certificate_status | ready instance_id | b8cb37779da4460485728e3fe9669c94 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | okHome Assistant Supervisor
host_os | Home Assistant OS 13.2 -- | -- update_channel | stable supervisor_version | supervisor-2024.11.2 agent_version | 1.6.0 docker_version | 27.2.0 disk_total | 113.9 GB disk_used | 17.0 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | odroid-n2 supervisor_api | ok version_api | ok installed_addons | Samba share (12.3.2), File editor (5.8.0), Samba Backup (5.2.0), Studio Code Server (5.17.3), Advanced SSH & Web Terminal (19.0.0), Mosquitto broker (6.4.1), SQLite Web (4.2.2), eufy-security-ws (1.9.1), Matter Server (6.6.0)Dashboards
dashboards | 8 -- | -- resources | 29 views | 34 mode | storageRecorder
oldest_recorder_run | 6. November 2024 um 12:19 -- | -- current_recorder_run | 11. November 2024 um 17:33 estimated_db_size | 2716.09 MiB database_engine | sqlite database_version | 3.45.3Checklist
Describe the issue
Yesterday I updated to 2024.11.1 and newerst powercalc. Coming from older version 2024.6 (because of AMP problems until .11).
Until then, the powercalc sensors never had any issues. But after the updates I now get tons of waring messages. Over and over again.
Reproduction steps
1. 2. 3. ...
Debug logs
Diagnostics dump or YAML config
No response