Didn’t realize you had to drag the notification down to get the buttons
sorry for the late response. glad you got it figured out though!
The snooze time sounds like a pretty good idea! I’m not seeing any differences between the code that I posted and what you posted though. Do you mind pointing those out for me?
The snooze duration isn’t posted above, the above just fixed a small typo I found.
I’ll post the snooze code later this evening.
I added a ifttt to call my phone when the alarm goes off.
I mean’t what was the typo you found? I don’t see any differences in the codes
My mistake, there aren’t. When I originally implemented the code, I think there was one too few ‘{’ but it looks good now. Anyways, i’ll dig out the snooze duration code, stand by.
So I’ve implemented @3vasi0n code, as illustrated above, but made a few changes along the way…
I’ve added an additional input_number for alarm clock snooze duration, as well as one for fade in duration. So now I can adjust the snooze duration, and the amount of time it takes for the lights to fade-in.
instead of posting only the changes I’ve made, I found it easier to post the configuration, in it’s entirety
Here’s what it looks like (please note, I’m using a theme, so your colors may be different)
The code:
configuration.yaml:
config: sun: map: ios: push: categories: - name: alarm clock identifier: 'alarmclock' actions: - identifier: 'AWAKE' title: 'Awake' destructive: no - identifier: 'SNOOZE' title: 'Snooze' destructive: yes
input_boolean.yaml:
alarm_clock_status: name: Alarm Clock Status initial: on icon: mdi:alarm
input_number.yaml:
alarm_clock_hour: name: "Hour" icon: mdi:timer min: 0 max: 23 step: 1 mode: slider alarm_clock_minute: name: "Minutes" icon: mdi:timer min: 0 max: 55 step: 5 mode: slider alarm_clock_snooze: name: "Snooze" icon: mdi:alarm-snooze min: 0 max: 30 step: 1 mode: slider morning_lights_fadein: name: "Fade-in Minutes" icon: mdi:lightbulb-on-outline min: 5 max: 30 step: 1 mode: slider initial: 10
sensors.yaml:
- platform: template sensors: alarm_clock_hour: friendly_name: "Alarm Clock Hour" value_template: '{{ states.input_number.alarm_clock_hour.state | int }}' alarm_clock_minute: friendly_name: "Alarm Clock Minute" value_template: '{{ states.input_number.alarm_clock_minute.state | int }}' alarm_clock_snooze: friendly_name: "Alarm Clock Snooze" value_template: '{{ states.input_number.alarm_clock_snooze.state | int }}' alarm_clock_time: friendly_name: "Alarm Clock Time" value_template: >- {{ states.sensor.alarm_clock_hour.state }}: {%- if states.sensor.alarm_clock_minute.state|length == 1 -%} 0 {%- endif -%} {{ states.sensor.alarm_clock_minute.state }} alarm_clock_time_long: friendly_name: "Alarm Clock Time" value_template: >- {%- if states.sensor.alarm_clock_hour.state|length == 1 -%} 0 {%- endif -%} {{ states.sensor.alarm_clock_hour.state }}: {%- if states.sensor.alarm_clock_minute.state|length == 1 -%} 0 {%- endif -%} {{ states.sensor.alarm_clock_minute.state }}
groups.yaml:
alarm_clock: name: Alarm Clock icon: mdi:alarm entities: - input_boolean.alarm_clock_status - sensor.alarm_clock_time - input_number.alarm_clock_hour - input_number.alarm_clock_minute - sensor.alarm_clock_snooze - input_number.alarm_clock_snooze - sensor.morning_lights_fadein - input_number.morning_lights_fadein
automations.yaml:
# Alarm Clock - id: alarm_clock_activated alias: Alarm Clock Activated hide_entity: False trigger: - platform: template value_template: '{{ states.sensor.time.state == states.sensor.alarm_clock_time_long.state }}' condition: condition: and conditions: - condition: state entity_id: input_boolean.alarm_clock_status state: 'on' - condition: state entity_id: group.presence state: 'home' action: - service: script.turn_on # iOS Push Notification entity_id: script.alarm_clock_awake_pushed # I entirely removed the "Alarm Clock Awake Pushed" automation, because if I clicked "Awake", it just dismissed the notification, and I didn't need to perform an action based on this (I was awake, the lights were already on). # Alarm Clock Snooze Pushed - id: alarm_clock_snooze_action alias: alarm clock snooze action initial_state: true hide_entity: true trigger: - platform: event event_type: ios.notification_action_fired event_data: actionName: SNOOZE action: service: script.turn_on entity_id: script.alarm_clock_snooze_button
scripts.yaml:
(Please keep in mind, I’ve done a lot of customization here, specific to my setup, your data_template will, and should be very different; I always try and account for every possible situation, weekdays, weekends, holidays, etc.)
#Awake alarm_clock_awake_pushed: alias: 'Alarm Clock Awake' sequence: - service: script.turn_on data_template: entity_id: >- {%- if states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'off' -%} script.morning_lights_weekday {%- elif states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'on' and states.calendar.work.state == 'off' -%} script.morning_lights_weekend {%- elif states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'on' -%} script.morning_lights_weekend {%- elif states.binary_sensor.workday_sensor.state == 'off' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'off' -%} script.morning_lights_weekend {%- else -%} script.morning_lights_weekend {%- endif -%} - service: notify.ios_jon_iphone data: title: "Alarm Clock" message: "Time To Wake Up!" data: push: sound: "US-EN-Alexa-Good-Morning.wav" badge: 0 category: alarmclock # Alarm Clock Snooze Button -> Timer alarm_clock_snooze_button: alias: 'Alarm Clock Snooze Button' sequence: - service: light.turn_off data: entity_id: group.bedroom_lights - service: switch.turn_off entity_id: switch.n7x1_screen - service: switch.turn_off entity_id: switch.n7x2_screen - service: light.turn_off data: entity_id: light.hall_light - service: light.turn_off data: entity_id: light.bathroom_light - service: light.turn_off data: entity_id: group.kitchen_lights - service: script.turn_off data_template: entity_id: >- {%- if states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'off' -%} script.morning_lights_weekday {%- elif states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'on' and states.calendar.work.state == 'off' -%} script.morning_lights_weekend {%- elif states.binary_sensor.workday_sensor.state == 'on' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'on' -%} script.morning_lights_weekend {%- elif states.binary_sensor.workday_sensor.state == 'off' and states.input_boolean.vacation.state == 'off' and states.input_boolean.company.state == 'off' and states.calendar.holidays_in_united_states.state == 'off' and states.calendar.work.state == 'off' -%} script.morning_lights_weekend {%- else -%} script.morning_lights_weekend {%- endif -%} - service: script.turn_on data: entity_id: script.alarm_clock_snooze_timer # Alarm Clock Snooze Timer alarm_clock_snooze_timer: alias: 'Alarm Clock Snooze Timer' sequence: - delay: '{{ (states.sensor.alarm_clock_snooze.state | int * 60 ) }}' - service: automation.trigger data: entity_id: automation.alarm_clock_activated # Morning Lights Weekday morning_lights_weekday: alias: 'Morning Lights Weekday' sequence: - service: light.turn_on data: entity_id: group.bedroom_lights brightness: 1 color_temp: 358 - delay: seconds: 1 - service: light.turn_on data_template: entity_id: group.bedroom_lights brightness: 100 transition: > {{ states.input_number.morning_lights_fadein.state | int * 60 }} - service: switch.turn_on entity_id: switch.n7x1_screen - service: switch.turn_on entity_id: switch.n7x2_screen ... # Morning Lights Weekend morning_lights_weekend: alias: 'Morning Lights Weekend' sequence: - service: light.turn_on data: entity_id: group.bedroom_lights brightness: 1 color_temp: 358 - delay: seconds: 1 - service: light.turn_on data_template: entity_id: group.bedroom_lights brightness: 100 transition: > {{ states.input_number.morning_lights_fadein.state | int * 60 }} - service: switch.turn_on entity_id: switch.n7x1_screen - service: switch.turn_on entity_id: switch.n7x2_screen ...
Logic:
(fairly complicated, but works wonderfully)
If the alarm clock is ON, when the current time matches that of the alarm clock time, the following happens:
- Push notification to phone, with Alexa voice saying “Good Morning”
- Lights begin to fade in (for fade-in duration)
a. Depending on the day
b. Fire the following script (one or the other, not both):- morning_lights_weekend
- morning_lights_weekday
- Awake button - Simply dismisses the notification
- Snooze button - Perform the following:
- Snoozes for the alarm_clock_snooze duration
a. Turns off any and all lights, or screens that were turned on previously
b. Sleep for additional alarm_clock_snooze duration! - Cycle starts over…
Please let me know if anything doesn’t make sense, I accidentally left something out, or you’d like some more details, or clarification. Credit for the alarm clock should go to @3vasi0n, all I did was tweak it a little for my setup.
If anyone’s interested in how I’m controlling the tablet screens, please check out my other post
Looks nice man! I just got done reading your write up about the Fully Kiosk and the timing couldn’t have been better on that! I was literally getting ready to start working with that app when I noticed you replied to my question about the typo. Appreciate you saving me a lot of time with research on Fully Kiosk and I like what you did with the additions to the alarm clock. Since the time that I wrote this I have made a lot of changes to my own personal one and was planning on updating the article. I’ll make sure to give you credit on the snooze and light duration in the update!
Thanks man, glad you liked the Fully post. It’s a really powerful application, with a ton of great features! I love that you can control so much of the tablet, with a single application; really makes Fully an extension of HA, not just another piece.
Thanks again for writing up the original alarm clock; without that we probably wouldn’t be having this conversation. I’m anxious to see what improvements you’ve done, on your own.
I’ve been thinking about implementing some kind of media player, into the alarm clock, to play some kind of peaceful alarm, with a fade-in duration to match the lights. First step for me is, figuring out the hardware, the rest is fairly easy. If I make some traction on that, I’ll be sure and let you know!
Anyways, keep up the great work! I really enjoy seeing things like the alarm clock, building something awesome out of what we already use within HA (without having to add unnecessary hardware).
Let me know if you ever make any headway with setting your floorplan up! I’ve been trying to work on mine off and on for the last couple of months but there’s not really much documentation out there on the subject yet as far as getting it all working correctly.
Thank you so much for sharing this. Quick question for you regarding your scripts. I found the workday sensor as a HA component but wondered what the following are. Do I need them in my script for it to work?
input_boolean.vacation
input_boolean.company
calendar.holidays_in_united_states
calendar.work
Hey @Darren_Edwards no, you do not need those, they are specific to my installation, and used to check for various custom conditions (if it’s a holiday, I’ll probably be sleeping in; if I take PTO, I add it to my work calendar; etc)
Happy automating!
Thank you @xstrex I have made a few changes of my own and ended up adding back in the “Alarm Clock Awake Pushed” automation so that entities (such as lights) don’t turn on when the actionable alert is first sent. My automation for ‘when awake button pushed’ then now turns on lights, turns on the coffee machine and starts my music playing in the kitchen. Thanks so much again for sharing your code. I can see so many applications.
Hello
I have added this to my setup, but I can’t get it to work. There are no errors and I have adapted everything for my setup, but when I enter the time for the alarm nothing happens. I’m using it as a card into a group, I don’t know if it makes a difference…
Also, the alarm time is not remembered if I restart HA, so I have to set it up again from the panel. Is this normal?
Thanks
My problem is with the time sensors, that’s the part is not working for me.
If I put the automation for a fixed time (instead of it based on whatever set on the frontend), then it works fine.
There has been any changes in the way sensors work lately?
I think so because mines been hit or miss lately. I’ve just been too busy with work to figure it out.
As far as things being reset when you restart HA all you have to do is delete the initial: lines out of the input numbers and booleans. HA changed some things since I’ve wrote this and it’s definitely due for some updates.
I’ll try to get to it as soon as possible
Done something very similar. We have options for our alarm because we are both shift workers and each “morning” is so dynamic.
Can choose to wake up to the kettle on, heater on, Google Home playing music, bedroom lights on and the main lights on.
Also hit silence on our phones from the push notification to shut google home up.
Nothing better when it all comes together!
Hi, I really love the addition of these options. Any chance you can share your config? It would be much appreciated. Thanks
We use input booleans to turn on or off these different items
input_boolean: alarm_kettle: name: Alarm Kettle initial: off icon: mdi:kettle
Then the automation for the alarm is longer than it needs to be but I have made it so when the alarm equals the time then it will turn on the kettle for example. The kettle only triggers if the input boolean is on and someone is home. Had to include a backup if we got up earlier and walked out forgetting the alarm was going to trigger. Another thing is we can’t run the heater and the kettle at the same time so I had to ensure the heater was off before the kettle runs.
- alias: Alarm Kettle
trigger:
- platform: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_clock_time }}'
condition:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_kettle
state: 'on'
- condition: state
entity_id: input_boolean.alarm_heater
state: 'off'
- condition: or
conditions:
- condition: state
entity_id: device_tracker.iphone1
state: home
- condition: state
entity_id: device_tracker.iphone2
state: home
action:
- service: switch.turn_on
entity_id: switch.kettle