xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.98k stars 635 forks source link

Lights JSON broken on recent home assistant #2539

Open mcspr opened 1 year ago

mcspr commented 1 year ago

Noticed in gitter https://gitter.im/tinkerman-cat/espurna?at=632e273b9d3c186299170be1

Based on updated docs https://www.home-assistant.io/integrations/light.mqtt/#json-schema

"white_value" is deprecated and replaced with ["color"]["w"] and ["color"]["c"] combined with "color_mode" https://github.com/xoseperez/espurna/blob/75a518c6caaa40289737b0c8faaf8b96e5ce129a/code/espurna/homeassistant.cpp#L414-L430

https://www.home-assistant.io/integrations/light.mqtt/#color_mode

Flag that defines if the light supports color modes.

https://www.home-assistant.io/integrations/light.mqtt/#supported_color_modes

A list of color modes supported by the list. This is required if color_mode is True. Possible color modes are onoff, brightness, color_temp, hs, xy, rgb, rgbw, rgbww, white.

mcspr commented 1 year ago

Some context. Plus, might be important to remember that HASS has a dev blog

mswiss commented 1 year ago

Hi, are you planning to release a fix for this HA change anytime soon?

mcspr commented 1 year ago

Fix is in the tree, just pending some testing for the concurrent WebUI changes for the binary

mattster98 commented 1 year ago

I noticed this issue on a H801 I have had on 1.14.1 for a long time but only now getting into Home Assistant. I two-step upgraded to the 230112 nightly and it is now being provisioned in HomeAssistant, HOWEVER, it is only showing up as an off/on SWITCH. None of the color or brightness controls are being discovered, even though they are enabled. I have tried various reboot, enable/disable of HASS integration, mqtt json on/off, etc.. but nothing seems to help.

Edit/Update: I found a second entity that appears to be properly configured.. not sure why there are two, but it appears to be sent as both a device: switch with a trailing _0 as well as an entity: light without the trailing _0 . The light has a status of read-only which is preventing me using it in automations, even though when I choose it, I can make changes that appear to work.

mcspr commented 1 year ago

HA might give some hints in the logger, where it processes MQTT subscription to homeassistant/+ Entity changes between versions were not really avoidable

mattster98 commented 1 year ago

What was the previous relayProv0 value? :) I didn't look before I changed it. It seemed to disable on/off functionality entirely, at least with my current setup.

I think the relay provider attached to the device is coming through the MQTT plugin, and the Light entity is coming via the HASS integration setting on Espurna.

Overnight the Light entity lost its "read only" status on the entity list.. and seems to be staying that way.

I found how to automate entities (I'm still an HA newbie). If it works at all I should be good to go.

mcspr commented 1 year ago

^ del relayProv0 and reset

from MQTT side of things

1.14.1 did not have this single topic, so we had an extra relay to do state switches. This is no longer the case and lights work differently, but it is kept for backwards compatibility (and for people not using HASS; no need to change topics)

Both switch and light are separate entities when we publish to discovery topic.

mattster98 commented 1 year ago

Thanks! I think what threw me off so much was how straightforward some of the simple relay (even multiple relay) espurnas still on 1.14.1 came into HA, but this one (and the others like it, as I eventually discovered) are quite different.