Wake-up light alarm with sunrise effect

Thank you for the nice blueprint!

I wanted to trigger the wake up based on a schedule. For now I dont need any fancy UI.

What I did is make use of the Schedule helper integration:

This helper has an attribute next_event which can be used to trigger the wake up automation. However, next_event is an attribute and not of device_class: timestamp. With a template sensor you can convert the timestamp:

template:
  - sensor:
    - unique_id: bedroom_alarm_schedule_next_event
      name: Bedroom alarm schedule next event
      device_class: timestamp
      state: "{{ state_attr('schedule.bedroom_alarm', 'next_event') }}"

Now this template sensor can be used for the input Alarm timestamp sensor.

1 Like

Is there any way to adjust the color temperature to the current sun’s temperature for my location?

1 Like

I just forked the original and did this modification. You should be able to import this version from:

I have also strange problem with Ikea gateway and bulbs. This blueprint turns light on and then immediately off. So if automation based on this runs, end result is light turning off even if light is on before.

And for some reason it also turns light off if I try to start the light with automation bit after the wake-up automation has started.

History from the light:
07.05.00 - Turned on (wake up light automation)
07.05.00 - Turned off (wake up light automation)
07.05.10 - Turned on (automation to turn on the bulb after wake up light is running)
07.05.12 - Turned off (wake up light automation)

Edit: and I’ve searched the code and there should be only turn on -stuff in there so this is pretty mysterious…

I’ll reply to myself. It seems to be the blueprint sending mireds to the light that causes Ikea lamp to turn off. Any color_temp below 2200 will shut the lamp down.

I’ll try to modify updated version that fixes this one for IKEA lights today, no promises etc. Will edit this post if I succeed.

Hello Timo,

Thank you for the reply.
I was middeling a bit with this code already but I was setting up a new server so did’t figure it out yet.
I tried the code you posted earlier but I still cannot get it to work.
I saw that you where stil editing the code.

When I copy past the code I get Message malformed: required key not provided @ data[‘action’].

i will look into I a bit more (iam still a newbie when it comes to coding), maybe you can point me in the right direction :slight_smile:

Sorry about that, I am currently trying to figure out also fix for Ikea lights and this is why my gist is currently not functional. Running tests currently and I can let you know when I get it at least somewhat working.

Or you can start by creating a github account if you don’t already have one, fork the original gist and edit your own version in browser and use your own version of the blueprint :slight_smile:

I think I got my version working and sending Kelvins instead of mireds. But no luck, still same behaviour. Needs further investigation at some point.

Something that caught my eye, translated so it will not be fully accurate in english:
Turned off by automation “Wake-up light alarm with sunrise effect” executed because of time pattern

Sorry, you should not use my gist for time being, it will not help and might cause further issues.

This is bit embarassing, but I found something potentially useful when staring again the code:

description: ‘The brightness to start with. Some lights ignore very low values
and may turn on with full brightness instead!’

But actually this was the thing causing issues with light not turning on at all. So the description should be “may turn on with full brightness or turn on and immediately off again” or something similar.

Changed settings to 3 or similar value and now it works! Please forget my gist I linked previously because that is in fully broken state and completely useless.

I can happily recommend the Shelly Duo bulbs.
I have several myself and they work great from 1-100% brightness.

Does this blueprint take into consideration the sunrise time? I would like the lamp not be lit if the alarm time is after the sunrise.

Hmm. It will not work for me. The entity isn’t available in HA. Any idea what it can be?

“input_datetime.weckzeit” is a Helper (input_datetime.set_datetime)

template:
  - sensor:
    - name: "Wecker Zeit"
      unique_id: 'wecker_zeit'
      device_class: timestamp
      state: "{{ today_at(states('input_datetime.weckzeit')) }}"

You don’t need quotes for unique_id. This config works for me.

template:
  - sensor:
      - name: wake-up-workday
        unique_id: wake-up-workday
        device_class: timestamp
        state: "{{ today_at(states('input_datetime.wake_up_clock_workday')) }}"
      - name: wake-up-sat
        unique_id: wake-up-sat
        device_class: timestamp
        state: "{{ today_at(states('input_datetime.wake_up_clock_sat')) }}"
      - name: wake-up-sun
        unique_id: wake-up-sun
        device_class: timestamp
        state: "{{ today_at(states('input_datetime.wake_up_clock_sun')) }}"

And in your dashboard, you add a card for your helper, not sensor. In your case input_datetime.weckzeit.

It will not work… i created the Helper “input_datetime.weckzeit” and the Template-Sensor: “set-wake-up-time”.
The Template-Sensor always says “unavailable”… i tried exactly your code.

Which of the entitys do you use in the Wake-Up-Light-Automation?
Could you show how it lookslike in your Dashboard?

template:
  - sensor:
      - name: set-wake-up-time
        unique_id: set-wake-up-time
        device_class: timestamp
        state: "{{ today_at(states('input_datetime.weckzeit')) }}"

I have this card on my dashboard for control of the wake-up lights:

type: entities
entities:
  - entity: input_boolean.wake_up_workday_enabled
  - entity: input_datetime.wake_up_clock_workday
  - entity: input_boolean.wake_up_sat_enabled
  - entity: input_datetime.wake_up_clock_sat
  - entity: input_boolean.wake_up_sun_enabled
  - entity: input_datetime.wake_up_clock_sun

image
So I’m not using the Template-sensor on the dashboard but the helpers directly. I have also modified the blueprint a bit. I have added a new parameter:

  enabled:
   name: Boolean for controlling the sunrise
      description: If set, checks if entity is 'on' before triggering. Use a boolean.
      default: none
      selector:
        entity:
          multiple: false

And modified the second wait-template:

- wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) <= float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home''] and states(enabled) in [''unknown'', ''on'']}}'
3 Likes

Ok now it works for me. My mistake was that I used an input_datetime with date AND time and not just a Time-Helper. But the problem is now that the sensor will not update the Date until I restart the server…

Hi! I have configured the helpers but the automation is not doing anything. Also nothing in the main log of HA. How could I troubleshoot this?

1 Like

Hi, I have been using this for 1+ years now, and the concept is great.

But… during the last few months the automation is sometimes not triggered. I had switched to a datetime helper to ease my alarm configuration, and I do not know if that is the cause.
E.g.: I had the automation set to 6h45, it worked. Then changed it to 7h20 last couple of nights, and it did not run. wake up duration is always set to 20 minutes.

I will probably try to go back to manual time, but if it persists I believe I will (sadly) stop using it.

Any ideas?

Same for me. Manual time works but not with the helper. Sad…

I am using this for some time now, but suddenly this morning it stopped working. I didn’t change anything to the automation. In the trace it says: Stopped because only a single execution is allowed at 16 december 2022 om 09:39:00 (runtime: 0.00 seconds).
I restarted HA and tried again several time but no change