I installed 4 colour bulbs (SHELLY DUO - RGBW GU10) in home assistant with ShellyForHass. The bulbs were recognised in ‘devices’ as SHCB-1. Unfortunately, there were no ‘entities’ made, so I couldn’t add the bulbs to the Lovelace-UI.
I also have Shelly dimmer 2 and Shelly 2.5 installed and they work flawlessly.
QUESTION: what goes wrong with the bulbs?
Therefore I switched to MQTT. I use the mqtt template that is shown below.
In the Lovelace-UI I can change colour, use white and effects, so that is fine.
The problem is: I can’t switch them off and on. (When I change the slider, within a second it’s switched back)
I use the topic:
shellies/shellycolorbulb<id>/color/0/set (command-topic)
and
shellies/shellycolorbulb<id>/color/0/status (state-topic)
.
According to the shelly API, I can’t switch the bulb with the command-topic …/set.
In nodered I can switch the bulb off/on with:
msg.payload = on (or off) and
topic: shellies/shellycolorbulb<id>/color/0/command
So, it seems that I need a second command-topic: …/command.
In mqtt explorer I also see 3 topics: …/set ; …/status ; and …/command.
QUESTION: What should I change in mqtt template to switch the bulbs on/off? or is there another solution for this.
(yes, I put an RFXtrx switch in the light-rail to switch the power off/on for all 4 bulbs. But that is not an elegant solution)
configuration.yml:
- platform: mqtt
schema: template
name: "TV ColorBulb 3"
command_topic: "shellies/shellycolorbulb-<id>/color/0/set"
state_topic: "shellies/shellycolorbulb-<id>/color/0/status"
effect_list:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
command_on_template: >
{"turn": "on"
{%- if brightness is defined -%}
, "gain": {{brightness | float | multiply(0.3922) | round(0)}}
{%- endif -%}
{%- if red is defined and green is defined and blue is defined -%}
, "red": {{ red }}, "green": {{ green }}, "blue": {{ blue }}
{%- endif -%}
{%- if white_value is defined -%}
, "white": {{ white_value }}
{%- endif -%}
{%- if effect is defined -%}
, "effect": {{ effect }}
{%- endif -%}
}
command_off_template: '{"turn":"off"}'
state_template: "{% if value_json.ison %}on{% else %}off{% endif %}"
brightness_template: "{{ value_json.gain | float | multiply(2.55) | round(0) }}"
red_template: '{{ value_json.red }}'
green_template: '{{ value_json.green }}'
blue_template: '{{ value_json.blue }}'
white_value_template: '{{ value_json.white }}'
effect_template: '{{ value_json.effect }}'
qos: 2