Closed MrEbbinghaus closed 3 weeks ago
@MrEbbinghaus why do you want to disable the energy sensors for the individual members? The group sensors expect them to be there because they don't calculate (riemann) by default but just get the data for summing from the individual energy sensors. Also see https://docs.powercalc.nl/sensor-types/group/custom/#force-creating-riemann-sum-sensor.
You can force calculating by setting this force_calculate_group_energy
, but I see it's not available in the GUI yet. I will add that there as well.
Done with #2484, will be in next release.
@bramstroker I have a light fixture with multiple lights. I don't care about the energy sensors of the individual lights, only of the group.
As I understand, the linked code, it should be able to deal with missing energy sensors without having to manually set force_calculate_group_energy
(which is good).
The issue from a UX perspective is: Adding a child sensor without the energy sensor. and Adding a child sensor with the energy sensor and then deleting that sensor. have two different behaviours regarding the group sensor, the second one failing silently.
I think the underlying bug is that the groups config entry still contains the field _energy_entity
although the referenced entity has been deleted, and resolve_entity_ids_recursively
uses that without checking that the entity exists.
So the code I linked above gets a set of entity_ids that don't exist and decides to use them instead of creating a Riemann sum sensor for the group.
@MrEbbinghaus Thanks for the extensive information.
Will see if I can also fix this today, but I consider it quite an edge case.
Anyway with the force_calculate_group_energy
you can force the creation of the riemann sensor and fix your setup.
_energy_entity
should also be correctly unset now with #2487.
This was indeed cause of your issue.
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 | 5000 Installed Version | 2.0.1 Stage | running Available Repositories | 1464 Downloaded Repositories | 26Home Assistant Cloud
logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | okHome Assistant Supervisor
host_os | Home Assistant OS 13.1 -- | -- update_channel | stable supervisor_version | supervisor-2024.08.0 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 229.2 GB disk_used | 60.1 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | Mosquitto broker (6.4.1), AirCast (4.2.1), Let's Encrypt (5.1.4), Studio Code Server (5.15.0), SQLite Web (4.2.0), NGINX Home Assistant SSL proxy (3.10.1), Advanced SSH & Web Terminal (18.0.0), room-assistant (2.20.0), Home Assistant Google Drive Backup (0.112.1), MQTT Explorer (browser-1.0.3), Matter Server (6.4.2), ESPHome (2024.8.3), Jellyfin NAS (10.9.10), Samba share (12.3.2), Tdarr (pro_1.3004), InfluxDB (5.0.0), AdGuard Home (5.1.1), Uptime Kuma (0.12.1), Paperless-ngx (2.1.1), Activity Assistant (v0.0.4.3-alpha), Glances (0.21.1), Nginx Proxy Manager (1.0.1), Piper (1.5.2), Whisper (2.1.2), Matterbridge (2.9.0-PSA-121), chrony (3.0.1)Dashboards
dashboards | 3 -- | -- resources | 18 views | 18 mode | storageRecorder
oldest_recorder_run | August 23, 2024 at 14:23 -- | -- current_recorder_run | September 4, 2024 at 19:20 estimated_db_size | 221.00 MiB database_engine | sqlite database_version | 3.45.3Checklist
Describe the issue
The entity registry still contains the energy sensors of virtual sensors that once had an energy sensor, but that were later disabled via the Create energy sensor toggle in the UI and then deleted using the regular HA UI, after it was marked as "no longer provided".
This is an issue for group sensor, as the code that decides whether to create a Riemann sum sensor only does so, if there are no energy sensor entities in the registry:
https://github.com/bramstroker/homeassistant-powercalc/blob/7d503ead80b63dd8278abc12f0efaf3c39998943/custom_components/powercalc/sensors/group/custom.py#L357-L358
Reproduction steps
An energy sensor is created for the group, but it's unavailable, because there are no child energy sensors.
Debug logs
Relevant log entries only:
Diagnostics dump or YAML config
The group sensor:
One of the member sensors: