A good working sunrise alarm clock

I trying some different automations and blueprints for a simulated sunrise alarm clock, but havent found anything that’s working (perhaps iam doing things wrong as iam a noob)

Sinds iam using a iPhone I cannot use the next_alarm sensor.
I wanne let HA do everything.
So I put in an time with an helper and have several conditions like workday, bed sensors.
But I have no idea how to simulate sunrise with my hue lights, fade in music will be the next step but first the lights.

Does anybody has something like that running, as my skills are at this point only copy/paste.

Hi
I problably know less about home assistant than you but I just read about scenes and transitions.

I would probably first try to define start and end of the wake up sequence as two scenes and the let home assistant do a transition between scene 1 and scene 2.

Best Regards
Zebi

If I were you, I’d try the blueprint from the thread you posted a few days ago. It is very sophisticated and does exactly what you want. When you got it running, experiment a little with it, as it should offer you all things you want, customization included.

But nonetheless I can see the point where people want to do it “on their own”, so use the blueprint as a template and build an automation that does the “same”.

If you take a look at that blueprint, look at the Gist-page, starting with line 108 it is an “automation”, like any other:

The stuff before is setting up helpers and variables. So you have a trigger, condition and action. All these things are needed for your automation, so you have to find them yourself (the entity_ids).

hai Zebi,

iam still learning about home automation and home assistant as there are so much possibility’s.
That is a great suggestion,i will look in to the scene and transition.

Yes this blue print is not very stable as its won’t activate every morning.
I tried it in the past to change the blueprint for my situation but never got it up and running.

thnx for your suggestion, i will start to change as you suggested downwards from line 108,i will give it another try :slight_smile:

Just start with it, and if you run into problems, the forum is here for you! :wink:

If you can’t get it to work, post what you have and where you’re stuck. :slight_smile: I know, that does sound a little rude, if you ask a question and the most responses are directing you to something else. The idea behind that is, we don’t know what you want, but if you post at least some small parts of the code, it is much easier to see where you want to go with it.

So just take it as a motivation, I def. know people here in this very forum are always willing to help, but most of them (us) aren’t willing to start with “nothing”, but with “something” they can change and explain! :slight_smile:

It’s just the difference between helping (change or explain) or doing all the setup work for someone else. :slight_smile: You get where I’m going with this. :slight_smile:

We’ll see you with some code in the next days, right? :wink: :slight_smile:

Patrick,

Thank you for the straight forward answer, i’am form The Netherlands and we like to be straight forward :slight_smile:

The community is the reason I toke the dive in to home assistant, I begun my smart home with Fibaro hc3 but pushed it aside.

i have so much to learn as I don’t understand variables and templating jet.
your stance about explaining (learning) I can really can get behind.

As time is at the moment limited I played around a little bit but as I said its a lot to
digest.
To start with the variables, do I leave the !input and then I put my entity id behind it? otherwise I do’t understand where the automation knows with entity it has to use.

I changed some things but get the following error:
Message malformed: required key not provided @ data[‘trigger’]

don’t judge my on the rocky mistakes but here is what I tried in 30 min ( I know have to spend more time with home assistant.

blueprint:
  name: Wake-up light alarm with sunrise effect
  description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
  domain: automation
  input:
    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:
        entity:
          domain: light
    timestamp_sensor:
      name: Alarm timestamp sensor
      description: 'Sensor with timestamp of next alarm with device_class: timestamp
        (set to ''none'' for manual alarm time)'
      default: none
      selector:
        entity:
          device_class: timestamp
    manual_time:
      name: Manual alarm time
      description: Time to trigger alarm every day if timestamp sensor is not set.
        Settings at or shortly after midnight will not work as expected!
      default: '7:00:00'
      selector:
        time: {}
    check_entity:
      name: Additional entity to check before sunrise is triggered
      description: If set, checks if entity is 'on' or 'home' before triggering. Use
        e.g. a (workday) sensor, device_tracker or person entity.
      default: none
      selector:
        entity: {}
    sunrise_duration:
      name: Sunrise duration
      description: The sunrise will start the configured number of minutes before
        the timestamp.
      default: 25
      selector:
        number:
          min: 5.0
          max: 60.0
          step: 5.0
          unit_of_measurement: min
          mode: slider
    start_brightness:
      name: Minimum brightness
      description: The brightness to start with. Some lights ignore very low values
        and may turn on with full brightness instead!
      default: 1
      selector:
        number:
          min: 1.0
          max: 255.0
          step: 1.0
          mode: slider
    end_brightness:
      name: Maximum brightness
      description: The brightness will be transitioned from the minimum to the configured
        value.
      default: 120.0
      selector:
        number:
          min: 5.0
          max: 255.0
          step: 1.0
          mode: slider
    min_mired:
      name: Minimum color temperature
      description: 'The minimum color temperature to use. (0: lowest supported)'
      default: 0
      selector:
        number:
          min: 0.0
          max: 500.0
          step: 5.0
          mode: slider
          unit_of_measurement: mired
    pre_sunrise_actions:
      name: Pre-sunrise actions
      description: Optional actions to run before sunrise starts.
      default: []
      selector:
        action: {}
    post_sunrise_actions:
      name: Post-sunrise actions
      description: Optional actions to run after sunrise ends (around the alarm time).
      default: []
      selector:
        action: {}
  source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
variables:
  light_entity: !input 'light_slaapkamer_verlichting'
  sensor: !input 'input_datetime.tijd_om_op_te_staan'
  sunrise_duration: !input 'sunrise_duration'
  start_brightness: !input 'start_brightness'
  end_brightness: !input 'end_brightness'
  range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
  manual_time: !input 'manual_time'
  seconds: '{{float(sunrise_duration) * 60}}'
  min_mired: !input 'min_mired'
  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: !input 
  - 'binary_sensor.edwin_in_bed'
  - 'binary_sensor.gast_in_bed'
  - 'binary_sensor.werkdagen
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: !input 'pre_sunrise_actions'
- 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: !input 'light_entity'
  default:
  - service: light.turn_on
    data:
      brightness: '{{start_brightness}}'
    entity_id: !input 'light_entity'
- 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: !input 'light_entity'
          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: !input 'light_entity'
- choose: []
  default: !input 'post_sunrise_actions'
mode: single
max_exceeded: silent