Sunrise animation for RGB (yee)light

Because I searched a long time to find something satisfying this is quite a good basis if you want to create a sunrise animation with lights (I used yeelights)

- id: sunrise_config
  alias: "Sunrise when alarm"
  trigger:
    platform: template
    value_template: "{{ 1==1 }}"
  action:
    - service: light.turn_on
      entity_id: light.desk
      data:
        rgb_color: [255, 0, 0]
        brightness_pct: 1
    - delay: 00:03
    - service: light.turn_on
      entity_id: light.desk
      data:
        rgb_color: [255,100,0]
        brightness_pct: 1
        transition: 60
    - delay: 00:02
    - service: light.turn_on
      entity_id: light.desk
      data:
        rgb_color: [255,230,200]
        brightness_pct: 1
        transition: 60
    - delay: 00:03
    - service: light.turn_on
      entity_id: light.desk
      data:
        rgb_color: [255,230,200]
        brightness_pct: 50
        transition: 60
    - delay: 00:01

I use the Flux component.

I’m confused. You have a 60 transition for each action but you execute every next command with a 2-3 seconds delay. Won’t it override the transition?

That’s actually minutes. Because a Yeelight bug you cannot make the transitions very long (I don’t know what is the limit but I picked 60 after some trial and error). After that I wait a few minutes to start the next transition to slow it down a bit. Everything is executed in parallel so it doesn’t override the transition.

Will look into that! Thanks

Maybe also check out this custom component

Hey,

Still relatively new, but could you explain how this is triggered?

The trigger ( {{ 1==1 }} ) doesn’t make much sense to me, but the alias is interesting as I’d like this to automatically trigger when my Android phone alarm is set!

Thanks

Hi I also looked a lot before I could found how to do it. I eventually used this:

{% if strptime(states(''sensor.alarm''), ''%H:%M'').hour -%}{{((60
  * (strptime(states(''sensor.alarm''), ''%H:%M'').hour * 60 + strptime(states(''sensor.alarm''),
  ''%H:%M'').minute-15))|timestamp_custom(''%H:%M'', false))==states(''sensor.time'')}}{%-
  else -%}{{False}}{%- endif %}

You first have to add a sensor time the time is calculated in this particular way because you have to convert it from string to time as explained by pnbrucker. The sensor.Alarm is an sensor which is created by the HTTP endpoint and send from my phone using tasker, autoalarm and Clocktask (all apps from the playstore). There are many tutorial on the internet how to do this.
I set up a task that first gets the alarm time using ‘AutoAlarm’ and then I send the time to Home Assistant using this command:
curl -X POST -H "Authorization: Bearer %HASS_TOKEN" -H "Content-Type: application/json" -d '{"state": "%taskertime", "attributes": {"unit_of_measurement": "HH:MM", "friendly_name": "Alarm"}}' 192.168.1.200:8123/api/states/sensor.alarm

Where you have to have to generate a token (which can be done from the graphical user interface Account > Long Lived Access Token).

And to activate it I have a Profile which states Next alarm changed -> Execute the task described above. This Next alarm changed can be triggered by the ‘ClockTask’ app.

All in all it’s quite a hassle but it works perfectly, and doesn’t mess with your android alarm or anything so you can just set your alarm the way you are used to.

With new HA ( 0.87 ) You could possibly simplify this and declare as custom effect. More details here: https://github.com/home-assistant/home-assistant/pull/20107 . I’ve also wanted to make wake up light, thanks for inspiration.

Awesome news!!! I can’t wait to try this out :grin: