Open jpeterse opened 4 days ago
Hey there @emontnemery, @jbouwh, @bdraco, mind taking a look at this issue as it has been labeled with an integration (mqtt
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
mqtt documentation mqtt source (message by IssueLinks)
Made a quick (although low-res) video of the issue with setting the RBG color, through message to RGB_STATE_TOPIC: Even low-res, it was still too large to attached directly here, so I uploaded here instead: https://youtu.be/CD0jWpz1LhY
Video is private, and only available through this link.
Made a quick (although low-res) video of the issue with setting the RBG color, through message to RGB_STATE_TOPIC: Even low-res, it was still too large to attached directly here, so I uploaded here instead: https://youtu.be/CD0jWpz1LhY
Video is private, and only available through this link.
I'm not able to view it, i'm afraid.
That the brightness is set, is by-design. The RGB color are not normalized for brightness. As no brightness information is expected it is estimated from the highest value from R, G or B.
https://developers.home-assistant.io/docs/core/entity/light/
Sorry, changed video from private to unlisted. Ahh, I see. That makes sense.
On the color_mode issue I was working through. If I don't specify the color_mode_state_topic, so only the color_mode attribute on the light is define, I often get NONE as color and brightness, even if the RGB_STATE_TOPIC does have a valid color code. If I send a color code to the light, it's not being set, and nothing appear in log either. What is the requirements when multiple color_modes are listed in capabilities? Is it required to also have an current color code in HS_STATE_TOPIC, if current color_mode is set to RBG for example?
The RGB values are normalized assuming a 100% brightness, if that is not supplied. But as it is expected brightness can be set for a light, the brightness value is calculated for you, and when set, it is used to scale the RGB values to light when it's RGB values are set. It is enough to have a rgb_state_topic
, a color_mode_state_topic
is not needed. The available color modes are determined based on the topics you subscribe to. This works differently when using the json
schema, where the available color modes are specified in advance.
I think I understand now. I've been testing for better understand the logic that is happening. color_mode will be set by what color state is send last. Sending an RGB code, sets the color_mode to RGB. And also sets the brightness, if not specifically set previously. Likewise, an HS color code sets the color_mode to HS.
When light is changed from within HA, the HA will always send out a RGB command code, if the RBG command topic is configured. Even if the color_mode is currently set to HS. In order to force the light to observe the current color_mode and send color commands in HS format, I need to remove the RGB command topic from the light's discovery topic message. Which means, when I have a light fixture with interchangeable led modules, that each have different capabilities, I have to either resubmit the discovery topic, to match the type of led's, that is in the fixture currently. Or alternatively, perform conversation from RGB color to for example HS color code in the fixture's firmware.
The problem
I am registering a new light via MQTT discovery. Discovery work fine, and I can control the lights on/off state with MQTT messages.
However, I have issues with setting a light color value via MQTT. I found, that if I have both RGB and HS options configured, and color_mode is set to RGB, and I send a color as a comma separated RGB raw content message to RGB_STATE_TOPIC , HA does not set the color of the light. The state of the color in HA is reported as "None". This is regardless of what content I provide for RGB_VALUE_TEMPLATE. In order to make HA response to RBG state updates, when HS capability is also configured, then COLOR_MODE_STATE_TOPIC is required to be configured with value "rgb".
I then remove all HS configuration options, and now HA start to respond to RGB message on RGB_STATE_TOPIC. However it respond incorrectly. The brightness of the light is set to the first value provided (which should be the red color value). The green and blue is set to some value, different from what was provided in the message.
If this is intended functionality, then please update the documentation, to point out, that COLOR_MODE_STATE_TOPIC is required, if more than one color_mode is configured. And update documentation on what the correct value to send to RGB_STATE_TOPIC should be, in order to correctly set the RGB value of the light.
Light Discovery message without HS configured:
Light discovery message with HS configured:
Content of RGB_STATE_TOPIC:
content of COLOR_MODE_STATE_TOPIC:
State of light in HA, with rgb, hs options configured:
What version of Home Assistant Core has the issue?
core-2024.11.2
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
MQTT
Link to integration documentation on our website
https://www.home-assistant.io/integrations/light.mqtt/
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response