bramstroker / homeassistant-powercalc

Custom component to calculate estimated power consumption of lights and other appliances
MIT License
984 stars 261 forks source link

nested groups missing after update/configuration update (1.8.0+) #1755

Closed gribber closed 1 year ago

gribber commented 1 year ago

System Health details

System Information

version core-2023.7.2
installation_type Home Assistant Supervised
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.11.4
os_name Linux
os_version 5.10.0-19-amd64
arch x86_64
timezone Europe/Stockholm
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.32.1 Stage | running Available Repositories | 1275 Downloaded Repositories | 54
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Debian GNU/Linux 11 (bullseye) -- | -- update_channel | stable supervisor_version | supervisor-2023.07.1 agent_version | 1.2.1 docker_version | 20.10.21 disk_total | 78.2 GB disk_used | 55.8 GB healthy | true supported | true supervisor_api | ok version_api | ok installed_addons | Studio Code Server (5.8.1), MariaDB (2.6.1), InfluxDB (4.7.0), Mosquitto broker (6.2.1), phpMyAdmin (0.8.7), ESPHome (2023.6.5), Frigate NVR Proxy (1.3), Node-RED (14.3.0), Zigbee2MQTT (1.32.1-1), Network UPS Tools (0.12.0)
Husqvarna Automower can_reach_server | ok -- | --
Dashboards dashboards | 2 -- | -- resources | 31 views | 20 mode | storage
Recorder oldest_recorder_run | July 14, 2023 at 06:32 -- | -- current_recorder_run | July 16, 2023 at 09:49 estimated_db_size | 2121.41 MiB database_engine | mysql database_version | 10.6.12
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

After the update to 1.8.0 and changes to configuration related to that (removed platform and moved configuration to powercalc->sensors), no entities defined in nested groups are shown anymore Only single entities and single groups are working

Full configuration: new style: https://github.com/gribber/ha/blob/main/integrations/powercalc.yaml old disabled: https://github.com/gribber/ha/blob/main/sensors/powercalc.yaml.disabled

Reproduction steps

  1. create nested groups
  2. include entities by area in each group

Debug logs

