bramstroker / homeassistant-powercalc

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

TRADFRI bulb E14 WS 470lm not recognized #1939

Closed Mariusthvdb closed 11 months ago

Mariusthvdb commented 11 months ago

System Health details

before I had these lights on a Tradfri gateway and they were nicely added to powercalc, creating a device_power sensor.

Ive moved some of the Ikea lights to ZHA, and that is now showing as

TRADFRI bulb E14 WS 470lm

Scherm­afbeelding 2023-12-05 om 17 47 18

could it be the LED1949C5 (which this is, see https://www.ikea.com/nl/en/p/tradfri-led-bulb-e14-470-lumen-smart-wireless-dimmable-white-spectrum-chandelier-20486784/) needs another alias in the model.json? currently listing:

{
    "measure_description": "Measured with utils/measure script",
    "measure_device": "Shelly Plug S",
    "measure_method": "script",
    "measure_settings": {
        "SAMPLE_COUNT": 1,
        "SLEEP_TIME": 2,
        "VERSION": "v0.18.4:docker"
    },
    "name": "TRADFRI bulb E14 WS candle opal 470lm",
    "standby_power": 0.2,
    "calculation_strategy": "lut",
    "aliases": [
        "TRADFRIbulbE14WScandleopal470lm"
    ]
}

so failing the exact TRADFRI bulb E14 WS 470lm ?

because of that, the PC group is throwing below error

Checklist

Describe the issue

light not recognized/nop device_power entity created

Reproduction steps

  1. add light in ZAH and have PC auto-discover
  2. ...

Debug logs

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.powercalc.sensors.group
Source: custom_components/powercalc/sensors/group.py:498
Integration: Powercalc (documentation, issues)
First occurred: 17:35:52 (1 occurrences)
Last logged: 17:35:52

sensor.kerststerren_device_energy: Could not restore last state: [<class 'decimal.ConversionSyntax'>]

Diagnostics dump or YAML config

            - create_group: Kerststerren
              entities:
                - entity_id: light.ster_links
                - entity_id: light.ster_rechts

fwiw, I added that to the alias section manually locally, but that does Not fix the issue...

nor does adding a unique_id to the create_group:

            - create_group: Kerststerren
              unique_id: powercalc_group_sterren
              entities:
                - entity_id: light.ster_links
                - entity_id: light.ster_rechts

btw, I missed we had this before: https://github.com/bramstroker/homeassistant-powercalc/issues/658

bramstroker commented 11 months ago

Yes probably only needs the new alias added. You may go forward and create a PR for that. I'll merge it asap and release new version.

Mariusthvdb commented 11 months ago

but how? as I said, I added it locally and it didnt fix the issue.. Also, see the note I added to the opening topic, we had this before

Mariusthvdb commented 11 months ago

maybe its something else after all, because this is in the debug logs:

2023-12-05 22:48:00.646 DEBUG (MainThread) [custom_components.powercalc.discovery] light.ster_links: Auto discovered model (manufacturer=IKEA of Sweden, model=TRADFRI bulb E14 WS 470lm)
2023-12-05 22:48:00.647 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.ster_links entity_category=None, sensor_name=Ster links device power strategy=lut manufacturer=ikea model=LED1835C6 unique_id=cc:86:ec:ff:fe:19:d8:a7-1)
2023-12-05 22:48:00.647 DEBUG (MainThread) [custom_components.powercalc.strategy.lut] Loading LUT data file: /config/custom_components/powercalc/power_profile/../data/ikea/LED1835C6/color_temp.csv.gz
2023-12-05 22:48:00.653 DEBUG (MainThread) [custom_components.powercalc.strategy.lut] LUT file loaded: 1144 lines

and

2023-12-05 22:48:00.654 DEBUG (MainThread) [custom_components.powercalc.discovery] light.ster_rechts: Auto discovered model (manufacturer=IKEA of Sweden, model=TRADFRI bulb E14 WS 470lm)
2023-12-05 22:48:00.654 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.ster_rechts entity_category=None, sensor_name=Ster rechts device power strategy=lut manufacturer=ikea model=LED1835C6 unique_id=cc:86:ec:ff:fe:16:1e:6f-1)

and even though they have a name: sensor_name=Ster links device power and sensor_name=Ster rechts device power, these are not in the dev tools....

bramstroker commented 11 months ago

This seems fine and indicates the profile for the light is found and CSV files loaded correctly. It indicates that the power sensor should be created. You are 100% sure it's not to be found in entities list / developer tools? No further errors / issues in the logs regarding these entities?

Mariusthvdb commented 11 months ago

yes, sure, I've tried both name and attribute, and anything with 'dummy'

we can see it being set as source for the energy sensors correctly. (though it isnt found, hence the 'unknown')

Scherm­afbeelding 2023-12-06 om 14 32 47 Scherm­afbeelding 2023-12-06 om 14 33 29 Scherm­afbeelding 2023-12-06 om 14 33 11 Scherm­afbeelding 2023-12-06 om 14 35 13

same for the other device_power entity

and trickles down into the group entities:

Scherm­afbeelding 2023-12-06 om 14 39 23
bramstroker commented 11 months ago

I have no clue why the entities are not created. You are confident there are no errors / warnings following the "Creating power sensor" lines after startup?

Mariusthvdb commented 11 months ago

from the logs:

