Hello everyone!
I found more challenging than expected creating an automation for blinking the lights in HA
and I wanted to share my experience (and workarounds).
My goal here is to blink the lights when a call is received on the phone and restore the lights to its previous state.
For this automation we will need the following:
- Yeelight colour bulbs
- Tasker or some other way to link your phone with HA
Define a new input_boolean
as a switch to control our automation:
input_boolean:
call_in_progress:
name: There is a call in progress
icon: mdi:phone
initial: false
Define a custom effect:
yeelight:
custom_effects:
- name: 'Call'
flow_params:
count: 0
transitions:
- RGBTransition: [90, 255, 36, 50, 20]
- RGBTransition: [90, 255, 36, 50, 100]
- RGBTransition: [90, 255, 36, 50, 20]
- RGBTransition: [90, 255, 36, 50, 100]
- SleepTransition: [500]
Create an automation to be triggered when the state of the input_boolean goes to on:
- alias: 'Lights - Call In progress'
trigger:
- entity_id: input_boolean.call_in_progress
platform: state
to: 'on'
action:
- service: scene.create # Needs a scene to restore switch off state
data:
scene_id: before
snapshot_entities:
- light.living_room_lights # Change it according to you config
- service: light.turn_on
entity_id:
- light.living_room_lights
data:
effect: 'Call'
- wait_template: "{{ is_state('input_boolean.call_in_progress', 'off') }}"
continue_on_timeout: 'true'
timeout: 00:00:15
- service: input_boolean.turn_off
entity_id: input_boolean.call_in_progress
- service: light.turn_on # FIX: yeelight doesnt stop effect when scene is applied back
entity_id:
- light.living_room_lights
data:
effect: 'Stop'
- service: scene.turn_on
entity_id: scene.before
Now you will need to link your device to HA, in my Android setup
I use Tasker + AutoNotification plugin (optional to WhatsApp call as well)
There are some good tutorials out there about how to do this #1 #2
Once you have Tasker linked with HA, create a new Event profile Phone Ringing
and
link it to a new Task which will call HA to turn on our call_in_progress input_boolean