2023-07-16 09:49:59.131 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Including entities from area: parkering_och_uppfart
2023-07-16 09:49:59.133 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Found include entities: [RegistryEntry(entity_id='light.entre_1', unique_id='0x84fd27fffeb32cc0_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='e76897dda0a1f08d893f942c80960d6b', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='efeed9360ecb093e0b1b49f80ea198de', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='entre_1', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.entre_2', unique_id='0x84fd27fffeab9599_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='b490e0e16be952eeccc825df7d611142', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='b39c171d9828058bf4309f2bd7da35cc', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='entre_2', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.parking_1', unique_id='0xcc86ecfffe1bd881_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='8af4d2acf3f765f5d6dbc06a68676115', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='e5c6ed34b9b9d891e983516df040e571', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='parking_1', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.garage_front', unique_id='0x84fd27fffeb30da6_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='c693fc5507d76d887b1c3fb1f0083918', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='b3a23bccd7c28b1b39392653a5e357f5', has_entity_name=False, name='Framsida garage', options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='garage_front', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.parking_2', unique_id='0xcc86ecfffe1bd6f2_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='23bc52fc888649402e4a28932d208375', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='c26a9be5e03bb8eaeb3d70cf4a778b48', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='parking_2', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.parking_3', unique_id='0x84fd27fffeb0f857_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='66c2a7c58ba5d2097f5f69d4be20ada5', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='04788124a2c98a23e7c7e5aa46d252f6', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='parking_3', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.garage_side', unique_id='0x84fd27fffe2ce91c_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='5f332018ca05af7300efef50db568560', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='a013df8b41ced2b5eb3578bc34fae4f0', has_entity_name=False, name='Sida garage', options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='garage_side', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.driveway_1', unique_id='0x84fd27fffeb31224_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='1c4ff4a1b08cfa55ff692cf04bb2c288', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='5223f878e8e82ba0d44afd5842723577', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='driveway_1', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.parkering_och_uppfart', unique_id='3_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='e222f8525f061f68f03d582116928905', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='beeed4c60774c2d252b0a1f22a08a37a', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='parkering_och_uppfart', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.earth_cellar', unique_id='0x84fd27fffeb0f4d9_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='ce27983fa32233d67ddc48a9db8e01fa', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='4c7b00931fede882f91335b80e81f36f', has_entity_name=False, name='Lampa utanför', options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='earth_cellar', supported_features=44, translation_key=None, unit_of_measurement=None)]
2023-07-16 09:49:59.133 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'outdoor parking driveway'
2023-07-16 09:49:59.134 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Including entities from area: uterum
2023-07-16 09:49:59.135 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Found include entities: [RegistryEntry(entity_id='light.conservatory_ceiling', unique_id='0x84fd27fffe581775_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='8b95874d125bbf906ff826fadb25d0d9', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='374d2653767cbf634bb56a8225385c49', has_entity_name=False, name='Tanklampan', options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='conservatory_ceiling', supported_features=44, translation_key=None, unit_of_measurement=None), RegistryEntry(entity_id='light.rice_lamp', unique_id='0x588e81fffeb754eb_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'min_color_temp_kelvin': 2202, 'max_color_temp_kelvin': 4000, 'min_mireds': 250, 'max_mireds': 454, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['color_temp']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='78e51e1a6b8374940bd8b4d77e4998f0', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='7d301c9c48fe9cbf2f8338cded569ab2', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='rice_lamp', supported_features=44, translation_key=None, unit_of_measurement=None)]
2023-07-16 09:49:59.135 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'conservatory'
2023-07-16 09:49:59.137 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Including entities from area: garage
2023-07-16 09:49:59.138 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Found include entities: [RegistryEntry(entity_id='light.garage_alert', unique_id='0x680ae2fffe8f8d11_light_zigbee2mqtt', platform='mqtt', aliases=set(), area_id=None, capabilities={'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'finish_effect', 'stop_effect'], 'supported_color_modes': ['brightness']}, config_entry_id='ed73bc0dd5b037efe0f7b5208585e074', device_class=None, device_id='3189253f55a131dad88e0cd0fde99cd7', disabled_by=None, entity_category=None, hidden_by=None, icon=None, id='b8ca778678886ea0af4beca18b090cfd', has_entity_name=False, name=None, options={'conversation': {'should_expose': True}}, original_device_class=None, original_icon=None, original_name='garage_alert', supported_features=44, translation_key=None, unit_of_measurement=None)]
2023-07-16 09:49:59.138 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'garage'
2023-07-16 09:49:59.141 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=sensor.dummy entity_category=None, sensor_name=techups power strategy=fixed manufacturer= model= standby_power=0.00 unique_id=3788b38d-5330-4c7e-a0ea-8565dda2c6c9)
2023-07-16 09:49:59.141 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: techups energy
2023-07-16 09:49:59.141 DEBUG (MainThread) [custom_components.powercalc.discovery] media_player.hobbyroom_speaker: Auto discovered model (manufacturer=Google Inc., model=Google Home Mini)
2023-07-16 09:49:59.142 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=media_player.hobbyroom_speaker entity_category=None, sensor_name=hobbyroom_speaker power strategy=linear manufacturer=google model=Home Mini (HOA) standby_power=1.65 unique_id=9d2104d0-fa1d-6e19-eeaa-e08660787ed4)
2023-07-16 09:49:59.142 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: hobbyroom_speaker energy
2023-07-16 09:49:59.142 DEBUG (MainThread) [custom_components.powercalc.discovery] media_player.kitchen_display: Auto discovered model (manufacturer=Google Inc., model=Google Nest Hub)
2023-07-16 09:49:59.142 ERROR (MainThread) [custom_components.powercalc.sensors.power] media_player.kitchen_display: Skipping sensor setup Model not found in library (manufacturer: Google Inc., model: Google Nest Hub)
2023-07-16 09:49:59.143 ERROR (MainThread) [custom_components.powercalc.sensors.power] media_player.kitchen_display: Skipping sensor setup: Model not found in library (manufacturer: Google Inc., model: Google Nest Hub)
2023-07-16 09:49:59.143 DEBUG (MainThread) [custom_components.powercalc.discovery] media_player.vardagsrummet_speaker: Auto discovered model (manufacturer=Google Inc., model=Google Nest Mini)
2023-07-16 09:49:59.143 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=media_player.vardagsrummet_speaker entity_category=None, sensor_name=vardagsrummet_speaker power strategy=linear manufacturer=google model=Nest Mini (H2C) standby_power=1.65 unique_id=a7f130bf-f099-1f63-c840-ec0f84b4d285)
2023-07-16 09:49:59.143 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: vardagsrummet_speaker energy
2023-07-16 09:49:59.143 DEBUG (MainThread) [custom_components.powercalc.discovery] media_player.sovrummet_speaker: Auto discovered model (manufacturer=Lenovo, model=Lenovo CD-4N341Y)
2023-07-16 09:49:59.143 ERROR (MainThread) [custom_components.powercalc.sensors.power] media_player.sovrummet_speaker: Skipping sensor setup Model not found in library (manufacturer: Lenovo, model: Lenovo CD-4N341Y)
2023-07-16 09:49:59.143 ERROR (MainThread) [custom_components.powercalc.sensors.power] media_player.sovrummet_speaker: Skipping sensor setup: Model not found in library (manufacturer: Lenovo, model: Lenovo CD-4N341Y)
2023-07-16 09:49:59.143 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped power sensor: smart speakers power (entity_id=sensor.smart_speakers_power)
2023-07-16 09:49:59.144 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped energy sensor: smart speakers energy (entity_id=sensor.smart_speakers_energy)
2023-07-16 09:49:59.145 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=fan.livingroom_starkvind entity_category=None, sensor_name=livingroom_starkvind power strategy=fixed manufacturer= model= standby_power=0.00 unique_id=0x2c1165fffe7daa19_fan_zigbee2mqtt)
2023-07-16 09:49:59.145 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: livingroom_starkvind energy
2023-07-16 09:49:59.145 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped power sensor: environment and air quality power (entity_id=sensor.environment_and_air_quality_power)
2023-07-16 09:49:59.145 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped energy sensor: environment and air quality energy (entity_id=sensor.environment_and_air_quality_energy)
2023-07-16 09:49:59.146 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.hobbyroom_speaker_power to device 3c6837d79a6db595a7d273efba0bef3a
2023-07-16 09:49:59.147 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.hobbyroom_speaker_energy to device 3c6837d79a6db595a7d273efba0bef3a
2023-07-16 09:49:59.147 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.vardagsrummet_speaker_power to device 171edd3abed80b550d5ec6983ee7f3c3
2023-07-16 09:49:59.147 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.vardagsrummet_speaker_energy to device 171edd3abed80b550d5ec6983ee7f3c3
2023-07-16 09:49:59.148 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Load previous energy sensor states from store
2023-07-16 09:49:59.148 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.smart_speakers_energy: Restoring state: 17.8584
2023-07-16 09:49:59.158 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.livingroom_starkvind_power to device 1ce5e89ca8b4bef9386eb3aff5bc1451
2023-07-16 09:49:59.159 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.livingroom_starkvind_energy to device 1ce5e89ca8b4bef9386eb3aff5bc1451
2023-07-16 09:49:59.159 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.environment_and_air_quality_energy: Restoring state: 10.0417
2023-07-16 09:49:59.451 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.vardagsrummet_speaker: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:49:59.526 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.vardagsrummet_speaker: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:49:59.553 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.hobbyroom_speaker: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:49:59.564 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.hobbyroom_speaker: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:49:59.576 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.vardagsrummet_speaker: State changed to "off". Power:1.65
2023-07-16 09:49:59.650 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.hobbyroom_speaker: State changed to "off". Power:1.65
2023-07-16 09:49:59.664 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.vardagsrummet_speaker: State changed to "off". Power:1.65
2023-07-16 09:49:59.681 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.hobbyroom_speaker: State changed to "off". Power:1.65
2023-07-16 09:50:01.883 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:50:02.075 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:50:04.238 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:50:08.487 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.dummy: State changed to "on". Power:27.00
2023-07-16 09:50:08.488 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.hobbyroom_speaker: State changed to "off". Power:1.65
2023-07-16 09:50:08.488 DEBUG (MainThread) [custom_components.powercalc.sensors.power] media_player.vardagsrummet_speaker: State changed to "off". Power:1.65
2023-07-16 09:50:08.488 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: Source entity has an invalid state, setting power sensor to unavailable
2023-07-16 09:50:08.570 DEBUG (MainThread) [custom_components.powercalc.sensors.power] sensor.dummy: State changed to "on". Power:27.00
2023-07-16 09:50:08.705 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: All standby energy
2023-07-16 09:50:10.730 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: State changed to "on". Power:2.00
2023-07-16 09:50:10.743 DEBUG (MainThread) [custom_components.powercalc.sensors.power] fan.livingroom_starkvind: State changed to "on". Power:2.00
2023-07-16 09:50:10.759 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.environment_and_air_quality_energy: Recalculate, current value: 10.0417
2023-07-16 09:50:10.759 DEBUG (MainThread) [custom_components.powercalc.sensors.group] delta for entity sensor.livingroom_starkvind_energy: 0.0000, prev=10.0417, cur=10.0417
2023-07-16 09:50:10.759 DEBUG (MainThread) [custom_components.powercalc.sensors.group] sensor.environment_and_air_quality_energy: New value: 10.0417

Diagnostics dump or YAML config

No response

bramstroker commented 1 year ago

Which version of powercalc are you running? 1.8.0 or 1.8.1?

gribber commented 1 year ago

Which version of powercalc are you running? 1.8.0 or 1.8.1?

1.8.1

bramstroker commented 1 year ago

I think the problem is not related to the change in configuration, but the change in the way auto discovery is working now.

2023-07-16 09:49:59.133 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'outdoor parking driveway'

You are expecting entities in this area right? Previously entities were magically created even if you have enable_autodiscovery: false. In new version this is not the case anymore. So you just have to add a few lines of yaml to register a library supported entity for powercalc registration. For example assume you have a light light.parking_light.

Just add:

sensors:
  - entity_id: light.parking_light`

That should create the powercalc sensors for this light, and than it also should be included in the group again when you use the include option.

gribber commented 1 year ago

I think the problem is not related to the change in configuration, but the change in the way auto discovery is working now.

2023-07-16 09:49:59.133 ERROR (MainThread) [custom_components.powercalc.sensor] Could not resolve any entities in group 'outdoor parking driveway'

You are expecting entities in this area right? Previously entities were magically created even if you have enable_autodiscovery: false. In new version this is not the case anymore. So you just have to add a few lines of yaml to register a library supported entity for powercalc registration. For example assume you have a light light.parking_light.

Just add:

sensors:
  - entity_id: light.parking_light`

That should create the powercalc sensors for this light, and than it also should be included in the group again when you use the include option.

I have literary hundreds of lights, parking lights consists of about 25, that's why I include lights by area, as some tends to be added/removed all the time

So there is no way to automatically add them without define them all one by one and update the configuration by hand every time somethings changes? Or could I just enable enable_autodiscovery? Not sure why I have that at the moment, I think it was added earlier when we debugged some other issue

EDIT: Enable autodiscovery did not help

bramstroker commented 1 year ago

hmm I see your issue. I'm sorry that you are bothered dealing with some extra configuration now. This change had been made to make the behaviour more consistent and also the code easier to maintain. When you enable auto discovery items should appear in the GUI, you can just click configure for these and then everything should return to work correctly hopefully.

bramstroker commented 1 year ago

EDIT: Enable autodiscovery did not help

You'll have to accept the discovered item. As that will make the configuration registered to HA, and powercalc knows it need to setup powercalc sensors for the entity. When you ignore it powercalc will not setup power entities for that entity. And also don't include it when using the include option. Previously it would still setup power sensors, that's one of the reason this change was made.

Screenshot 2023-07-16 at 10 57 45
gribber commented 1 year ago

I see, I guess that's doable Is it possible to rename a energy sensor? When I configured a light, it created duplicates (energy and energy_2, where the only one is unavailable), the power sensor was possible to rename but not the energy as in turned unavailable when I did I want to keep the same name to have the history/statistics left

Not a big problem, just have to remove all old unavailable sensor before I configure each auto discovered light

bramstroker commented 1 year ago

I'm not sure why you get duplicates. As the unique id of the entities should have stayed the same, and not cause any duplicates. How were the power sensors named? old and new one? Could you have a look in config/.storage/core.entity_registry?

gribber commented 1 year ago

old one

      {
        "config_entry_id": null,
        "entity_id": "sensor.bedroom_left_energy",
        "id": "e0965b35fdb6900850b3494d1c518704",
        "orphaned_timestamp": 1689498450.8782144,
        "platform": "powercalc",
        "unique_id": "0x2c1165fffe038a92_light_zigbee2mqtt_energy"
      },

new one:

      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "state_class": "total_increasing"
        },
        "config_entry_id": "65aece4746e2eb662155c8156719de4e",
        "device_class": null,
        "device_id": "1d9edc4c88480e4de6cc5c34f2fdbd8b",
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "sensor.bedroom_left_energy_2",
        "hidden_by": null,
        "icon": null,
        "id": "6b9435d10a4609ccc8fd1315145f98ca",
        "has_entity_name": false,
        "name": null,
        "options": {
          "conversation": {
            "should_expose": false
          },
          "sensor": {
            "display_precision": null
          }
        },
        "original_device_class": null,
        "original_icon": "mdi:lightning-bolt",
        "original_name": "bedroom_left energy",
        "platform": "powercalc",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "pc_0x2c1165fffe038a92_light_zigbee2mqtt_energy",
        "unit_of_measurement": null
      },
bramstroker commented 1 year ago

Ah I see. The unique id should start with pc_, that's a change I made a long time ago. Apparently the automatic created entities did not had this unique id structure yet.

HA tries to create entity with id sensor.bedroom_left_energy, but because it's already taken by the old one, with unique_id 0x2c1165fffe038a92_light_zigbee2mqtt_energy it renames the entity to _2.

I will have a look into the code if I can automatically modify the unique id to match the correct pattern, whenever I see an entity which has the old legacy unique_id pattern.

In the meantime you could try doing this yourself manually for an entity by modifying core.entity_registry file. And change the uniqueid's of powercalc entities to `pc`.

gribber commented 1 year ago

Changing the uuid before works and does not create duplicates

After changing that on one light, I expected the group energy sensors to come online as well, that did not happen, those nested groups are still unavailable outdoor lights (group) -> outdoor ambiance (group) -> conservatory_1 (entity) first two unavailable

root@homeassistant:~# hass-cli state get sensor.outdoor_lights_energy
ENTITY                        DESCRIPTION       STATE        CHANGED
sensor.outdoor_lights_energy  Utomhusbelysning  unavailable  2023-07-16T10:25:38.672963+00:00
root@homeassistant:~# hass-cli state get sensor.outdoor_ambience_energy
ENTITY                          DESCRIPTION              STATE        CHANGED
sensor.outdoor_ambience_energy  outdoor ambience energy  unavailable  2023-07-16T10:25:38.673905+00:00
root@homeassistant:~# hass-cli state get sensor.conservatory_1_energy
ENTITY                        DESCRIPTION              STATE  CHANGED
sensor.conservatory_1_energy  conservatory_1 energy   0.3206  2023-07-16T10:29:42.416088+00:00
bramstroker commented 1 year ago

