Wake-up light alarm with sunrise effect

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

You could also try it like this:

1 Like

This blueprint is excellent and working well for me with version 2021-01-01. So thank you very much for this!

However, I’m having a hard time getting my input.datetime helper to be recognized as a timestamp sensor. I’m using it for other morning automations, and it would be helpful if I could use it here as well. I’m fairly new to Home Assistant and there’s still a lot I don’t understand. From what I’ve gathered, I need to make a sensor template. Is that right? If so, where and how do I make it?

Does your helper have both date and time? If so you can manually input it in the timestamp sensor field and it will work. If it has only time you would need to make a template sensor with something like:
{{states('sensor.date')~' '~states('input_datetime.FOOBAR')}}
and of course sensor.date needs to be enabled.

3 Likes

Right on. I didn’t realize I could manually enter the input. Thank you for your quick response. My helper does currently have both date and time, so that was an easy fix for me haha. I’m planning on eventually having it auto-set with a bed occupancy sensor, but that’s awhile away and that will give me time to learn more about template sensors (still very confusing for me!)

Thanks so much!

1 Like

I had a issue today with this blueprint.

This morning I snoozed my alarm on my phone (10 min) and the automation turned to 10 min later (7:10), but it din’t trigger the lights of course, because I have set the sunrise duritation for 30 minutes.

Ok no problem you think. But then the sensor of next wake up time kept stuck on that time and date.

This also kept triggering the automation I think, and always disabled my adaptive lighting sleep mode this evening (I guess). As soon as I disabled the pre-sunrise condition to turn the adaptive lighting sleep mode. It din’t turn of the adaptive lighting sleep mode.
And as soon i add it to the automation, adaptive lighting sleep mode is atomatecly disabled.

Can you take a look how this is possible, and if this is fixable? If you need my assistance, let me know.

Edit: I needed to restart my phone to change the next alarm time in HA for next morning. It kept stuck at 7:10 this morning that had passed.

I tested some more, and even after restarting ha, disabling this automation for a while and enabling it afterwards. It keeps disabling the adaptive lighting. Even when the next alarm timer is correct now.

first of all: very nice approach!

This i my first post here so please have mercy with me :wink:

I would have rather sophisticated idea: currently I am doing this via a script manually but like the idea of merging this into a blueprint and making this much more intelligent (instead of hard coded) so the approach ist as follows:

setup: I am having lights at floor level (e.g. under the bed), at “normal” level (e.g. in the cupboard) and at ceiling level

process: I start with the floor level lights with brightness 1 and transition from [139,0,0] (dark red) to [255,0,0], then to [255,255,0], then to 255,255,240. then I raise the brightness to 255
then I add the normal level lights also in white and brightness 1 and transition with them also to 255
then I do the same for the ceiling lights

I hope it is somewhat clear :slight_smile:

since this is a more special case I understand if you do not want to include something like this but maybe this is interesting for more of us :slight_smile:

in general my understand would be to add more light entities (floor/middle/ceiling) and then to add more repeat cycles at the end of the script part in this blueprint. am I correct?

Hi there. Overall a very good sunrise automation and I think it deserves the attention and love it gets in the blueprint exchange.

I have one question though: Why you dont use a target as a selector for the light entity? Sorry if I ask this question twice, I shortly searched the comments and didnt find a coversation about that. It has the advantage that you can easly add a single light entity or device or directly a area where it picks all the light entitys from which you can still filter (see the docs about selectors).
I find this a good solution, because for the most the need for creating light groups or something similiar isnt needed cause they can select the area in the blueprint (usually the bedroom) and its grapping automatically all your lights filtered by your criterea of the selector. The most didnt need more variety than device, entity and areas i think and a target selectors covers them all the at the same time

Already tried it out locally and it looks like this

    light_entity:
      name: Wake-up light entity
      description:
        The light to control. Turning it off during the sunrise will keep
        it off. Color temperature range is auto-detected.
      selector:
        target:
          entity:
            domain: light

and looks like this in the UI:

I guess in principle target could be used but there are some template-functions e.g. detection of color temperature range and checking if lights have been turned off that don’t translate directly to target usage and would need some special logic if multiple lights were involved.

Hi! I’m also getting the type error. Is there a GitHub repo where I can contribute, or is the Gist the only thing we’ve got?

home-assistant   | 2021-01-08 20:11:46 ERROR (MainThread) [homeassistant.components.automation.wake_up_light_alarm_with_sunrise_effect] Error rendering variables: TypeError: '>' not supported between instances of 'int' and 'NoneType'

I think the culprit was the | max statement. I added another check there.

Yeah now I see it. Would be hard to implement it because you cant create light groups (group.set isnt working cause it doesnt work with your templates) in automations and you cant convert areas to groups or get the entities of groups to set them in a light group. So target will not work, not with the toosl I know in HA.

Can a condition be set that only allows the automation when the input bolean is switched on?

A easy solution without modifying the blueprint could be to make a automation and call the service automation.toggle / .turn_on/ .turn_off when the state of the input_boolean changes.

What is the usecase for this boolean so it needs to be implemented? Of course its totally up to sbyx if he wants to implement this, but I dont know the usecase for the most people, cause once a alarm is set, I think the most want to be wake up with this automation :smile:

1 Like

Many thanks.

This allows one or the other person in the house to create their own automations directly via Apple Home for certain days so when the input bolean (switch in home) is switched on (which in turn switches on the sensor).

I found a dirty solution:

  - platform: template
    sensors:
      wakeup:
        friendly_name: "Wakeup"
        value_template: >
          {{ 'on' if is_state('input_boolean.wakeup', 'on')
             else 'off' }}
        icon_template: >
          {% if is_state('input_boolean.wakeup', 'on') %}
            mdi:alarm
          {% else %}
            mdi:alarm-off
          {% endif %}

Just for your information: I found a workaround with defining a refrence entity so it works with a target (still my personal prototype though). I Just use the entity with the lowest range of color temperature and everything will work. For me personally its better cause I can create evrything right out of the UI and dont have to mess up my yaml config with light_groups. Of course it’s up to you which way you prefer, I just wanted to give some inspiration. You just said that it would be technical difficoult, not which way you prefer more :smile:

1 Like

@Sbyx I just wanted to create something similar on my own. Guess you saved me a lot of time :smiley:

Thanks for this!

1 Like

I updated the blueprint and now added an additional entity input that can be used for a sensor / peron / device_tracker etc. to be checked before the sunrise is triggered. The entity needs to be either ‘on’ or ‘home’ (or not exist / ‘unknown’) otherwise the sunrise is not triggered.

2 Likes