Hi All,
As a HA/yaml novice and many headaches, I’ve managed to get my first automation working using an Aqara P1 motion sensor, analog RGBCC (5in1 leds), and ESPThings Analoge LED controller.
I have these instaled in my kitchen running a slow rainbow effect, and when motion is detected the effect stops and the leds go to full power and brightness to provide light to work on the kitchen worktops.
This works reasonably well for what I wish to do, but once motion is detected the leds turn to white like flicking a light switch On. I’d like them to fade On (say over 10 seconds).
I’ve tried using transition, but this doesn’t work.
I know I can add many more service call for light turn On at different increments of percentages or pwm power (call service light turn on 5%, call another service light turn on 10% and so on), but I was wondering if there was a better way rather then having like 20 service calls in one automation?
Can someone point me in the right direction for reading how to do this in a better way?
Heres the esp leds sketch;
esphome:
name: kitchen-colour-leds-1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "Guess"
ota:
password: "Guess"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Kitchen-Colour-Leds-1"
password: "Guess"
captive_portal:
sensor:
- platform: wifi_signal
name: "WiFi Signal $devicename"
update_interval: 60s
output:
- platform: ledc
pin: 26
frequency: 25000Hz
id: ledc_cw
- platform: ledc
pin: 18
frequency: 25000Hz
id: ledc_ww
- platform: ledc
pin: 19
frequency: 25000Hz
id: ledc_r
- platform: ledc
pin: 23
frequency: 25000Hz
id: ledc_g
- platform: ledc
pin: 05
frequency: 25000Hz
id: ledc_b
light:
- platform: rgbww
name: "kitchen colour leds 1"
id: kcl2
warm_white: ledc_ww
cold_white: ledc_cw
red: ledc_r
green: ledc_g
blue: ledc_b
cold_white_color_temperature: 5000K
warm_white_color_temperature: 3000K
color_interlock: true
effects:
- lambda:
name: Slow Rainbow
update_interval: 16s
lambda: |-
static int state = 0;
auto call = id(kcl2).turn_on();
call.set_transition_length(15000);
if (state == 0) {
call.set_rgb(1.0, 0.0, 0.0);
} else if (state == 1) {
call.set_rgb(1.0, 0.5, 0.0);
} else if (state == 2) {
call.set_rgb(1.0, 1.0, 0.0);
} else if (state == 3) {
call.set_rgb(0.5, 1.0, 0.0);
} else if (state == 4) {
call.set_rgb(0.0, 1.0, 0.0);
} else if (state == 5) {
call.set_rgb(0.0, 1.0, 0.5);
} else if (state == 6) {
call.set_rgb(0.0, 1.0, 1.0);
} else if (state == 7) {
call.set_rgb(0.0, 0.5, 1.0);
} else if (state == 8) {
call.set_rgb(0.0, 0.0, 1.0);
} else if (state == 9) {
call.set_rgb(0.5, 0.0, 1.0);
} else if (state == 10) {
call.set_rgb(1.0, 0.0, 1.0);
} else if (state == 11) {
call.set_rgb(1.0, 0.0, 0.5);
}
call.perform();
state++;
if (state == 12)
state = 0;
- strobe:
- strobe:
name: Strobe Effect With Custom Values
colors:
- state: true
brightness: 100%
red: 100%
green: 90%
blue: 0%
duration: 500ms
- state: false
duration: 250ms
- state: true
brightness: 100%
red: 0%
green: 100%
blue: 0%
duration: 500ms
- flicker:
- flicker:
name: Flicker Effect With Custom Values
alpha: 95%
intensity: 10.5%
- random:
- random:
name: Random Effect With Custom Values
transition_length: 5s
update_interval: 7s
- pulse:
- pulse:
name: "Fast Pulse"
transition_length: 0.5s
update_interval: 0.5s
- pulse:
name: "Slow Pulse"
# transition_length: 1s # defaults to 1s
update_interval: 2s
Heres the automations yaml;
alias: kitchen leds catch
description: ""
trigger:
- type: motion
platform: device
device_id: 0a0d2e74956722bc0f62949fbab52519
entity_id: binary_sensor.kitchen_pir
domain: binary_sensor
condition: []
action:
- service: scene.create
data:
scene_id: leds_before_motion_1
snapshot_entities: light.kitchen_colour_leds_1
- service: light.turn_on
data:
kelvin: 6500
effect: None
brightness: 255
target:
entity_id: light.kitchen_colour_leds_1
mode: restart
alias: kitchen leds reload
description: ""
trigger:
- type: no_motion
platform: device
device_id: 0a0d2e74956722bc0f62949fbab52519
entity_id: binary_sensor.kitchen_pir
domain: binary_sensor
condition: []
action:
- service: scene.turn_on
data: {}
target:
entity_id: scene.leds_before_motion_1
mode: restart