Are the entities shown correctly on the powercalc integration page. Where all the GUI setup entries are shown?

Screenshot 2023-07-16 at 12 43 54
gribber commented 1 year ago

image

Yeah, that works fine

bramstroker commented 1 year ago

Ok that looks fine. Do you have debug logs again? I suspect you still have the Could not resolve any entities in group error. When you have full debug logs since startup hopefully I can figure out what the issue is.

gribber commented 1 year ago

home-assistant_powercalc_2023-07-16T11-16-46.948Z.log

bramstroker commented 1 year ago

hmm yes, I see the problem. It's a kind of chicken / egg issue. I see in your logs / and also I see that during debugging that the HA yaml setup routine is always executed first before the GUI config entries are setup. I might have an idea how to resolve. Let me give it a thought and do some testing.

bramstroker commented 1 year ago

No unfortunately when having a further look into it and debugging you cannot reference powercalc entities defined with the GUI in the YAML include functionality. As during evalutation of the include options the entities are just not created and not known to powercalc.

So unfortunately I don't really have an easy solution for you now. I will give it some more thought. Might reintroduce the old logic somehow. But it's a hard one as there are so many systems, configurations and setups to consider.

You can either define the entity_id's explicitely in the YAML which you want to include in your system, or downgrade to 1.7.* for now.

