Creating a alarm clock

This may or may not be in-depth enough (and I haven’t read the whole thread) - but quick post in case someone finds it helpful - and i can add more detail (if anyone wants)

“Alexa, Set alarm for 6:30am”
I use IFTTT to grab the alarm trigger and send to HA to start gradual lighting sequence (there is minimal IFTTT delay in this instance, but it also maybe possible to use Node-Red-alexa-local to grab the same result.
“Alexa, snooze alarm” or “Alexa, cancel alarm” are the standard OOB responses (however lighting sequence continues)
so I created a custom routine “Alexa, stop the alarm for 15 minutes”
which using Node-Red turns the lights off and waits for the alarm to go off again.

Works for me as i can set the time verbally, and to whatever time I need based on my schedule the next day :slight_smile: I also have an echo spot in the Bedroom, but a dot will work just as well.

1 Like

Do you think I could add voice support easily to this?:
Universal Persistent Timer
It can add a timer to anything including multiple scripts, lights etc. with separate start and stop actions, and will resume in the event of downtime and requires no programming skills once installed. All lights, switches etc can be accessed from auto populated lists; and you can specify days of the week, repetitions, intervals, and much more. Timers can be paused, backed up and give activation notifications etc.
https://youtu.be/rUeTIU1uAP0

So, because my job isn’t a 9-5 M-F one, I’ve created a variation on this alarm clock that runs my “wake up” script and let’s me choose specific days for it to run - for instance, I may have an 8am shift on Monday and Wednesday that I need it for.

(I haven’t read the whole 3 years of posts on this topic, so I hope I’m not duplicating anything here, but if anyone else needs something similar here it is.)

I’ve added input_booleans for each day of the week, and a sensor that will list which days are “on” in the “minimized” card.

Sensors (config.yaml):

  # Wake 1 Sensors
  - platform: template
    sensors:
      wake_hour_1:
        friendly_name: 'Wake Hour 1'
        value_template: '{{ states("input_number.wakehour_1") | round(0) }}'
      wake_minutes_1:
        friendly_name: 'Wake Minutes 1'
        value_template: '{{ states("input_number.wakeminutes_1") | round(0) }}'
      wake_time_1:
        friendly_name: 'Wake Time 1'
        value_template: '{% if states("sensor.wake_hour_1")|length == 1 %}0{% endif %}{{ states("sensor.wake_hour_1") }}:{% if states("sensor.wake_minutes_1")|length == 1 %}0{% endif %}{{ states("sensor.wake_minutes_1") }}'
      wake_time_days_1:
        friendly_name: 'Days'
        value_template: '{% if states.input_boolean.wakeweekday_sun_1.state == "on" %}Sun {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_mon_1.state == "on" %}Mon {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_tue_1.state == "on" %}Tue {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_wed_1.state == "on" %}Wed {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_thu_1.state == "on" %}Thu {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_fri_1.state == "on" %}Fri {% else %} {% endif %}
                         {% if states.input_boolean.wakeweekday_sat_1.state == "on" %}Sat {% else %} {% endif %}'

And the code for the alarm (automations.yaml):

- id: '1560900229648'
  alias: Wake 1
  trigger:
    platform: template
    value_template: '{{ states.sensor.time.state == states.sensor.wake_time_1.state
      }}'
  condition:
    condition: or
    conditions:
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_sun_1
        state: 'on'
      - condition: time
        weekday: sun
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_mon_1
        state: 'on'
      - condition: time
        weekday: mon
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_tue_1
        state: 'on'
      - condition: time
        weekday: tue
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_wed_1
        state: 'on'
      - condition: time
        weekday: wed
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_thu_1
        state: 'on'
      - condition: time
        weekday: thu
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_fri_1
        state: 'on'
      - condition: time
        weekday: fri
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_sat_1
        state: 'on'
      - condition: time
        weekday: sat
  action:
  - service: script.1560494508008

I have a “wake_1” group defined, so I can get this:

And when I put it on an entity card with the sensors I get this, for an at-a-glance summary of what alarms I have set (I have multiple copies for other days with different wake up times):
WakeTimerEntityCard

I hope this helps anyone who needs it!

8 Likes

dose any one using google hub as the “clock” and this code, thinking the new cast <3

This helped tremendously, thank you so much!
One thing I struggled to figure out here was the inputs. I ended up figuring it out.

configuration.yaml

input_boolean:
  wakestatus_1:
    name: Alarm 1
    icon: mdi:alarm
  wakeweekday_sun_1:
    name: Sunday
    icon: mdi:calendar
  wakeweekday_mon_1:
    name: Monday        
    icon: mdi:calendar
  wakeweekday_tue_1:
    name: Tuesday        
    icon: mdi:calendar
  wakeweekday_wed_1:
    name: Wednesday       
    icon: mdi:calendar
  wakeweekday_thu_1:
    name: Thursday       
    icon: mdi:calendar
  wakeweekday_fri_1:
    name: Friday        
    icon: mdi:calendar
  wakeweekday_sat_1:
    name: Saturday        
    icon: mdi:calendar

