Mqqt json and shelly RGBW2

It is here…

Can anyone adapt it to the shellybulb though?

Working off of this config I’m now stuck.

What do I need to publish, and to what, to control the colours and effects?

How are you configuring the HA front end to make this device easily useable?

Any yaml shares will be much appreciated.

I just updated to HomeAssistant 0.94.1 and I’m having a little issue with my Shelly RGBW2 modules.

When I’m sending this command, HomeAssistant sends out the MQTT message {“turn”:“off”} to shellies/shellyrgbw2-2B9246/color/0/set

- service: light.turn_on
  entity_id: light.ledstrip_office_mqtt
  data:
    rgb_color: [0,0,0]
    brightness: 0
    white_value: 150
    effect: 0

Before the update (version 0.90.1) this worked like expected, now it’s broken.

It seems to be something with “brightness”:“0”, when removing this line, the LEDstrip turns on, but with the RGB reverting to previous setting.

Sending “brightness”:“1” instead of 0 seems to fix the problem for now.

Was there a (breaking) change made to the mqtt light component?

My RGBW2 config:

light:
  - platform: mqtt
    schema: template
    name: "LEDstrip Office MQTT"
    command_topic: "shellies/shellyrgbw2-2B9246/color/0/set"
    state_topic: "shellies/shellyrgbw2-2B9246/color/0/status"
    availability_topic: "shellies/shellyrgbw2-2B9246/online"
    payload_available: "true"
    payload_not_available: "false"
    effect_list:
      - 0
      - 1
      - 2
      - 3
    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
    retain: false

Hi David,

Under the schema: template I don’t see any configuration to handle the red_template blue_template or green_template but rather rgb_command_topic. Your problem may lie within here.

I have a RGBW2 working and I’ll upload my config for you later. I have each of the RGBW set up as different lights so I have control for each separately.

David