It uses the keys brightness and state whereas the Shelly uses brightness and turn. They use the same term for brightness but different ones for state (state vs turn). I think that’s why you can control the light’s brightness but can’t control its state (on/off).
I think that it must somemthing like that in config, but i get error
Invalid config for [light.mqtt]: [command_on_template] is an invalid option for [light.mqtt]. Check: light.mqtt->command_on_template. (See ?, line ?). Please check the docs at https://home-assistant.io/components/light.mqtt/
I think that problem is because brightness is in JSON format but On and off is in “template”.
Also ON and OFF is send to shellies/shellyrgbw2-2B90ED/white/0/
but brightness is send to shellies/shellyrgbw2-2B90ED/white/0/set
It is also strange that status update do not work, maybe becase it need some settings because it is in JSON format? If i suscribe to it get status update like this
I said this earlier but I’ll say it again. The format of an RGBW2’s status and command is not the same as the format used by MQTT Light (schema: json). They both uses JSON format but the key names are not identical.
MQTT Light with schema: template allows you to use templates to convert the format of status and command messages. In other words, templates are used to convert Shelly’s JSON messages into the JSON format used by Home Assistant.
If this is the RGBW2’s status message: {"ison":false,"mode":"white","brightness":1,"power":0.00,"overpower":false}
then you need a template to extract the brightness value and, because there’s no state available, you must extract the value for ison and use it to represent the status of state.
Thanx a lot, now working brightnes and on off i just must figure it how set up that status will work. For example, now if i set brightness to 50% and close web UI and open again i see 0% brightness. I think that there must be some change: state_template: '{{ value_json.ison }}' On mqtt i get this status {"ison":false,"mode":"white","brightness":1,"power":0.00,"overpower":false}
Invalid config for [light.mqtt]: [brightness_scale] is an invalid option for [light.mqtt]. Check: light.mqtt->brightness_scale. (See ?, line ?). Please check the docs at https://home-assistant.io/components/light.mqtt/
Yes, the command_on_template and brightness_template have to be modified. They must convert from Home Assistant’s brightness scale (0-255) to the Shelly’s scale which I assume is 0-100? Or is it 1-100?
Assuming it’s 0-100 we need to multiply Home assistant’s values by 100/255 = 0.3922.
Try the test again. Using Home Assistant, set the brightness to 50% (leave the UI open), then tell me the MQTT status message. It should report ison:true and brightness:50.