input_number:
  wakehour_1:
    name: Hour
    min: 00
    max: 23
    step: 1
    icon: mdi:alarm
  wakeminutes_1:
    name: Minutes
    min: 00
    max: 59
    step: 1
    icon: mdi:alarm

Now I just need to get these inputs to keep their states on reboots, and learn grouping :smiley:
Duh! Thanks @sparkydave

To get them to keep their states on reboot you need to remove ’initial: off' as that is resetting the values to off at boot

1 Like

I think it’s not the correct topic, but beside the alarm I’m trying to set some standard variabel times based on sunset. For example I want

  • Sunset minus 1 hour / 30 minutes as datetime
  • Sunrise plus 1 hour

However I can’t figure out how to accomplish this. Anyone an idea?

You could create a new automation which puts your desired sunset offsets into the input_datetime value for the alarm when selected from an input_select

Good afternoon,

I am almost a year around in Home Assistan and now i am trying this to work but i cant get it working. I think the problem is that for some reason it doesn’t get inside the activation of the time.
if i execute the automation it does the action that i have program it to do.

my code is

#Inside automations

#Alarm clock

- id: '1560900229648'
  alias: Wake 1
  trigger:
    platform: template
    value_template: '{{ states.sensor.time.state == states.sensor.wake_time_1.state
      }}'
  condition:
    condition: or
    conditions:
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_sun_1
        state: 'on'
      - condition: time
        weekday: sun
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_mon_1
        state: 'on'
      - condition: time
        weekday: mon
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_tue_1
        state: 'on'
      - condition: time
        weekday: tue
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_wed_1
        state: 'on'
      - condition: time
        weekday: wed
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_thu_1
        state: 'on'
      - condition: time
        weekday: thu
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_fri_1
        state: 'on'
      - condition: time
        weekday: fri
    - condition: and
      conditions:
      - condition: state
        entity_id: input_boolean.wakestatus_1
        state: 'on'
      - condition: state
        entity_id: input_boolean.wakeweekday_sat_1
        state: 'on'
      - condition: time
        weekday: sat
  action:
  - data:
      entity_id: switch.office_1
    service: switch.turn_on

#Inside Sensor

# Wake 1 Sensors
- platform: template
  sensors:
    wake_hour_1:
      friendly_name: 'Wake Hour 1'
      value_template: '{{ states("input_number.wakehour_1") | round(0) }}'
    wake_minutes_1:
      friendly_name: 'Wake Minutes 1'
      value_template: '{{ states("input_number.wakeminutes_1") | round(0) }}'
    wake_time_1:
      friendly_name: 'Wake Time 1'
      value_template: '{% if states("sensor.wake_hour_1")|length == 1 %}0{% endif %}{{ states("sensor.wake_hour_1") }}:{% if states("sensor.wake_minutes_1")|length == 1 %}0{% endif %}{{ states("sensor.wake_minutes_1") }}'
    wake_time_days_1:
      friendly_name: 'Days'
      value_template: '{% if states.input_boolean.wakeweekday_sun_1.state == "on" %}Sun {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_mon_1.state == "on" %}Mon {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_tue_1.state == "on" %}Tue {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_wed_1.state == "on" %}Wed {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_thu_1.state == "on" %}Thu {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_fri_1.state == "on" %}Fri {% else %} {% endif %}
                        {% if states.input_boolean.wakeweekday_sat_1.state == "on" %}Sat {% else %} {% endif %}'      

#inside config.yaml

input_boolean:
  wakestatus_1:
    name: Alarm 1
    icon: mdi:alarm
  wakeweekday_sun_1:
    name: Sunday
    icon: mdi:calendar
  wakeweekday_mon_1:
    name: Monday        
    icon: mdi:calendar
  wakeweekday_tue_1:
    name: Tuesday        
    icon: mdi:calendar
  wakeweekday_wed_1:
    name: Wednesday       
    icon: mdi:calendar
  wakeweekday_thu_1:
    name: Thursday       
    icon: mdi:calendar
  wakeweekday_fri_1:
    name: Friday        
    icon: mdi:calendar
  wakeweekday_sat_1:
    name: Saturday        
    icon: mdi:calendar

input_number:
  wakehour_1:
    name: Hour
    min: 00
    max: 23
    step: 1
    icon: mdi:alarm
  wakeminutes_1:
    name: Minutes
    min: 00
    max: 59
    step: 1
     




Only the groups i havent get to work

i was trying this in groups.yaml

wake_1:
  name: wake 1
  entities:
    - input_boolean.wakestatus_1
    - wake_time_1
    - wakehour_1
    - wakeminutes_1
    - wakeweekday_sun_1
    - wakeweekday_mon_1
    - wakeweekday_tue_1
    - wakeweekday_wed_1
    - wakeweekday_thu_1
    - wakeweekday_fri_1
    - wakeweekday_sat_1

and i get this in validation

validation

i have been tryin this for almost a week with not any luck :cry: :cold_sweat:

Thanks in advance for your help