gribber commented 1 year ago

Downgraded, it would be too much to maintain to keep the configuration updated for each light to be worth it

I hope you find a way to solve it, thanks in advance

bramstroker commented 1 year ago

I wrote some code to correctly include the GUI powercalc sensors when using the YAML include options.

1756

Are you able to test that by installing the master branch?

When this works correctly you'll only have to click the blue button to configure (adopt it in your HA system) when a new light is added and supported by powercalc. Or when a non supported light gets supported. Than it will automatically be added to the group you created with YAML.

gribber commented 1 year ago

Tested, don't think I can see any difference against 1.8.1, groups still not created, attaching the debug log home-assistant_powercalc_2023-07-16T13-12-59.473Z.log

bramstroker commented 1 year ago

Could you verify first that you are on latest master. Should be commit ec66a909732363d00800b4cac9cd03da4dd98da7.

Screenshot 2023-07-16 at 15 27 44

You also did still have some entities setup using the GUI right?

When the answer on above both is true I might need to add some extra debug logging to the code.

gribber commented 1 year ago

image It is (fell for that one before so I made sure I got the correct one this time :) )

bramstroker commented 1 year ago

Haha, ok good to know we are on the right version. Let's focus on 1 entity / area in debugging this. Which individual entity do you expect in which area group? For this entity you have setup using discovery now, right? Could you lookup the JSON for that in config/.storage/core.config_entries?

