homeassistant-powercalc icon indicating copy to clipboard operation
homeassistant-powercalc copied to clipboard

Platform powercalc does not generate unique IDs

Open jake404 opened this issue 2 years ago • 9 comments

I have for a while been getting error messages regarding one light bulb but haven't had the time to report it. As you can see in the log below the errors seem to be connected to Zigbee device naming. Stairwell light has the IEEE address 0xccccccfffec78389 in Zigbee2MQTT. sensor.stairwell_light_power and sensor.stairwell_light_energy work as they should but not the rest of the energy sensors. I have several Zigbee bulbs and with the exception to the below bulb, all sensors created by powercalc work as the should.

2022-09-20 10:40:01.793 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee is already used by sensor.stairwell_light_power - ignoring sensor.stairwell_light_power
2022-09-20 10:40:01.794 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy is already used by sensor.stairwell_light_energy - ignoring sensor.stairwell_light_energy
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_daily_peak is already used by sensor.stairwell_light_energy_daily_peak - ignoring sensor.stairwell_light_energy_daily_peak
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_daily_offpeak1 is already used by sensor.stairwell_light_energy_daily_offpeak1 - ignoring sensor.stairwell_light_energy_daily_offpeak1
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_daily_offpeak2 is already used by sensor.stairwell_light_energy_daily_offpeak2 - ignoring sensor.stairwell_light_energy_daily_offpeak2
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_weekly_peak is already used by sensor.stairwell_light_energy_weekly_peak - ignoring sensor.stairwell_light_energy_weekly_peak
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_weekly_offpeak1 is already used by sensor.stairwell_light_energy_weekly_offpeak1 - ignoring sensor.stairwell_light_energy_weekly_offpeak1
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_weekly_offpeak2 is already used by sensor.stairwell_light_energy_weekly_offpeak2 - ignoring sensor.stairwell_light_energy_weekly_offpeak2
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_monthly_peak is already used by sensor.stairwell_light_energy_monthly_peak - ignoring sensor.stairwell_light_energy_monthly_peak
2022-09-20 10:40:01.795 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_monthly_offpeak1 is already used by sensor.stairwell_light_energy_monthly_offpeak1 - ignoring sensor.stairwell_light_energy_monthly_offpeak1
2022-09-20 10:40:01.796 ERROR (MainThread) [homeassistant.components.sensor] Platform powercalc does not generate unique IDs. ID 0xccccccfffec78389_light_zigbee_energy_monthly_offpeak2 is already used by sensor.stairwell_light_energy_monthly_offpeak2 - ignoring sensor.stairwell_light_energy_monthly_offpeak2

jake404 avatar Sep 20 '22 09:09 jake404

@jake404 It's a very strange error. I have no idea what causes this.

The error is complaining about the unique_id already used by the same entity "used by sensor.stairwell_light_power - ignoring sensor.stairwell_light_power". How did you set up the sensors? With yaml or gui? Could you enable debug logging and share full logs after startup? Maybe that gives some hints.

bramstroker avatar Sep 20 '22 09:09 bramstroker

All sensors are setup in YAML, this is my sensor config:

- platform: powercalc
  create_utility_meters: true
  create_group: All lights
  entities:
    - create_group: Stairwell lights
      entities:
        - entity_id: light.stairwell_light
    - create_group: Second floor lights
      entities:
        - create_group: Hallway upstairs lights
          entities:
            - entity_id: light.hallway_upstairs_light
        - create_group: Bedroom lights
          entities:
            - entity_id: light.bedroom_floor_light
            - entity_id: light.bedroom_window_light_1
            - entity_id: light.bedroom_window_light_2
    - create_group: First floor lights
      entities:
        - create_group: Kitchen lights
          entities:
            - entity_id: light.kitchen_sink_light_2
              manufacturer: ikea
              model: LED1537R6
            - entity_id: light.kitchen_sink_light_3
              manufacturer: ikea
              model: LED1537R6
            - entity_id: light.kitchen_window_light
            - entity_id: light.kitchen_mudroom_light
            - entity_id: light.kitchen_door_light
            - entity_id: light.kitchen_island_lights
              power_sensor_id: sensor.kitchen_island_lights_electric_consumption_w
        - create_group: Hallway downstairs lights
          entities:
            - entity_id: light.hallway_downstairs_light
        - create_group: Guest room lights
          entities:
            - entity_id: light.guest_room_light
        - create_group: TV room lights
          entities:
            - entity_id: light.tv_room_downlights
              power_sensor_id: sensor.tv_room_downlights_electric_consumption_w
    - create_group: Basement lights
      entities:
        - entity_id: light.basement_light_1
        - entity_id: light.basement_light_2
        - entity_id: light.basement_light_3