It’s because you don’t have the domain in front of most entities in your group, only the first one. Each entity need to be in the format ‘domain.name’

Omg so silly. But still automation doesn’t work.

I’ve got mine working this way; maybe that could help you

group:
  wake_up_lights:
    name: Wake Up Lights
    entities:
      - input_boolean.wakeup
      - sensor.time
      - sensor.wakeup_alarm_time
      - input_number.slider_wakeup_hour
      - input_number.slider_wakeup_minutes
      - input_boolean.wakeup_monday
      - input_boolean.wakeup_tuesday
      - input_boolean.wakeup_wednesday
      - input_boolean.wakeup_thursday
      - input_boolean.wakeup_friday
      - input_boolean.wakeup_saturday
      - input_boolean.wakeup_sunday
      - input_boolean.wakeup_weekend
    
input_number:
  slider_wakeup_hour:
    name: Hours
    icon: mdi:clock-in
    initial: 5
    min: 0
    max: 23
    step: 1
  slider_wakeup_minutes:
    name: Minutes
    icon: mdi:clock-in
    initial: 30
    min: 0
    max: 59
    step: 1

input_boolean:
  wakeup:
    name: 'Activate Light Alarm'
    icon: mdi:power
    initial: on

  wakeup_weekend:
    name: 'Weeekend'
    icon: mdi:power
    initial: on

  wakeup_monday:
    name: Monday
    icon: mdi:calendar
    initial: on

  wakeup_tuesday:
    name: Tuesday
    icon: mdi:calendar
    initial: on

  wakeup_wednesday:
    name: Wednesday
    icon: mdi:calendar
    initial: on

  wakeup_thursday:
    name: Thursday
    icon: mdi:calendar
    initial: on

  wakeup_friday:
    name: Friday
    icon: mdi:calendar
    initial: on

  wakeup_saturday:
    name: Saturday
    icon: mdi:calendar
    initial: off

  wakeup_sunday:
    name: Sunday
    icon: mdi:calendar
    initial: off
    
### Automation ###
automation:
  - id: wake_up_lights
    alias: Wake Up Lights
    initial_state: true
    trigger:
      - platform: template
        value_template: '{{ states.sensor.time.state == states.sensor.wakeup_alarm_time.state }}'
    condition:
      - condition: state
        entity_id: person.ghislaine_louis
        state: home
      - condition: state
        entity_id: person.marc_louis
        state: home
      - condition: state
        entity_id: input_boolean.wakeup
        state: 'on'
      - condition: template
        value_template: '{{ is_state(''input_boolean.wakeup_'' ~ [''monday'',''tuesday'',''wednesday'',''thursday'',''friday'',''saturday'',''sunday''][now().weekday()], ''on'') }}'
    action:
      - service: notify.alexa_media
        data:
          data:
            type: announce
          target:
            - media_player.mbedechoplus
          message: 'Good morning my dear, it is time to get up.'
      - delay: 00:00:01
      - service: light.turn_on
        data:
          brightness: 15
          entity_id: light.mbedfanleds, light.desserlightstrip
          rgb_color:
            - 0
            - 34
            - 255
      - delay: 00:00:15
      - service: light.turn_on
        data:
          brightness: 103
          entity_id: light.mbedfanleds, light.desserlightstrip
          rgb_color:
            - 249
            - 123
            - 0
          transition: 15
      - delay: 00:30:00
      - service: light.turn_off
        data:
          entity_id: light.mbedfanleds, light.desserlightstrip
        
### Sensors ###
sensor:
  - platform: template
    sensors:
      wakeup_alarm_time:
        friendly_name: 'Alarm Time'
        value_template: '{% if states.input_number.slider_wakeup_hour.state | length == 3 %}0{% endif %}{{ states.input_number.slider_wakeup_hour.state | int }}:{% if states.input_number.slider_wakeup_minutes.state | length == 3 %}0{% endif %}{{ states.input_number.slider_wakeup_minutes.state | int }}'
4 Likes

Thank you, the “big problem” was that i havent enabled the sensor.time.
So happy that everything now works fine. :smiley:

Can you share me your code and how to fix it? Thank you

1 Like

I read it, but idk how to fix, i newbie in programing :frowning:

There’s nothing programming about it. All you need to to is add the sensor to your configuration.yaml. Copy & paste.

1 Like

Oh, thank you, and i place this code to my configuration.yaml to add sensor.time right? :smiley: Thank you very much

sensor:
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
      - 'date_time'
      - 'date_time_utc'
      - 'date_time_iso'
      - 'time_date'
      - 'time_utc'
      - 'beat'

UPDATE:, it worked, cant belive i must add sensor time by above code to fix it hahahaha, so stupid. Thank @petro and @g14nn86 so much. <3

what is the input_boolean.wakestatus_1 used for?

It’s honestly a bit redundant, but it controls whether that alarm will run or not. That way, I can leave the weekday toggles on but turn off the alarm itself if I want, and then turn it back on later for the same days with a single button. With my work schedule, this is a convenient feature.

The automation should work without it, as long as you remove it from the conditionals.