gribber commented 1 year ago

Let's focus on conservatory_1 then The defined area for that one is dekoration_ute which is included in the sub-group "outdoor ambience" as below: https://github.com/gribber/ha/blob/main/integrations/powercalc.yaml#L3-L17

image

Added by autodiscovery: image

the json for that light (energy):

      {
        "aliases": [],
        "area_id": null,
        "capabilities": {
          "state_class": "total_increasing"
        },
        "config_entry_id": "bd9ee80f8dce1e30798d6624545d8db4",
        "device_class": null,
        "device_id": "2e5f990fc475fa0f1edb75f39cfb806b",
        "disabled_by": null,
        "entity_category": null,
        "entity_id": "sensor.conservatory_1_energy",
        "hidden_by": null,
        "icon": null,
        "id": "385ecf2f868012e2d3f8e4d4fd80c6cd",
        "has_entity_name": false,
        "name": null,
        "options": {
          "conversation": {
            "should_expose": false
          }
        },
        "original_device_class": null,
        "original_icon": "mdi:lightning-bolt",
        "original_name": "conservatory_1 energy",
        "platform": "powercalc",
        "supported_features": 0,
        "translation_key": null,
        "unique_id": "pc_0x84fd27fffe2ce1d3_light_zigbee2mqtt_energy",
        "unit_of_measurement": null
      },
bramstroker commented 1 year ago

Thanks for the information. Looks like you shared information from .storage/core.entity_registry, needs to be .storage/core.config_entries. That contains all the data for the GUI configuration options. But there is an easier way to get that btw, you can also click the three dots and "Download diagnostics".

gribber commented 1 year ago

Thanks for the information. Looks like you shared information from .storage/core.entity_registry, needs to be .storage/core.config_entries. That contains all the data for the GUI configuration options. But there is an easier way to get that btw, you can also click the three dots and "Download diagnostics".

