bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
1.04k stars 266 forks source link

PowerCalc group power sensor is increasing very fast #1916

Closed RienduPre closed 1 year ago

RienduPre commented 1 year ago

System Health details

System Information

version core-2023.11.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.6
os_name Linux
os_version 6.1.59
arch aarch64
timezone Europe/Amsterdam
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4989 Installed Version | 1.33.0 Stage | running Available Repositories | 1408 Downloaded Repositories | 84
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | 27 november 2023 om 01:00 relayer_connected | true relayer_region | eu-central-1 remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | eu-central-1-8.ui.nabu.casa certificate_status | ready can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 11.1 -- | -- update_channel | beta supervisor_version | supervisor-2023.11.3 agent_version | 1.6.0 docker_version | 24.0.6 disk_total | 113.9 GB disk_used | 37.2 GB healthy | true supported | true board | odroid-n2 supervisor_api | ok version_api | ok installed_addons | Home Assistant Google Drive Backup (0.111.1), Samba share (12.1.0), Advanced SSH & Web Terminal (16.0.1), Samba Backup (5.2.0), File editor (5.7.0), AppDaemon (0.15.2), AdGuard Home (4.8.17), WireGuard (0.9.0), Duck DNS (1.15.0), Mosquitto broker (6.3.1), AirCast (4.0.1), EMHASS (0.4.2), ESPHome (2023.10.6), Grott Beta branch (2.8) (0.1.5), RTSP Simple Server Add-on (v0.17.6), eufy-security-ws (1.7.1), SQLite Web (4.0.0)
Dashboards dashboards | 7 -- | -- resources | 51 views | 32 mode | storage
Nibe Uplink Heat Pumps api_endpoint_reachable | ok -- | --
Recorder oldest_recorder_run | 8 november 2023 om 10:07 -- | -- current_recorder_run | 18 november 2023 om 14:36 estimated_db_size | 3320.27 MiB database_engine | sqlite database_version | 3.41.2
Solcast PV Forecast can_reach_server | ok -- | -- used_requests | 0 rooftop_site_count | 1
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

I had performance issues with HA since I created the powercalc sensor group. After some troubleshooting it’s directly related to to powercalc group definition. This is my configuration:

powercalc: create_domain_groups:

I found this error in the logging:

The recorder backlog queue reached the maximum size of 97768 events; usually, the system is CPU bound, I/O bound, or the database is corrupt due to a disk problem; The recorder will stop recording events to avoid running out of memory So it seems that this new powercalc sensor is flooding the recorder

I run HA on a Odroid N2 with SSD with plenty of CPU, Memory and disksize, so it’s not hardware related.

Reproduction steps

1. 2. 3. ... See above

Debug logs

Sent the debug log by email

Diagnostics dump or YAML config

No response

bramstroker commented 1 year ago

Thanks for reporting. I did have a quick look into the code, and I see there is not throtteling in place for updates to the group power sensors, only the group energy sensor. The energy sensor is limited to only update once every 30 seconds. I'm changing the code now, so the power sensor is limited to once every 5 seconds.

You should however also try to find the culprit which causes the amount of updates to the group power sensor. The increasing and constantly updating value must be caused by another power sensor, which is member of this group.

bramstroker commented 1 year ago

Limiting update frequency should be resolved with #1917 Would be nice if you can try with the latest master version. You can install that with HACS (click reinstall), mark beta versions and select master. When this solves your issue than I will issue a new release shortly.

This won't fix the always increasing power sensor obviously. You'll need to investigate that further first, by looking which of member power sensors causes this.

Updates of the group power sensor are not logged in the debug logs, so we cannot get that information from there. When you can't find it I'll add debug logging, so we can discover which entity causes this in your system.

RienduPre commented 1 year ago

I think I know what caused this. I did put the group sensor itself also in the zone (kantoor) and than the value if the group sensor is also part if itself Scherm­afbeelding 2023-11-18 om 15 24 21

After I deleted it from the zone, al is working like expected. This gives me another problem, because I use the zone for lovelave/dwains dashboard and this relies on the zone if it will be available for a zone display.

But at least this problem is clarified

Maybe it's an idea to exclude a group sensor itself from the group

bramstroker commented 1 year ago

Ah, good find! That clarifies things as it will non stop update freezing the whole system. I definitely need to make sure that the group cannot be member of itself. I will add protection for that.

bramstroker commented 1 year ago

Should also be fixed with #1918

RienduPre commented 1 year ago

Problem solved. Thank you very much