Skip to content

Add support for Shelly Duo RGBW light bulbs#585

Merged
bieniu merged 3 commits intobieniu:masterfrom
Xinayder:shelly-duo-rgbw
Nov 4, 2024
Merged

Add support for Shelly Duo RGBW light bulbs#585
bieniu merged 3 commits intobieniu:masterfrom
Xinayder:shelly-duo-rgbw

Conversation

@Xinayder
Copy link
Copy Markdown
Contributor

@Xinayder Xinayder commented Jul 23, 2024

This PR adds support for Shelly Duo RGBW light bulbs. Currently only tested with a GU10.

KEY_EFFECT_TEMPLATE was added for Lovelace to properly display what effect is currently selected. I used the Shelly RGBW2 as a base, but had to change KEY_BRIGHTNESS_VALUE_TEMPLATE to KEY_BRIGHTNESS_TEMPLATE for the same reason previously described. The light bulb only supports 4 effects, including "Off" (no effect).

To turn on the light bulb, the effect field must be present on the MQTT payload, thus if you only want to turn on the light and not use any effects, just set the field to 0.

Thanks to @tc-maxx for providing a MQTT discovery payload for this light bulb (#424)

This is the YAML generated by the Python script:

schema: template
qos: 0
red_template: '{%if value_json.mode == "color"%}{{value_json.red}}{%else%}{{ none }}{%endif%}'
green_template: >-
  {%if value_json.mode == "color"%}{{value_json.green}}{%else%}{{ none
  }}{%endif%}
blue_template: >-
  {%if value_json.mode == "color"%}{{value_json.blue}}{%else%}{{ none
  }}{%endif%}
state_topic: shellies/shellycolorbulb-485519DA73A9/color/0/status
brightness_state_topic: shellies/shellycolorbulb-485519DA73A9/color/0/status
origin:
  name: Shellies Discovery
  sw_version: 5.1.0
  support_url: https://github.com/bieniu/ha-shellies-discovery
effect_command_template: >-
  { {%if value=="Off"%}"effect":0{%elif value=="Meteor Shower"%}"effect":1{%elif
  value=="Gradual Change"%}"effect":2{%elif value=="Flash"%}"effect":3{%endif%}
  }
state_template: '{%if value_json.ison%}on{%else%}off{%endif%}'
unique_id: shellycolorbulb-485519da73a9-light-0
effect_state_topic: shellies/shellycolorbulb-485519DA73A9/color/0/status
availability:
  - payload_not_available: 'false'
    topic: shellies/shellycolorbulb-485519DA73A9/online
    payload_available: 'true'
  - value_template: '{%if value_json.mqtt.connected%}online{%else%}offline{%endif%}'
    topic: shellies/shellycolorbulb-485519DA73A9/info
max_mireds: 333
min_mireds: 154
command_on_template: >-
  {"turn":"on"{%if red is defined and green is defined and blue is
  defined%},"mode":"color","red":{{red}},"green":{{green}},"blue":{{blue}}{%endif%}{%if
  brightness is
  defined%},"brightness":{{brightness|float|multiply(0.3922)|round}},"gain":{{brightness|float|multiply(0.3922)|round}}{%endif%}{%if
  color_temp is
  defined%},"mode":"white","temp":{{(1000000/(color_temp|int))|round(0,"floor")}}{%endif%}{%if
  transition is defined%},"transition":{{min(transition|multiply(1000),
  5000)}}{%endif%}{%if effect is defined%},"effect": {%- if effect == "Meteor
  Shower" -%}1{%- elif effect == "Gradual Change" -%}2{%- elif effect == "Flash"
  -%}3{%- else -%}0{%- endif -%}{%- else -%},"effect": 0{%endif%} }
brightness_command_topic: shellies/shellycolorbulb-485519DA73A9/color/0/set
effect_list:
  - 'Off'
  - Meteor Shower
  - Gradual Change
  - Flash
brightness_template: '{{value_json.brightness|float|multiply(2.55)|round(0)}}'
effect_command_topic: shellies/shellycolorbulb-485519DA73A9/color/0/set
brightness_command_template: >-
  {"gain":{{value|float|multiply(0.3922)|round(0)}},
  "brightness":{{value|float|multiply(0.3922)|round(0)}}}
device:
  name: Shelly Duo RGBW 485519DA73A9
  connections:
    - - mac
      - 48:55:19:da:73:a9
  hw_version: gen1 (SHCB-1)
  sw_version: 20231107-162425/v1.14.1-rc1-g0617c15
  model: Shelly Duo RGBW
  configuration_url: http://192.168.1.138/
  manufacturer: Allterco Robotics
command_off_template: >-
  {"turn":"off","effect":0{%if transition is
  defined%},"transition":{{min(transition|multiply(1000),5000)}}{%endif%}}
effect_template: >-
  {%if value_json.effect==1%}Meteor Shower{%elif value_json.effect==2%}Gradual
  Change{%elif value_json.effect==3%}Flash{%else%}Off{%endif%}
name: Light 0
command_topic: shellies/shellycolorbulb-485519DA73A9/color/0/set
color_temp_template: '{{((1000000/(value_json.temp|int,2700)|max)|round(0,"floor"))}}'
platform: mqtt

image image

Closes #588

Xinayder added 2 commits July 23, 2024 21:57
Thanks to @tc-maxx for providing a MQTT discovery payload for this light bulb, check bieniu#424
Copy link
Copy Markdown
Owner

@bieniu bieniu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix lint errors. My RGBW2 died so I need a while to get a new one to test this. Thanks!

@bieniu bieniu added the new-feature A new feature label Aug 3, 2024
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 3, 2024

Stale pull request message

@tcsmaxx
Copy link
Copy Markdown

tcsmaxx commented Oct 4, 2024

Hi @Xinayder, it looks like there are still some requested changes for this PR. Would you be able to take a look and help implement the necessary adjustments? Let me know if there's anything I can assist with to move this forward. Thanks for your work on this!

@bieniu bieniu merged commit 66601e7 into bieniu:master Nov 4, 2024
@Xinayder
Copy link
Copy Markdown
Contributor Author

Xinayder commented Nov 4, 2024

My notifications were off for some reason, I am terribly sorry for forgetting about this PR. I'm happy that it was merged!

@bieniu
Copy link
Copy Markdown
Owner

bieniu commented Nov 4, 2024

Thanks for your contribution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Shelly RGBW DUO

3 participants