Hi, did you find the correct pins and manage to set up a Shelly rgbw2 with esphome?
Sure did. First, flash the shelly with esphome - should be pretty straightforward. Then, use the table at the end of this blog post to figure out the channel - pin mapping on the Shelly. Lastly, set up the output components and the cwww platform like so:
This is how I got it going, but it’s not in “production” yet - just a test for now.
Thanks for sharing!
Hi,
Thanks all for the information!
I’ve been using the RGBW2 through MQTT for months but wanted to get rid of MQTT.
So I’ve flashed my Shelly RGBW2 with ESPHOME.
I used this config
After adding the Shelly RGBW2 to Home Assistant through the ESPHOME integration I am able to change colors, dimming and changing the white value of my RGBW led strip.
Care to elaborate on how to flash? I am having a rough time.
Thanks for these details! Two questions:
- Are you able to control RGB and W independently with ESPHome and HA? (When I previously used Tasmota + HA with a different RGBW controller, HA wouldn’t let me turn on the white LED at the same time as RGBs; if I touch the white value slider, the RGBs would turn off.)
- Were you able to get a physical on/off, dimmer, or momentary switch working (I)nput terminal on the Shelly?
- Yes I’m able to control the white value independently. When RGB is on changing the white value also changes the RGB value. If you I only turn on W and change the white value then I can go from standard cold white to warm white.
- I don’t need a physical switch. It’s in my bathroom and have other main lighting. This is more a mood light which is turned on from time to time.
I just wanted to post my solution for a Shelly RGBW2 for monochromic lighting on all 4 outputs with one switch to control them like a regular dimmable light:
substitutions:
device_name: dim_0
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
logger:
api:
reboot_timeout: 15min
password: !secret api_password
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: !secret domain
fast_connect: true
light:
- platform: monochromatic
name: ${device_name}_ch1
id: ${device_name}_ch1
output: ${device_name}_out_ch1
- platform: monochromatic
name: ${device_name}_ch2
id: ${device_name}_ch2
output: ${device_name}_out_ch2
- platform: monochromatic
name: ${device_name}_ch3
id: ${device_name}_ch3
output: ${device_name}_out_ch3
- platform: monochromatic
name: ${device_name}_ch4
id: ${device_name}_ch4
output: ${device_name}_out_ch4
# Example output entry
output:
- platform: esp8266_pwm
id: ${device_name}_out_ch1
pin: GPIO12
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_ch2
pin: GPIO15
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_ch3
pin: GPIO14
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_ch4
pin: GPIO4
frequency: 1000 Hz
binary_sensor:
- platform: gpio
pin: GPIO5
id: light_0_touch
on_click:
then:
- if:
condition:
- light.is_off: ${device_name}_ch1
- light.is_off: ${device_name}_ch2
- light.is_off: ${device_name}_ch3
- light.is_off: ${device_name}_ch4
then:
- light.turn_on:
id: ${device_name}_ch1
brightness: 1.0
- light.turn_on:
id: ${device_name}_ch2
brightness: 1.0
- light.turn_on:
id: ${device_name}_ch3
brightness: 1.0
- light.turn_on:
id: ${device_name}_ch4
brightness: 1.0
else:
- light.turn_off: ${device_name}_ch1
- light.turn_off: ${device_name}_ch2
- light.turn_off: ${device_name}_ch3
- light.turn_off: ${device_name}_ch4
on_press:
then:
- if:
condition:
light.is_off: ${device_name}_ch1
then:
- delay: 0.5s
- while:
condition:
binary_sensor.is_on: light_0_touch
then:
- light.dim_relative:
id: ${device_name}_ch1
relative_brightness: 5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch2
relative_brightness: 5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch3
relative_brightness: 5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch4
relative_brightness: 5%
transition_length: 0.1s
- delay: 0.1s
else:
- delay: 0.5s
- while:
condition:
and:
- binary_sensor.is_on: light_0_touch
- light.is_on: ${device_name}_ch1
then:
- light.dim_relative:
id: ${device_name}_ch1
relative_brightness: -5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch2
relative_brightness: -5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch3
relative_brightness: -5%
transition_length: 0.1s
- delay: 0.1s
- light.dim_relative:
id: ${device_name}_ch4
relative_brightness: -5%
transition_length: 0.1s
- delay: 0.1s
The channels are then combined in to one group in HA.
I’m posting this because I found it somewhat difficult for to find all the bits and pieces, so maybe it helps someone.
cheers
Hi
I’ve just bought my first Shelly RGBW2 to be used with a 620x620mm LED light panel ( https://www.synergy21.de/media/pdf/dd/42/a1/166579-Datenblatt.pdf )
Using the stock-firmware and the web interface, the primary colors (red,green,blue) are ok, but every color from the color picker is off (red for instance looks like violet)
I found this question from another user having the same problem:
Do you experience this as well? Or does esphome “fix” this bug?
Thanks in advance,
Cheers!
Never mind. I found a way to flash esphome (working around those mini-connectors) and esphome does provide better color accuracy. Not perfect, but better
A little trick to work around those 1.27 mm pitch headers:
It’s a bit MacGyver-style, but it works, and you only need it once
Well, I am a child of the 80’s… And without googling I came up with the exact same idea .
At first I tried a paper clip, but it was to thick. Then I though of the old resistors I still have in storage
Can you post the full config?
Has anyone figured out how to create a power sensor for the Shelly RGBW2 device running ESPhome? Would love to see a working .yaml file for that.
According to this Tasmota article, you can monitor voltage using the A0 pin. I tried this as follows:
sensor:
- platform: adc
id: voltage_analog_reading
pin: A0
name: ${friendly_name} Voltage
unit_of_measurement: V
icon: mdi:flash-circle
update_interval: 10s
However, the output is fixed value of 0.37, no matter what I do with my lights (on/off/change brightness/…).
Answering my own question. Turns out the yaml is correct. The voltage did vary between 0.365 and 0.369 V which is why I didn’t see any change at first. The load only varied from 0 to about 4 Watt, which explains why the voltage didn’t change all that much. So, it all works
Hi, since this is the only Shelly RGBW2 topic on the forum I might ask my question here best. I have flashed esphome on my shelly rgbw2 in order to replace my zwave fibaro rgbw led driver with the shelly. I only want to use 1 output: white. According to the specs it should be able to drive 45W which is more than enough for my 10x2W white dimmable LEDs. But I have no success with both @ebula his and @lolfonfire his configs in driving out a signal on either 1 out of 4 channels for driving my LEDs… I have tried with LEDs connected and tried to measure voltage with a multi-meter but no voltage comes out… I think it has to do that the esphome component ony send the “signal” and not the power… but according to the specs the sehlly (sh)(c)ould do this…
Can someones please help me out with a push in the right direction on how to use esphome to drive out voltage for my LEDs?
(ps. please do not start a discussion on why I do no use the stock firmware )
Thanks!
Solved. Can dim 4 channels separate or combined to RGBW. The culprit was the LEDs need to be powered between DC (+) and a channel which is (-). Thus for me a little illogical since the plus is on the LED and the other is the minus which is 1 of the 4 channels (R G B W)… Thus a channel is MINUS.
For others. You can flash completely OTA (thus no wires needed!
use this:
Then important!!! you cannot directly flash esphome binary via the tasmota webinterface of the device due to less memory. Download minimal tasmota in between:
ota.tasmota.com/tasmota/release-9.1.0/
this :http://ota.tasmota.com/tasmota/release-9.1.0/tasmota-minimal.bin
don’t use version 10 of minimal, that’s too big.
Then via minimal upload the esphome bin file… voila…
My config:
# Lamp Kitchen
substitutions:
device_name: shelly_rgbw_01
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
wifi:
ssid: "ssid"
password: !secret ssid
domain: !secret domain
#use_address: 192.168.6.70
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name} Fallback Hotspot"
password: !secret Fallback_Hotspot
captive_portal:
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: wifi_signal
name: "${device_name} - WiFi Signal"
update_interval: 60s
- platform: uptime
name: "${device_name} - Uptime"
icon: mdi:clock-outline
update_interval: 60s
- platform: uptime
name: Uptime Seconds
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
light:
- platform: monochromatic
name: ${device_name}_R
id: ${device_name}_R
output: ${device_name}_out_R
- platform: monochromatic
name: ${device_name}_G
id: ${device_name}_G
output: ${device_name}_out_G
- platform: monochromatic
name: ${device_name}_B
id: ${device_name}_B
output: ${device_name}_out_B
- platform: monochromatic
name: ${device_name}_W
id: ${device_name}_W
output: ${device_name}_out_W
output:
- platform: esp8266_pwm
id: ${device_name}_out_R
pin: GPIO12
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_G
pin: GPIO15
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_B
pin: GPIO14
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_W
pin: GPIO4
frequency: 1000 Hz
text_sensor:
- platform: template
name: Uptime
id: uptime_human
icon: mdi:clock-start
- platform: version
name: "ESPHome Version"
switch:
- platform: restart
name: "${device_name} Restart"
For all fans, my complete yaml with power measurement and the whole shabang
substitutions:
device_name: shelly_rgbw_01
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
esp8266_restore_from_flash: true
wifi:
ssid: "ssid"
password: !secret ssid_wifi_key
domain: !secret domain
#use_address: 192.168.6.70
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${device_name} Fallback Hotspot"
password: !secret Fallback_Hotspot
#fast_connect: true
captive_portal:
# Enable logging
logger:
level: DEBUG
# Enable Home Assistant API
api:
ota:
web_server:
port: 80
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: wifi_signal
name: "${device_name} - WiFi Signal"
update_interval: 60s
- platform: uptime
name: "${device_name} - Uptime"
icon: mdi:clock-outline
update_interval: 60s
- platform: uptime
name: "${device_name} - Uptime Seconds"
id: uptime_sensor
update_interval: 60s
on_raw_value:
then:
- text_sensor.template.publish:
id: uptime_human
state: !lambda |-
int seconds = round(id(uptime_sensor).raw_state);
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return (
(days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")
).c_str();
- platform: adc
pin: A0
name: "${device_name} - adc"
update_interval: 1s
accuracy_decimals: 4
id: current_raw
internal: true
- platform: template
name: "${device_name} - Power"
unit_of_measurement: W
accuracy_decimals: 1
device_class: power
update_interval: 30s
id: my_power
lambda: return id(current_raw).state;
filters:
- calibrate_linear:
- 0.4000 -> 0.0
- 0.4043 -> 0.14
- 0.4053 -> 0.20
- multiply: 12 # 12V lamp
- platform: total_daily_energy
name: "${device_name} - Total Daily Energy"
power_id: my_power
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kW
light:
- platform: monochromatic
name: ${device_name}_R
id: ${device_name}_R
output: ${device_name}_out_R
restore_mode: RESTORE_DEFAULT_OFF
- platform: monochromatic
name: ${device_name}_G
id: ${device_name}_G
output: ${device_name}_out_G
restore_mode: RESTORE_DEFAULT_OFF
- platform: monochromatic
name: ${device_name}_B
id: ${device_name}_B
output: ${device_name}_out_B
restore_mode: RESTORE_DEFAULT_OFF
- platform: monochromatic
name: ${device_name}_W
id: ${device_name}_W
output: ${device_name}_out_W
restore_mode: RESTORE_DEFAULT_ON
output:
- platform: esp8266_pwm
id: ${device_name}_out_R
pin: GPIO12
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_G
pin: GPIO15
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_B
pin: GPIO14
frequency: 1000 Hz
- platform: esp8266_pwm
id: ${device_name}_out_W
pin: GPIO4
frequency: 1000 Hz
text_sensor:
- platform: template
name: "${device_name} - Uptime"
id: uptime_human
icon: mdi:clock-start
update_interval: 60s
- platform: version
name: "${device_name} - ESPHome Version"
- platform: wifi_info
ip_address:
name: "${device_name} - IP"
switch:
- platform: restart
name: "${device_name} - Restart"
Will copy few items from your config!
Also I learned just now that underscores should not be used in the device names.