Wake-up light alarm with sunrise effect

Please provide the settings you are using for the blueprint. In the settings menu click on the 3 dots and select Edit as YAML and post the contents.

The blueprint should work with all lights that are at least dimmable.

Do you see any related errors in the log, e.g. regarding templates? Is your Timezone set correctly in the HA General Settings?

alias: Alarm Smorgends Ruben
description: Laat lamp aan bed aangaan
use_blueprint:
path: Sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
input:
max_brightness: 100
light_entity: light.nachtlampje_ruben
timestamp_sensor: sensor.ruben_gsm_volgende_alarm
sunrise_duration: ‘5’
pre_sunrise_actions:
- condition: device
device_id: 1231
domain: device_tracker
entity_id: device_tracker.ruben_gsm
type: is_home
end_brightness: ‘50’
manual_time: ‘09:00:00’

This is my YAML config.
I also add the ‘date_time_iso’ to configuration.yaml
I tried also with other Ikea Bulbs but this is also not working

I would love to use this. But I set my alarm using a google home speaker at bedside rather than my phone. Is there a way to expose your next alarm on Google to this?

Unfortunately not. I used to have a few triggers based on Google Home alarms and timers but Google removed the ability to expose those features a while back. Too bad, it was very useful.

That’s too bad. It would be nice if I could at least set this up manually at a fixed time 4 days a week. I don’t want to wake up early on weekends/days off of work! Is there a way I could set up an persistent android mobile notification with a button or something to toggle this on/off?

@duckflame I don’t see anything obvisouly wrong in your config. Just check please your timezone is correct if you haven’t already and note that while you have set a timestamp_sensor the manual_time is ignored. Also this automation cannot be triggered using the “Trigger” button on the UI it always needs the timer to be set in order to work.

@nima @jazzyisj
Actually there is a way since I am using this every day but it takes some effort and Linux skills to set this up once (since it is not very well documented) and needs some kind of cronjob to work so with just a HassOS installation it will not work. There is some outline on how to do this here:

This will basically retrieve API tokens for talking to your local Google home from time to time and writes them into a helper variable in HA.
In HA itself you can then define a command-line sensor to poll the next alarm time from the Nest Mini or similar.

sensor:
  - platform: command_line
    command: 'curl --silent --insecure --header "cast-local-authorization-token: {{ state_attr(''input_text.google_tokens'', ''token_Mini im Schlafzimmer'') }}" https://192.168.x.y:8443/setup/assistant/alarms'
    name: Schlafzimmer Wecker
    value_template: >
      {% set alarms = value_json.alarm|sort(attribute='fire_time') %}
      {% if alarms[0] is defined %}
        {{ (alarms[0].fire_time / 1000) | timestamp_local }}
      {% else %}
        Unknown
      {% endif %}
2 Likes

I really like your blueprint. The only thing I’m missing is to set target color temperature for light, because now the light is blue after automation is done. I think I am not the only one who would love to see this improvement.
Thank you

3 Likes

First of all, thank you so much for this Blueprint. As a new user to HA, this really helped achieve what I wanted with much ease. I don’t have it trigged via an alarm, just a set time to reach desired max brightness level.

Could you help me clarify one thing though, regarding your comment of this:
{{ 1 <= now().isoweekday() <= 5 }}

I would like to set it to only run between Monday and Friday [work days for me].
Have I done this correctly? Screenshot below

Latest update now brings a minimum brightness and minimum color temperature input.
I have noticed that with my Hue Go since switching from percentage to absolute brightness values it doesn’t react to a brightness of 1 and turns the light on with last known brightness instead (which could be full) which is suboptimal. Also as someone liked to see minimum color temperature you can set this now too (in mired). This setting is 0 by default and practically ignored if you set anything lower than what your light advertises as minimum supported value.

@jellytotz yeah I would give it a try like this.

1 Like

It just don’t work with philips hue go

And how I can solve this? Ive try this blueprint with 2 hue go and it just dont work

I have added a troubleshooting section to the first post. Here are the contents:

1 Like

Is it possible to add a home/away option to his automation? So when you’re not at home (sleeping in a hotel or something like that) it doesn’t trigger this automation.

You could add an automation that turns this one off/on based on that trigger.

See the presence part of the first post.

Defining additional conditions (e.g. weekday, presence, workday)

You can define additional conditions for your light alarm by using a ‘wait’ action with a template in the custom pre-sunrise actions, some examples:

  • Day of week, e.g. monday to friday: {{ 1 <= now().isoweekday() <= 5 }}
  • Presence: {{ states('person.admin') == 'home' }}
  • Sensor (e.g. workday): {{ states('binary_sensor.workday_sensor') == 'on' }}

still not working with philips hue go, I already manually puts a time

Like this?

Yes, that of course requires person.admin to be tracked by your phone for instance.

1 Like

Yeah, I understand. Thanks for the fast reply.

The most recent version of this blueprint gives me the following issue:

Logger: homeassistant.components.automation.wake_up_light_alarm_with_sunrise_effect
Source: components/automation/__init__.py:373
Integration: Automation ([documentation](https://www.home-assistant.io/integrations/automation), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+automation%22))
First occurred: 4:54:00 PM (1 occurrences)
Last logged: 4:54:00 PM

Error rendering variables: TypeError: '>' not supported between instances of 'int' and 'NoneType'

edit

I found a reason for the NoneType, but not yet the solution, this was in the next log-entry:

Logger: homeassistant.helpers.event
Source: helpers/template.py:355
First occurred: 8:39:59 AM (3 occurrences)
Last logged: 4:40:48 PM

    Error while processing template: {{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds)}}
    Error while processing template: Template("{{0 < as_timestamp(states(sensor) if sensor != 'none' else states('sensor.date') ~ ' ' ~ manual_time) - as_timestamp(states('sensor.date_time_iso')) < float(seconds)}}")

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 353, in async_render
    render_result = compiled.render(kwargs)
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/usr/local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 885, in _render_template_if_ready
    result: Union[str, TemplateError] = info.result()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 230, in result
    raise self.exception
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 462, in async_render_to_info
    render_info._result = self.async_render(variables, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 355, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'

I have this already in the configuration.yaml:

image

And this is the yaml-code of the automation that I have created:

alias: Wake-up light alarm with sunrise effect
description: ''
use_blueprint:
  path: Sbyx/wake-up-light-alarm-with-sunrise-effect.yaml
  input:
    min_mired: '0'
    light_entity: light.dining_room_light_3_level_on_off
    start_brightness: '10'
    end_brightness: '255'
    manual_time: '18:05:00'
    pre_sunrise_actions:
      - condition: zone
        entity_id: person.marcel
        zone: zone.home
    sunrise_duration: '25'
1 Like