bieniu / ha-shellies-discovery

Script that adds MQTT discovery support for Shellies devices
Apache License 2.0
290 stars 90 forks source link

Support for Shelly RGBW DUO #588

Open sebastiannielsen opened 1 month ago

sebastiannielsen commented 1 month ago

Is your feature request related to a problem? Please describe. Duo bulb not supported

Describe the solution you'd like Support for Duo Bulb

Additional context

Have tried with the following code, but it isn't working right, power measurement works fine, but not light switch:

MODEL_SHELLYCB = f"{ATTR_SHELLY} Color Bulb" MODEL_SHELLYCB_ID = "SHCB-1" # Shelly Color Bulb Duo RGB MODEL_SHELLYCB_PREFIX = "shellycolorbulb"

if model_id == MODEL_SHELLYCB_ID or dev_id_prefix == MODEL_SHELLYCB_PREFIX:

model = MODEL_SHELLYCB
inputs = 0
rgbw_lights = 1
white_lights = 1

white_lights = {
    0: {
        KEY_COLOR_TEMP_TEMPLATE: TPL_COLOR_TEMP_WHITE_LIGHT,
        KEY_COMMAND_ON_TEMPLATE: TPL_COMMAND_ON_WHITE_LIGHT_DUO,
        KEY_COMMAND_TOPIC: TOPIC_LIGHT_SET,
        KEY_MAX_MIREDS: 370,
        KEY_MIN_MIREDS: 153,
        KEY_STATE_TOPIC: TOPIC_COLOR_0_STATUS,
    }
}
light_sensors = {
    SENSOR_POWER: OPTIONS_SENSOR_LIGHT_POWER,
    SENSOR_ENERGY: OPTIONS_SENSOR_LIGHT_ENERGY,
}
sensors = {
    SENSOR_IP: OPTIONS_SENSOR_IP,
    SENSOR_RSSI: OPTIONS_SENSOR_RSSI,
    SENSOR_SSID: OPTIONS_SENSOR_SSID,
    SENSOR_UPTIME: OPTIONS_SENSOR_UPTIME,
}
buttons = {BUTTON_RESTART: OPTIONS_BUTTON_RESTART}
updates = {UPDATE_FIRMWARE: OPTIONS_UPDATE_FIRMWARE}

Here is a example of MQTT status its spitting out:

Meddelande 270 mottaget på shellies/shellycolorbulb-3494546E7DE6/color/0/status vid 23:13 : { "ison": true, "source": "mqtt", "has_timer": false, "timer_started": 0, "timer_duration": 0, "timer_remaining": 0, "mode": "color", "red": 14, "green": 255, "blue": 242, "white": 0, "gain": 100, "temp": 3000, "brightness": 100, "effect": 0, "transition": 0 }

(it spit out on color/0/status regardless of its in color or white mode) White mode:

Meddelande 279 mottaget på shellies/shellycolorbulb-3494546E7DE6/color/0/status vid 23:14 : { "ison": true, "source": "http", "has_timer": false, "timer_started": 0, "timer_duration": 0, "timer_remaining": 0, "mode": "white", "red": 14, "green": 255, "blue": 242, "white": 0, "gain": 100, "temp": 3000, "brightness": 100, "effect": 0, "transition": 0 }

It also spits out the following statuses, why energy meter works:

Meddelande 284 mottaget på shellies/shellycolorbulb-3494546E7DE6/color/0 vid 23:14 : on QoS: 0 - Retain: false Meddelande 283 mottaget på shellies/shellycolorbulb-3494546E7DE6/light/0/energy vid 23:14 : 135 QoS: 0 - Retain: false Meddelande 282 mottaget på shellies/shellycolorbulb-3494546E7DE6/light/0/power vid 23:14 : 8.59 QoS: 0 - Retain: false

It also seems to expect a plain "on" or "off" payload (no JSON) on: shellies/shellycolorbulb-3494546E7DE6/color/0/command

to turn off and on.

If seems to require, to set color, a set JSON payload on shellies/shellycolorbulb-3494546E7DE6/color/0/set

With the following content: { "mode": "color", "red": 0, ## 0-255 "green": 0, ## 0-255 "blue": 0, ## 0-255 "white": 0, ## 0-255 "gain": 100, ## 0-100 "effect": 0 ## 0 = no effect, 1 = meteror shower, 2 = gradual change, 3 = flash } OR { "mode": "white", "temp": 4750, ## 3000 to 6500 "brightness": 100 ## 0-100 }

bieniu commented 1 month ago

Discussed many times, at the moment there is no way to properly and fully configure this bulb via MQTT. At least I don't know how to do it. If someone creates the correct configuration we can add it to the script, I won't work on it because my bulb died.

sebastiannielsen commented 1 month ago

Actually tried out the script in the PR and it works out well: https://github.com/bieniu/ha-shellies-discovery/pull/585

image image 20240803_110315

image 20240803_110612

It even works with the effects values.

So I say, you should work on getting that PR merged.

inch1957 commented 4 weeks ago

Hello bieniu, regarding this open issue, I have an old version of your script (the version is not documented, but my file is dated May 2023), where there are entries concerning this device type: MODEL_SHELLYBULB_ID = "SHBLB-1" # Shelly Bulb MODEL_SHELLYBULB_PREFIX = "shellybulb"

MODEL_SHELLYBULBRGBW_ID = "SHCB-1" # Shelly DUO RGBW MODEL_SHELLYBULBRGBW_PREFIX = "shellycolorbulb"

And further down of course the appropriate codings... old_shellies_discovery.txt

De Facto, I have (did have...) 2 of these bulbs in my Home-assistant. I deleted one and with the latest version of your script it will of course no longer get re-installed. The original entry is there and working.

Somewhere in the works your coding seems to have got dropped...

Hope this info helps, thanks for your great work on making all this so simple!