Creating a alarm clock

You are right! This is a neater way to trigger the alarm. Thanks.

Excellent solution. Thanks

Guys. I have improvised the automation to make use of the nested conditions…

- alias: 'Alarm Clock'
  trigger:
    platform: template
    value_template: '{{ now.time().strftime("%-H") == states.input_slider.alarmhour.state and now.time().strftime("%-M") == states.input_slider.alarmminutes.state }}'
  condition:
    condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.alarmstatus
            state: 'on'
          - condition: state
            entity_id: input_boolean.alarmweekday
            state: 'on'
          - condition: time
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
      - condition: and
        conditions:
          - condition: state
            entity_id: input_boolean.alarmstatus
            state: 'on'
          - condition: state
            entity_id: input_boolean.alarmweekday
            state: 'off'
  action:
    service: notify.notify
    data:
      message: 'Good morning. Time to Wake Up!'
      title: ""
6 Likes

So this all looks super cool, but do you think we can take everything here and combine it together? As a noob at this it’s a little hard to follow, but I’m getting there. If we could sum up that would be awesome though. Thanks!

Here is the sample of complete code in my configuration.yaml…

input_slider: 
  alarmhour:
    name: Hour
    icon: mdi:timer
    initial: 9
    min: 0
    max: 23
    step: 1
  alarmminutes:
    name: Minutes
    icon: mdi:timer
    initial: 0
    min: 0
    max: 55
    step: 5

input_boolean: 
  alarmstatus:
    name: Wake Me Up
    initial: off
    icon: mdi:alarm-check
  alarmweekday:
    name: Weekdays Only
    initial: off
    icon: mdi:calendar

sensor: 
  platform: template
  sensors:
    alarm_time:
      friendly_name: 'Time'
      value_template: '{{ states.input_slider.alarmhour.state }}:{% if states.input_slider.alarmminutes.state|length == 1 %}0{% endif %}{{ states.input_slider.alarmminutes.state }}'

group:
  default_view:
    view: yes
    entities:
      - group.alarmclock
  alarmclock:
    name: Wake Me Up
    entities: 
      - sensor.alarm_time
      - input_slider.alarmhour
      - input_slider.alarmminutes
      - input_boolean.alarmstatus
      - input_boolean.alarmweekday

automation
  - alias: 'Wake Me Up'
    trigger:
      platform: template
      value_template: '{{ now.time().strftime("%-H") == states.input_slider.alarmhour.state and now.time().strftime("%-M") == states.input_slider.alarmminutes.state }}'
    condition:
      condition: or
      conditions:
        - condition: and
          conditions:
            - condition: state
              entity_id: input_boolean.alarmstatus
              state: 'on'
            - condition: state
              entity_id: input_boolean.alarmweekday
              state: 'on'
            - condition: time
              weekday:
                - mon
                - tue
                - wed
                - thu
                - fri
        - condition: and
          conditions:
            - condition: state
              entity_id: input_boolean.alarmstatus
              state: 'on'
            - condition: state
              entity_id: input_boolean.alarmweekday
              state: 'off'
    action:
      service: notify.notify
      data:
        message: 'Good morning. Time to Wake Up!'
        title: ""

Which show this in my HASS home screen…

17 Likes

Thanks! Really appreciated. You just have a little mistake in your template sensor: you handled the case where the minutes were 0, and added another 0, but you didn’t handled the case where they were set to 5. A more generic template: {{ states.input_slider.alarmhour.state }}:{% if states.input_slider.alarmminute.state|length == 1%}0{% endif %}{{ states.input_slider.alarmminute.state }}

2 Likes

yes. you are right. thanks!

Fantastic, thanks for the sum up!

I have a question !
When i want to put a transition on my light for the morning like that
- alias: "aurora 07h00" trigger: - platform: time after: "06:50:00" condition: - platform: state entity_id: input_boolean.reveil state: 'on' - platform: state entity_id: input_boolean.lightreveil state: "on" - platform: state entity_id: input_select.choixreveil state: "07:00" action: service: light.turn_on entity_id: light.chambre data: transition: 600

The light turn on but the transition doesn’t happen… the light is on with full brightness… it isn’t very peaceful to wake up…
Have you test that ?

1 Like

I updated my code to replace platform with condition in condition.
I think that my word transition was not good indented, a space was needed the T of transition had to be under the T of data.

I’ll try this tomorrow moring.

Working like a charm for me.

Thanks for sharing!!!

You’re welcome :smile:

This is awesome stuff guys! Thank you. As a noob of course I have at least one question! Would it be possible to add a duration slider? So that you can set how long the even triggers for? Obviously not useful as an alarm with notify, however, I’m thinking this would be amazingly useful as a timer module for a pool pump.
Im also not sure how to change the action to use a rpi_gpio switch… one thing at a time!
Thanks again for sharing!

Continuing the discussion from Creating a alarm clock:

I’ve tested the transition item as well, but unfortunately is not working for me.

Is there any limitation (as in plattforms,etc.) that might be impacting on it?

I’m working with custom Dimmers based on MySensors and I’m not sure if I’m missing anything.

When this triggers, the lights are going 100%, and I’d like to have a more progressive effect.

ideas?

thanks in advance

Hi davedan for me to succes i had to write automation like that

- alias: "aurora 07h55" trigger: - platform: time after: "07:45:00" condition: - condition: state entity_id: input_boolean.reveil state: 'on' - condition: state entity_id: input_boolean.lightreveil state: "on" - condition: state entity_id: input_select.choixreveil state: "07:55" action: service: light.turn_on entity_id: light.chambre data: transition: 600 brightness: 255

In the begining the transition didn’t work now it works fine.
Goos luck to you :slight_smile:

thank you @hokagegano,

quick question: The transition time is in secs? I can’t find the unit in the doc: https://home-assistant.io/components/light/

thanks in advance!

Yes transition is an integer in seconds :smiley:

Hello!
I would also like to have a duration slider and a repeat slider so that the alarm can be triggered every x hrs or mins. I am thinking of using it as a timer for my hydroponic pump. Since the delay feature won’t allow for template values ( e.g. minutes: ‘{{ input_slider.hydroponic_pump.state }}’) I’m finding very difficult to find a way to implement this. Can someone think of a solution?
Thanks!

1 Like

what you need is not an alarm clock function. just create an automation using time trigger. For example…

automation:
  trigger:
    platform: time
    # Matches every 2 hours
    hours: /2
    minutes: 0
    seconds: 0

That is a good way to do it, I suppose it would be possible to use a slider to input the time variables. The alarm clock drew my attention because of the “gui” adjustments.