The log was fairly big so I had to share it from my NAS: https://gofile.me/48qLa/BZtA9BGhx

jake404 avatar Sep 20 '22 12:09 jake404

@jake404 Looks like you enabled debug log for whole HA, which causes a massive amount of log lines (that's why it is so big), and makes it hard to make any sense of. You can enable for powercalc only, see the last section in the readme.

bramstroker avatar Sep 20 '22 17:09 bramstroker

Here is the log: https://privatebin.net/?2234e099885f96f9#BnyNRbXgCcM4s8RMzCHZaEjuA4kCjp6ejhwBRHiyXtV9

jake404 avatar Sep 20 '22 18:09 jake404

I see powercalc is trying to create a virtual power sensor for the same entity twice, which results in this error.

You can see this when searching on this phrase: Creating power sensor (entity_id=light.stairwell_light There are 2 occurrences but there should be only one.

Could you try disabling auto discovery first and see if the error disappears? Add following to configuration.yaml and restart afterwards.

powercalc:
  enable_autodiscovery: false

bramstroker avatar Sep 20 '22 18:09 bramstroker

With auto discovery off the error is gone.

jake404 avatar Sep 20 '22 18:09 jake404

ok nice, I will see if I can reproduce with this information. As you have defined all the entities yourself in yaml you don't rely on auto discovery so you can just leave that disabled.

bramstroker avatar Sep 20 '22 18:09 bramstroker

I have the same issue. Powercalc creates a duplicate entity and I cannot remove the duplicate. Happy to share logs if it will help. I use the GUI.

peterxrock avatar Sep 20 '22 21:09 peterxrock

@peterxrock Yes please could you also share your logs. I am unable to reproduce yet, it's a tough issue. And could you also try disabling auto discovery to see if this also solves for you?

bramstroker avatar Sep 21 '22 07:09 bramstroker

@peterxrock @jake404 Could you also test with v1.0.0-beta.1, I have also made some changes there which could potentially fix your issues. When it is still not resolved could you also share your logs @peterxrock ?

bramstroker avatar Sep 23 '22 14:09 bramstroker

With v1.0.0-beta.1 the original error message is gone, however I got a new error message.

Logger: custom_components.powercalc.sensors.group
Source: custom_components/powercalc/sensors/group.py:361
Integration: Powercalc ([documentation](https://github.com/bramstroker/homeassistant-powercalc), [issues](https://github.com/bramstroker/homeassistant-powercalc/issues))
First occurred: 16:13:35 (27 occurrences)
Last logged: 16:14:00

sensor.all_lights_power: One or more members of the group are unavailable, setting group to unavailable (sensor.kitchen_window_light_power,sensor.kitchen_mudroom_light_power,sensor.stairwell_light_power)
sensor.all_lights_power: One or more members of the group are unavailable, setting group to unavailable (sensor.kitchen_window_light_power,sensor.kitchen_mudroom_light_power)
sensor.kitchen_lights_power: One or more members of the group are unavailable, setting group to unavailable (sensor.kitchen_mudroom_light_power)
sensor.first_floor_lights_power: One or more members of the group are unavailable, setting group to unavailable (sensor.kitchen_mudroom_light_power)
sensor.all_lights_power: One or more members of the group are unavailable, setting group to unavailable (sensor.kitchen_mudroom_light_power)

The referenced lights are not unavailable after startup. Should I create a new issue or is this expected?

jake404 avatar Sep 23 '22 14:09 jake404

@jake404 yes this was something I also changed yesterday and is unrelated. Could you create a new issue for this, then I will provide some insights.

bramstroker avatar Sep 23 '22 15:09 bramstroker