Wake-up light alarm with sunrise effect

Hi,
I wanted to make this blueprint work with my IKEA Tradfri RGB bulb…
It does work in terms of brightness, yet the colour always stays the same.
I tried to find information on how to make it work but there is nothing.
What could I do?

Thanks!

Hello there,

I absolutely love this blueprint. It is by far one of the most useful things in my smart home.
But there is one thing that bothers me. I do not see a possiblity to limit the sunrise alarm to lets say before 12am. Because sometimes I use the alarmclock of my phone to remind me of something. And then, even when it is a bright sunny day the lights start to turn on. That is a bit anoying.

So it would be great to have a setting or the possibiltiy to check wether the time of the alarm is in the “allowed” sunrise time.

Any help is highly apprechiated.

Thanks in advance!

Till

Hi, really nice blueprint, thanks!

I was wondering if it is possible to add multiple entity check before triggering. I now use a switch on my dashboard to have the sunrise (my alarm) on or off but I would like to additionally check if its a workday so if I set the alarm on for friday but forget to take it off again it is automatically turned off.

I can think of other use cases where multiple checks would be useful. (checking a database, checking if someone is home or not etc). Might be a usefull addition.

I have used this youtube video in combination with this blueprint to make that happen:
link

Looks nice imo :slight_smile:
afbeelding

Thank you for this! It worked great out of the box. I hope it’s a game changer to my morning routine.

With the shortening days in the winter coming, waking up in the dark has me sleeping through 6 alarms. Today I got up with the first one!

Trying to use this blueprint but not able to get my light to turn on.

2021-11-05 05:05:13 WARNING (MainThread) [homeassistant.helpers.template] Template warning: ‘int’ got invalid input ‘None’ when rendering template ‘{{0 < state_attr(light_entity, ‘brightness’) | int < end_brightness | int}}’ but no default was specified. Currently ‘int’ will return ‘0’, however this template will fail to render in Home Assistant core 2022.1

alias: Wake-up light alarm with sunrise effect
description: ''
use_blueprint:
  path: sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
  input:
    light_entity: light.bedroom_bed_light
    manual_time: '05:30:00'
    start_brightness: 123
    end_brightness: 235
    min_mired: 155

looks good, but afew things i would think about is
1, manual alarm time to be an time input entity instead
2, more options for the aditional entities to check
( i want to check that i am home, but i also want to check one or more input booleans, for example i got a input boolean that i check in all my automations, when its off no automation will run. this is basically a switch to make the house “dumb”, incase im away and someone is housesitting they might not want all the automations)

otherwise its great, and you can easly add additional options and checks as post actions.
for example i start playing music in my kitchen, but in some conditions i don’t want that (i have guests at home) so i use an input boolean to turn that feature off ( or if i forgett it also checks for known guests connected to my guest wifi, or if there’s been movement in the guest room in the last x amount of time )

I got the same warning since updating on core version 2021.11 (I think. I didn’t mentioned it myself, my girlfriend told me that it isn’t working anymore for a few days now and I saw the warning in the logs while testing, but I can only see the logs from today). I hope someone can figure out how to solve this problem, because it was a very nice feature before.
Thx a lot

I have updated the blueprint to work around the upcoming breaking changes in the template engine. This should address the template-related warning messages you have been seeing.

1 Like

Getting the following error when I set up the automation:

Stopped because an error was encountered at November 13, 2021, 4:16:06 PM (runtime: 0.02 seconds)

In 'template' condition: TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

Looking at the step details, it appears to get stuck here:

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']}}

I’m not sure how to fix this…a buddy of mine used this blueprint and it just worked so idk why I’m not able to get it working. I saw on Github someone else had a similar issue but there was never a response. Any help/tips appreciated.

I’m using a template sensor for all of this myself.

Tried it last night - based on my Google Nest Mini 2 alarm - and it didn’t work.

The alarm shows as 2021-11-17T11:00:06+00:00. It’s valid, right?

Ok, tested again and seems the problem is that it won’t run the pre-sunrise action of turning on my bedroom switch (to which my wake up lights are connected).

EDIT: I have 3 actions. Could that be it? Does the blueprint only support one?

Ok, tested it and can confirm that it’ll only run the pre-sunrise actions if you only have one. Anymore than that and nothing runs.

Guess I’ll point it to a script.

Hi! Thanks for this really useful blueprint. I’m trying to use it so it automates with my google home alarm. Tried a few different things, but cannot get it to work.

Any ideas?

homeassistant:
  customize: !include customize.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:



# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: time_date
    display_options:
      - 'date'
      - 'date_time_iso'

# Google Home Alarm Sensor

  - platform: template
    sensors:
      google_home_alarm_sensor:
       value_template: '{{ as_timestamp(states("sensor.bedroom_display_alarms"))| timestamp_custom("%A %B %-d, %I:%M %p") }}'

sensor is set as a timestamp via customize.yaml

