So, this project was born out of wanting to replace the controller from two sets of these fairy lights.
Partially because I wanted them both to turn on at the same time, and partly because having the stock controller on a z-wave plug seemed to reset the effects back to the ‘demo’ one, which cycled through some seizure-inducing flashing.
Evidently anyone else that has done so hasn’t written it up, or my Google-fu sucked, because I really struggled to find anything I could use as base, other than the example stuff on the ESPHome docs, and a snippet of Red-Green transition lambda code.
I’ll post a bit more about the hardware used and add a wiring diagram later, but the proof of concept on a test set of string lights works a treat - and I’ve managed to bodge together a couple of effects that work for the way ESPHome sees these lights.
Hardware:
- Wemos D1 Mini
- L298N H-Bridge
- 8A36V Power Supply
- 1500x Warm White Fairy Lights
Issues:
- Need to see if there’s a better way to ‘activate’ each string in the strobe effect, rather than color_temperature. Tried cold_white/warm_white but it threw a “Color temperature value 0.00 is out of range (153.0 - 500.0)”. 3500K seems to be close to the mid-point to activate both strings so have been using that as an “all on” value.
- In the lambda effect, it seems to flicker a little on each cycle.
- Add some more effects - in particular a ‘twinkle’ where the two sets of lights twinkle at random brightnesses.
ESPHome YAML:
esphome:
name: "led-strings"
platform: ESP8266
board: d1_mini
wifi:
ssid: !secret wifi_iot_ssid
password: !secret wifi_iot_password
ap:
ssid: $friendly_name Fallback Hotspot
password: !secret esphome_fallback_ap_password
captive_portal:
logger:
api:
encryption:
key: !secret esphome_api_key
ota:
password: !secret esphome_api_password
output:
- platform: esp8266_pwm
id: pina
pin: GPIO12
- platform: esp8266_pwm
id: pinb
pin: GPIO14
light:
- platform: hbridge
id: ledstrings
name: "led-strings"
pin_a: pina
pin_b: pinb
effects:
- strobe:
name: "Flash A-B 500ms"
colors:
- state: true
color_temperature: 2000 K
duration: 500ms
- state: true
color_temperature: 6534 K
duration: 500ms
- strobe:
name: "Flash A-AB-B 500ms"
colors:
- state: true
color_temperature: 2000 K
duration: 500ms
- state: true
color_temperature: 3500 K
duration: 500ms
- state: true
color_temperature: 6534 K
duration: 500ms
- state: true
color_temperature: 3500 K
duration: 500ms
- lambda:
name: "Fade A-AB-B 10s"
update_interval: 10s
lambda: |-
static int state = 0;
auto call = id(ledstrings).make_call();
call.set_transition_length(10000);
if (state == 0) {
call.set_warm_white(1.0);
call.set_cold_white(0.0);
} else if (state ==1) {
call.set_warm_white(0.0);
call.set_cold_white(1.0);
}
call.perform();
state += 1;
if (state == 2)
state = 0;