bramstroker / homeassistant-powercalc

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

No lookup file found for mode: color_temp #2247

Closed erkr closed 1 month ago

erkr commented 1 month ago

System Health details

System Information

version core-2024.5.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.1.73-haos-raspi
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 | 4352 Installed Version | 1.34.0 Stage | running Available Repositories | 1401 Downloaded Repositories | 38
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 | Home Assistant OS 12.2 -- | -- update_channel | stable supervisor_version | supervisor-2024.05.1 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 219.4 GB disk_used | 62.3 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | File editor (5.8.0), Mosquitto broker (6.4.0), MariaDB (2.7.1), Network UPS Tools (0.13.0), Home Assistant Google Drive Backup (0.112.1), InfluxDB (5.0.0), FTP (5.0.2), phpMyAdmin (0.9.1), Advanced SSH & Web Terminal (17.3.0), MQTT Explorer (browser-1.0.3), WireGuard (0.10.2), Grafana (10.0.0), Music Assistant (2.0.4)
Dashboards dashboards | 6 -- | -- resources | 28 views | 32 mode | storage
Recorder oldest_recorder_run | May 12, 2024 at 19:18 -- | -- current_recorder_run | May 18, 2024 at 08:45 estimated_db_size | 740.73 MiB database_engine | mysql database_version | 10.11.6

Checklist

Describe the issue

I have 3 lights that only have colour control, no colour temp. Two of them are first gen blooms, the other is Led strip from the Lidl. They worked fine, until I upgraded from core 2024.5.3 to the core 2024.5.4 today. I guess that is not related, except that I restarted HA after several days. I included the debug log for both types.

Reproduction steps

  1. Restart HA, models missing
  2. ...

Debug logs

2024-05-18 08:45:33.519 DEBUG (MainThread) [custom_components.powercalc.discovery] light.hue_bloom_1: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue bloom (LLC011))
2024-05-18 08:45:33.529 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.hue_bloom_1 entity_category=None, sensor_name=Bloom power strategy=lut manufacturer=signify model=LLC011 unique_id=3420b8e3-2ae5-4fe6-b40d-fa31a971d4d3)
2024-05-18 08:45:33.530 ERROR (MainThread) [custom_components.powercalc.sensors.power] light.hue_bloom_1: Skipping sensor setup: No lookup file found for mode: color_temp
2024-05-18 08:45:33.531 DEBUG (MainThread) [custom_components.powercalc.discovery] light.hue_lightstrip_1: Auto discovered model (manufacturer=Signify Netherlands B.V., model=Hue lightstrip (LST001))
2024-05-18 08:45:33.536 DEBUG (MainThread) [custom_components.powercalc.sensors.power] Creating power sensor (entity_id=light.hue_lightstrip_1 entity_category=None, sensor_name=Lichtstrip power strategy=lut manufacturer=signify model=LST001 unique_id=742f8a5a-abb7-4649-aa3d-2771d5658daf)
2024-05-18 08:45:33.537 ERROR (MainThread) [custom_components.powercalc.sensors.power] light.hue_lightstrip_1: Skipping sensor setup: No lookup file found for mode: color_temp

Diagnostics dump or YAML config

Bloom properties in dev tools. It mentions that color-temp mode is supported, but it only has RGB lights:

min_color_temp_kelvin: 2000
max_color_temp_kelvin: 6535
min_mireds: 153
max_mireds: 500
supported_color_modes:
  - color_temp
  - xy
color_mode: null
brightness: null
color_temp_kelvin: null
color_temp: null
hs_color: null
rgb_color: null
xy_color: null
mode: normal
dynamics: none
friendly_name: Bloom
supported_features: 40
bramstroker commented 1 month ago

Which integration are you using for the lights?

Powercalc validates that a lookup file exists for every color mode the light supports. When the integration falsly reports a wrong color_mode for the light this will break the powercalc sensor.

This issue appeared in the past with Hue integration and also Tapo P100 integration. Also had contact with core developer of Hue about this and pretty sure all was fixed, because there were no such reports anymore the last months. But there appear to be a regression on it.

I might consider removing the upfront validation during setup and just create the power sensor. Then when you select a color_mode where no LUT file is available for I will set the sensor to unavailable and raise an error.

What happens when you select color_temp on the bloom light? Is it actually doing something?

bramstroker commented 1 month ago

I have changed the Powercalc logic to make things less error prone. I just go forward setting up the sensor now, and whenever you switch to a color mode which is not supported by powercalc, then the sensor will get unavailable and error logged.

https://github.com/bramstroker/homeassistant-powercalc/pull/2248

Will be in next release.

erkr commented 1 month ago

I'm using it via the HUE integration. It seems the HUE bridge changed! Both in my HUE apps and in HA I can now set a colour temp, although the light physical only has RGB This is the dev tool properties after controlling the light using color temp:

min_color_temp_kelvin: 2000
max_color_temp_kelvin: 6535
min_mireds: 153
max_mireds: 500
supported_color_modes:
  - color_temp
  - xy
color_mode: color_temp
brightness: 143
color_temp_kelvin: 2000
color_temp: 500
hs_color:
  - 30.601
  - 94.547
rgb_color:
  - 255
  - 136
  - 13
xy_color:
  - 0.599
  - 0.382
mode: normal
dynamics: none
friendly_name: Bloom vitrinekast
supported_features: 40

Can I help to extend the model? Don't have the required power plugs but maybe I can map the colour settings used to achieve the selected color_temp

bramstroker commented 1 month ago

Can I help to extend the model? Don't have the required power plugs but maybe I can map the colour settings used to achieve the selected color_temp

When we can extract a formula somehow how to convert from a certain color_temp to a hsv value, I might implement that as a fallback.

Assuming color_temp mode is selected.

  1. Check if the model has no color_temp.csv, but has a hs.csv
  2. Convert color temp to hs_color value
  3. Lookup power in hs.csv
bramstroker commented 1 month ago

There seem to be a formula/mapping already in HA:

https://github.com/home-assistant/core/blob/dev/homeassistant/util/color.py#L505

bramstroker commented 1 month ago

That yields the same values as seen in your developer tools snippet.

Screenshot 2024-05-19 at 08 18 34
bramstroker commented 1 month ago

Implemented with #2249

erkr commented 1 month ago

I just tried v1.12.3, and hte sensor is already back with that version, and indeed unavailable in color_temp mode. Looking forward for the fallback :-)

erkr commented 1 month ago

Yesssss fully fixed in 1.12.4. 🙏