For me, it helped to add a time_date sensor with the used display options to the configuration:

sensor:
  - platform: time_date
    display_options:
      - 'date'
      - 'date_time_iso'
1 Like

Hey i try to use it too, cause it looks awesome, sadly it’s just not working i have no idee why, maybe somebody could have a look:

Config

id: '1637529339671'
alias: asjnklödsnköjldfs
description: ''
use_blueprint:
  path: Sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
  input:
    light_entity: light.schrank
    sunrise_duration: 5
    manual_time: '22:16:00'

And Trace:

{
  "trace": {
    "last_step": "action/1",
    "run_id": "5ed2dde219ba157c631c1f657f8a649b",
    "state": "running",
    "script_execution": null,
    "timestamp": {
      "start": "2021-11-21T21:16:00.006709+00:00",
      "finish": null
    },
    "domain": "automation",
    "item_id": "1637529339671",
    "trigger": "time pattern",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2021-11-21T21:16:00.007855+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.asjnklodsnkojldfs",
              "state": "on",
              "attributes": {
                "last_triggered": "2021-11-21T21:15:55.330570+00:00",
                "mode": "single",
                "current": 0,
                "id": "1637529339671",
                "friendly_name": "asjnklödsnköjldfs"
              },
              "last_changed": "2021-11-21T21:15:40.225207+00:00",
              "last_updated": "2021-11-21T21:15:55.338753+00:00",
              "context": {
                "id": "20ac517926d158e53ddb7d55766c140a",
                "parent_id": "0b660c1026eddf68ca293de0e8a46b40",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "platform": "time_pattern",
              "now": "2021-11-21T22:16:00.003790+01:00",
              "description": "time pattern"
            },
            "light_entity": "light.schrank",
            "sensor": "none",
            "sunrise_duration": 5,
            "start_brightness": 1,
            "end_brightness": 254,
            "range_brightness": 253,
            "manual_time": "22:16:00",
            "seconds": 300,
            "min_mired": 0,
            "start_mired": null,
            "end_mired": 0,
            "tick_time": 1.1857707509881423,
            "check_entity": "none"
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2021-11-21T21:16:00.019584+00:00",
          "changed_variables": {
            "context": {
              "id": "b5da3c6369a20d540ee438ce9c0b408b",
              "parent_id": null,
              "user_id": null
            }
          },
          "result": {
            "wait": {
              "remaining": null,
              "completed": true
            }
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2021-11-21T21:16:00.019999+00:00",
          "changed_variables": {
            "wait": {
              "remaining": null,
              "completed": true
            }
          },
          "result": {
            "wait": {
              "remaining": null,
              "completed": false
            }
          }
        }
      ]
    },
    "config": {
      "variables": {
        "light_entity": "light.schrank",
        "sensor": "none",
        "sunrise_duration": 5,
        "start_brightness": 1,
        "end_brightness": 254,
        "range_brightness": "{{float(end_brightness)-float(start_brightness)}}",
        "manual_time": "22:16:00",
        "seconds": "{{float(sunrise_duration) * 60}}",
        "min_mired": 0,
        "start_mired": "{{state_attr(light_entity, 'max_mireds')}}",
        "end_mired": "{{[state_attr(light_entity, 'min_mireds')|int(0), min_mired|int(0)]|max}}",
        "tick_time": "{{float(seconds) / float(range_brightness)}}",
        "check_entity": "none"
      },
      "trigger": [
        {
          "platform": "time_pattern",
          "minutes": "*"
        }
      ],
      "condition": [],
      "action": [
        {
          "wait_template": "{{sensor == 'none' or as_timestamp(states(sensor), None) != None}}"
        },
        {
          "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']}}"
        },
        {
          "choose": [],
          "default": []
        },
        {
          "condition": "template",
          "value_template": "{{sensor == 'none' or as_timestamp(states(sensor), None) != None}}"
        },
        {
          "condition": "template",
          "value_template": "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) <= float(seconds) and states(check_entity) in ['unknown', 'on', 'home']}}"
        },
        {
          "choose": [
            {
              "conditions": [
                "{{state_attr(light_entity, 'min_mireds') != None}}"
              ],
              "sequence": [
                {
                  "service": "light.turn_on",
                  "data": {
                    "brightness": "{{start_brightness}}",
                    "color_temp": "{{start_mired}}"
                  },
                  "entity_id": "light.schrank"
                }
              ]
            }
          ],
          "default": [
            {
              "service": "light.turn_on",
              "data": {
                "brightness": "{{start_brightness}}"
              },
              "entity_id": "light.schrank"
            }
          ]
        },
        {
          "repeat": {
            "while": [
              "{{sensor == 'none' or as_timestamp(states(sensor), None) != None}}",
              "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}"
            ],
            "sequence": [
              {
                "delay": "{{tick_time}}"
              },
              {
                "choose": [
                  {
                    "conditions": [
                      "{{0 < state_attr(light_entity, 'brightness') | int(0) < end_brightness | int}}",
                      "{{sensor == 'none' or as_timestamp(states(sensor), None) != None}}",
                      "{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}"
                    ],
                    "sequence": [
                      {
                        "choose": [
                          {
                            "conditions": [
                              "{{state_attr(light_entity, 'min_mireds') != None}}"
                            ],
                            "sequence": [
                              {
                                "service": "light.turn_on",
                                "data": {
                                  "brightness": "{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int(0)}}",
                                  "color_temp": "{{(float(end_mired) + (float(start_mired) - float(end_mired)) * ((as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int(0)}}"
                                },
                                "entity_id": "light.schrank"
                              }
                            ]
                          }
                        ],
                        "default": [
                          {
                            "service": "light.turn_on",
                            "data": {
                              "brightness": "{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now())) / float(seconds))) | int(0)}}"
                            },
                            "entity_id": "light.schrank"
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "choose": [],
          "default": []
        }
      ],
      "mode": "single",
      "max_exceeded": "silent",
      "id": "1637529339671",
      "alias": "asjnklödsnköjldfs",
      "description": ""
    },
    "blueprint_inputs": {
      "id": "1637529339671",
      "alias": "asjnklödsnköjldfs",
      "description": "",
      "use_blueprint": {
        "path": "Sbyx/wake-up-light-alarm-with-sunrise-effect.yaml",
        "input": {
          "light_entity": "light.schrank",
          "sunrise_duration": 5,
          "manual_time": "22:16:00"
        }
      }
    },
    "context": {
      "id": "b5da3c6369a20d540ee438ce9c0b408b",
      "parent_id": null,
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "asjnklödsnköjldfs",
      "message": "has been triggered by time pattern",
      "source": "time pattern",
      "entity_id": "automation.asjnklodsnkojldfs",
      "context_id": "b5da3c6369a20d540ee438ce9c0b408b",
      "when": "2021-11-21T21:16:00.008022+00:00",
      "domain": "automation"
    }
  ]
}

Thanks for any help… i’m just lost…

Oo and i can’t see anythink in the log

Great blueprint, thanks for your work!
Is it possible to use another trigger? I tried to start the whole automation from another automation but without success. It would be nice to trigger the alarm with other enties states.

This is great, thanks OP. I prefer the lights to start fully red at brightess 1, so I bastardized this poor blueprint to work around that (my Hass skills are not great yet :slight_smile: ).

To get the starting state right I just used a pre-sunrise script to set the light to 1% brightness red. I then added an input to specify the temperature of the light in the end state, axed the whole light changing logic, and instead changed that to use the transition attribute in the light.turn_on service. As a bonus I added a post-sunrise script to crank the light to an even higher brightness and temperature since I tend to lay in bed an extra 5 mins anyways.

Since a few others were asking for something similar in the comments earlier, here’s the full automation. Not sure that I have the ability to troubleshoot much, but hopefully this helps steer someone else on the right path.

variables:
  light_entity: light.<entity>
  sensor: sensor.<entity>
  sunrise_duration: 30
  start_brightness: 1
  end_brightness: 126
  range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
  manual_time: '08:00:00'
  seconds: '{{int(float(sunrise_duration) * 60)}}'
  end_temperature: 3000
  tick_time: '{{float(seconds) / float(range_brightness)}}'
  check_entity: person.<entity>
trigger:
  - platform: time_pattern
    minutes: '*'
condition: []
action:
  - wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
  - 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']}}
  - choose: []
    default:
      - service: light.turn_on
        target:
          entity_id: light.<entity>
        data:
          rgb_color:
            - 255
            - 0
            - 0
          brightness: 1
  - condition: template
    value_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
  - condition: template
    value_template: >-
      {{0 < as_timestamp(states(sensor) if sensor != 'none' else
      states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(now()) <=
      float(seconds) and states(check_entity) in ['unknown', 'on', 'home']}}
  - choose:
      - conditions:
          - '{{state_attr(light_entity, ''min_mireds'') != None}}'
        sequence:
          - delay: 5
          - service: light.turn_on
            data:
              brightness: '{{end_brightness}}'
              transition: '{{seconds}}'
              kelvin: '{{end_temperature}}'
            entity_id: light.<entity>
          - delay: '{{seconds}}'
    default:
      - service: light.turn_on
        data:
          brightness: '{{start_brightness}}'
        entity_id: light.<entity>
  - choose: []
    default:
      - service: light.turn_on
        target:
          entity_id: light.<entity>
        data:
          transition: 300
          brightness: 255
          kelvin: 4000
mode: single
max_exceeded: silent
id: '1637718034053'
alias: Wake-up light alarm with sunrise effect
description: ''

Hi,
Great Blueprint!
Is it possible to use an input_number or a sensor as sunrise_duration? I tried it but it didn’t work.