2023-12-06 13:20:33.764 DEBUG (MainThread) [custom_components.powercalc.discovery] light.ster_links: Auto discovered model (manufacturer=IKEA of Sweden, model=TRADFRI bulb E14 WS 470lm)
2023-12-06 13:20:33.764 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.ster_links entity_category=None, sensor_name=Ster links device power strategy=lut manufacturer=ikea model=LED1835C6 unique_id=cc:86:ec:ff:fe:19:d8:a7-1)
2023-12-06 13:20:33.765 DEBUG (MainThread) [custom_components.powercalc.strategy.lut] Loading LUT data file: /config/custom_components/powercalc/power_profile/../data/ikea/LED1835C6/color_temp.csv.gz
2023-12-06 13:20:33.769 DEBUG (MainThread) [custom_components.powercalc.strategy.lut] LUT file loaded: 1144 lines
2023-12-06 13:20:33.769 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: Ster links device energy
2023-12-06 13:20:33.769 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Ster links device energy daily (entity_id=sensor.ster_links_device_energy_2_daily)
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Ster links device energy yearly (entity_id=sensor.ster_links_device_energy_2_yearly)
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.discovery] light.ster_rechts: Auto discovered model (manufacturer=IKEA of Sweden, model=TRADFRI bulb E14 WS 470lm)
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.ster_rechts entity_category=None, sensor_name=Ster rechts device power strategy=lut manufacturer=ikea model=LED1835C6 unique_id=cc:86:ec:ff:fe:16:1e:6f-1)
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.sensors.energy] Creating energy sensor: Ster rechts device energy
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Ster rechts device energy daily (entity_id=sensor.ster_rechts_device_energy_2_daily)
2023-12-06 13:20:33.770 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Ster rechts device energy yearly (entity_id=sensor.ster_rechts_device_energy_2_yearly)
2023-12-06 13:20:33.771 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped power sensor: Kerst sterren device power (entity_id=sensor.kerst_sterren_device_power)
2023-12-06 13:20:33.771 DEBUG (MainThread) [custom_components.powercalc.sensors.group] Creating grouped energy sensor: Kerst sterren device energy (entity_id=sensor.kerst_sterren_device_energy)
2023-12-06 13:20:33.771 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Kerst sterren device energy daily (entity_id=sensor.kerst_sterren_device_energy_daily)
2023-12-06 13:20:33.771 DEBUG (MainThread) [custom_components.powercalc.sensors.utility_meter] Creating utility_meter sensor: Kerst sterren device energy yearly (entity_id=sensor.kerst_sterren_device_energy_yearly)

a bit down:

2023-12-06 13:20:34.472 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_links_device_energy_2 to device cce913993542f1d458925713358e598f
2023-12-06 13:20:34.476 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_links_device_energy_2_daily to device cce913993542f1d458925713358e598f
2023-12-06 13:20:34.478 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_links_device_energy_yearly_2 to device cce913993542f1d458925713358e598f
2023-12-06 13:20:34.480 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_rechts_device_energy_2 to device a579956e9c1a7ec2702e365a29ff3119
2023-12-06 13:20:34.480 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_rechts_device_energy_2_daily to device a579956e9c1a7ec2702e365a29ff3119
2023-12-06 13:20:34.482 DEBUG (MainThread) [custom_components.powercalc.sensors.abstract] Binding sensor.ster_rechts_device_energy_yearly_2 to device a579956e9c1a7ec2702e365a29ff3119
2023-12-06 13:20:34.484 WARNING (MainThread) [custom_components.powercalc.sensors.group] sensor.kerst_sterren_device_energy: Could not restore last state: [<class 'decimal.ConversionSyntax'>]

could these be written in some hidden file, whihc I could maybe delete? I did try to edit the powercalc_group, but it gets rewritten during edit.. maybe I should delete that completely? Or will my config be lost then

Mariusthvdb commented 11 months ago

arghh, some progress:

Scherm­afbeelding 2023-12-06 om 15 58 22 Scherm­afbeelding 2023-12-06 om 15 58 38

but cant enable them?

Might this be a remnant of the former integration (Ikea Tradfri), and, because I no longer have the lights on that integration, and thus that device no longer exists) so I cant re-enable?

bramstroker commented 11 months ago

sensor.ster_links_device_energy_2 mind the _2. That's probably part of you problem / issues.

Might be some similar issue as #1919. Where the unique_id of the source entity has changed. Probably also the case for you because another integration is providing the entity now. You could try looking into core.entity_registry if there are some old references somehow.

Very busy atm and coming weeks, so don't have time to investigate this further. It's also a very complex problem, so will definitely take some time to dig in to.

Mariusthvdb commented 11 months ago

and so it was! I deleted all entires from core.entity registry and restarted:

Scherm­afbeelding 2023-12-06 om 16 10 18

there still are other issues in the energy sensor, but maybe that can be solved in the same way:

group entities:

Scherm­afbeelding 2023-12-06 om 16 13 36

and for the individual entities, there's a mixup between the new _2 entities as source and ones with the unsuffixed entity_id's

though the unsuffixed entities update now:

Scherm­afbeelding 2023-12-06 om 16 17 14

and the _2 remain unknown.

Mariusthvdb commented 11 months ago

finally, after having followed this order of operation:

all entities are there, and no more suffixes.

still a lot of 'unknown' energy entities both for the grouped and for the individual.

but at least no more unavailable and yet:

this keeps bugging

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.powercalc.sensors.group
Source: custom_components/powercalc/sensors/group.py:498
Integration: Powercalc (documentation, issues)
First occurred: 16:52:19 (1 occurrences)
Last logged: 16:52:19

sensor.kerst_sterren_device_energy: Could not restore last state: [<class 'decimal.ConversionSyntax'>]```

update

after some time (not sure since I had to go away...but certainly not the regular initial 10 minutes) I now see that all energy sensors have been populated with an actual state. Seems perfect now.

Also restart on the new 2023.12 release And the todays Powercalc update to 1.9.9 fixed the restore error I have been reporting.

this issue will close .

It might be a sane thing to do and post the order of operation when actually trying to delete legacy entities from a yaml config in your guide somewhere......