You are correct, here comes the data:

      {
        "entry_id": "bd9ee80f8dce1e30798d6624545d8db4",
        "version": 2,
        "domain": "powercalc",
        "title": "conservatory_1",
        "data": {
          "entity_id": "light.conservatory_1",
          "manufacturer": "ikea",
          "model": "LED2005R5",
          "unique_id": "pc_0x84fd27fffe2ce1d3_light_zigbee2mqtt",
          "sensor_type": "virtual_power",
          "name": "conservatory_1",
          "_power_entity": "sensor.conservatory_1_power",
          "_energy_entity": "sensor.conservatory_1_energy"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "integration_discovery",
        "unique_id": "pc_0x84fd27fffe2ce1d3_light_zigbee2mqtt",
        "disabled_by": null
      }
gribber commented 1 year ago

Diagnostics file: config_entry-powercalc-bd9ee80f8dce1e30798d6624545d8db4.json.txt

bramstroker commented 1 year ago

That looks exactly as expected. These are also correct. right?

"_power_entity": "sensor.conservatory_1_power",
"_energy_entity": "sensor.conservatory_1_energy"

Then I might need to add some extra debug logging. I also changed the debug line Found include entities to only list the entity_id's and not full objects. Less data and makes it a lot easier to read.

gribber commented 1 year ago

That looks exactly as expected. These are also correct. right?

"_power_entity": "sensor.conservatory_1_power",
"_energy_entity": "sensor.conservatory_1_energy"

Yeah that's correct

bramstroker commented 1 year ago

Can you overwrite config/custom_components/powercalc/group_include/include.py with the following version https://github.com/bramstroker/homeassistant-powercalc/blob/debug-include/custom_components/powercalc/group_include/include.py? Added multiple extra logs here. That would hopefully show what goes wrong. Restart after that and check logs again.

gribber commented 1 year ago

home-assistant_powercalc_2023-07-16T15-04-12.159Z.log

bramstroker commented 1 year ago

I only see:

Including entities from area: parkering_och_uppfart Including entities from area: uterum Including entities from area: garage

These are all the first groups from the nested structure, so that's a pattern there. Need to have a further look into that if I can reproduce. Might be an regression bug in v1.8.

Could you try adding the GUI entry for a sensor for one of these groups and see if the group works correctly again? For example garage

bramstroker commented 1 year ago

I'm pretty sure the above happens because when no entities could be resolved for an area than it will be considers as an error and stop processing the other entities in the group. Will have a look if we can continue processing the other entities/subgroups in that case.

gribber commented 1 year ago

Didn't we have that problem before as well? I stopped when no lights was resolved in the first group I small bulb lighted up somewhere in my head

including the debug file, added garage_alert from auto discovery home-assistant_powercalc_2023-07-16T15-23-01.115Z.log

bramstroker commented 1 year ago

Didn't we have that problem before as well? I stopped when no lights was resolved in the first group I small bulb lighted up somewhere in my head

I don't know. Anyways I was able to reproduce with a test and will have a look into fixing that. And that will also prevent any regressions in the future.

including the debug file, added garage_alert from auto discovery home-assistant_powercalc_2023-07-16T15-23-01.115Z.log

That confirmed my suspision:

2023-07-16 17:21:03.396 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Including entities from area: garage
2023-07-16 17:21:03.397 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Found possible include entities: ['light.garage_alert']
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Try to find power sensor
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Walk config entries
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Check config entry bedroom_left
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Check config entry bedroom_right
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Check config entry conservatory_1
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Check config entry garage_alert
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] light.garage_alert: Found config entry garage_alert
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped power sensor: garage power (entity_id=sensor.garage_power)
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped energy sensor: garage energy (entity_id=sensor.garage_energy)
2023-07-16 17:21:03.398 DEBUG (MainThread) [custom_components.powercalc.group_include.include] Including entities from area: teknikrum

Now it sets up garage correctly and also continous to teknikrum.

bramstroker commented 1 year ago

Continue setting up group on error has been fixed with #1757 Is merged to master.

gribber commented 1 year ago

Confirmed working, now all groups showing again :)

bramstroker commented 1 year ago

Awesome! Thanks for providing the info and helping debugging this one.