I didn’t find a component to create an alarm clock for my difficult morning, so i implement that.
It’s composed with simple modules
We need 2 input_slider alarmminutes for minutes and alarmhour for hour.
one sensor to display wake up time from the two slider.
And two input_boolean, alarmweekon to activate/desactivate the alarm, and alarmweekday to setup alarm for the weekdays (if this one is activated only the weekdays are active, if not it will activate for only weekend days).
in the configuration.yaml :
input_slider:
alarmhour:
name: Heure
icon: mdi:timer
initial: 6
min: 0
max: 23
step: 1
alarmminutes:
name: Minutes
icon: mdi:timer
initial: 30
min: 0
max: 59
step: 5
input_boolean:
alarmweekday:
name: Les jours de la semaine
initial: on
icon: mdi:calendar
alarmweekon:
name: Activee
initial: on
group:
alarmclock:
name: Wake Me Up
entities:
- sensor.alarm_time
- input_slider.alarmhour
- input_slider.alarmminutes
- input_boolean.alarmweekday
- input_boolean.alarmweekon
in the sensors.yaml :
- platform: template
sensors:
alarm_time:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_slider.alarmhour") | int, states("input_slider.alarmminutes") | int) }}'
And we need automation to finish that :
- alias: "Wake me up with bedroom light transition for weekdays"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
- service: light.turn_on
entity_id: light.bedroom
data:
transition: 600
brightness: 255
- alias: "Wake me up with bedroom light transition for weekend days"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
service: light.turn_on
entity_id: light.bedroom
data:
transition: 600
brightness: 255
Many improvements could be found in digging the original post:
I didn’t find a component to create an alarm clock for my difficult morning, so i implement that.
It’s composed with simple modules
input_boolean :
reveil:
name: Reveil positionné
initial: off
icon: mdi:alarm
lightreveil:
name: Reveil Naturel
initial: off
icon: mdi:theme-light-dark
We declare 2 input_boolean to turn on the TV and to turn on bedroom’s light
input_select:
choixreveil:
name: "reveil matin"
icon: mdi:alarm
initial: "06:35"
op…
9 Likes
Peleke
(Frederik Niedernolte)
November 4, 2017, 11:22am
3
Thanks a lot for your project and description!
Do you know how I could modify it so that it is possible to set the next alarm time via Google Home / IFTTT / Voice?
I have connected IFTTT with Google Assistant and Home Assistant and would like to set a radio alarm timer at a specific time with the IFTTT trigger “Say a phrase with a number”.
I have created a new IFTTT applet with the phrase “Set radio alarm to # clock” and use as URL https://myname.dns.com/api/services/script/radiowecker?api_password=XXX with POST method {“entity_id”: “script.radioalarm”}
The script.radioalarm looks currently like this:
radiowecker:
alias: 'Radiowecker stellen und a…
poldim
November 17, 2017, 7:04am
4
Thanks for the writeup @hokagegano ! I tried adapting your code for my setup but it gave me errors.
Looks like input_slider
might be obsolete, replacing it with input_number
made it work.
Hi @poldim
you’re right with the use of input_number.
The code updated :
input_number:
alarmhour:
name: Heure
icon: mdi:timer
initial: 6
min: 0
max: 23
step: 1
mode: slider
alarmminutes:
name: Minutes
icon: mdi:timer
initial: 35
min: 0
max: 59
step: 5
mode: slider
For the group
alarmclock:
name: Wake Me Up
entities:
- input_boolean.freebox
- sensor.alarm_time
- input_number.alarmhour
- input_number.alarmminutes
- input_boolean.alarmweekday
- input_boolean.alarmweekon
in sensor.yaml
- platform: template
sensors:
alarm_time:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.alarmhour") | int, states("input_number.alarmminutes") | int) }}'
and for automation
- alias: "Wake me up with bedroom light transition for weekdays"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
- service: light.turn_on
entity_id: light.bedroom
data:
transition: 600
brightness: 255
- alias: "Wake me up with bedroom light transition for weekend days"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
service: light.turn_on
entity_id: light.bedroom
data:
transition: 600
brightness: 255
2 Likes
Peleke
(Frederik Niedernolte)
November 24, 2017, 6:55pm
6
Thanks @hokagegano for sharing your project!
I am using it successfully but have changed the actions a little bit:
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.schlafzimmer
volume_level: 0.1
- service: tts.google_say
entity_id: media_player.schlafzimmer
data:
message: "Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}"
cache: false
- service: media_player.play_media
data_template:
entity_id: media_player.wohnung
media_content_id: 'http://fluxfm.hoerradar.de/fluxfmberlin-live-aac-mq?sABC=59s45n23%230%23no8617362n29q2o435p17n54928n16s5%23gharva&amsparams=playerid:tunein;skey:1509186083'
media_content_type: 'audio/mp4'
The only problem is the action with tts because it doesn’t get executed (at least I cannot hear a word and also nothing in the error log). I have tried the same action in the service tool of Home Assistant and it worked. How can I fix it in this project as well?
3vasi0n
(Joseph Sanders)
January 12, 2018, 1:12pm
7
Hey @Peleke not sure if you’re still having the issue of the tts not working but here’s a couple of things you can try. First thing is to comment out the part for playing the music and test to see if the tts works without it. If it does then set up like a 5 second delay after the tts and before the play media. I had the same issue and what happens is the music plays before the tts gets a chance to play and takes over. If that doesn’t work then maybe try switching
data:
message: "Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}"
cache: false
to
data_template:
message: "Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}"
cache: false
1 Like
Peleke
(Frederik Niedernolte)
January 24, 2018, 9:26pm
8
Thanks, I got it working now with the added delay
1 Like
Hey, can you share a complete copy for me? thank you! I need it very much.
maurizio53
(Maurizio Fabiani)
October 14, 2018, 11:39am
10
Can you share your input_boolean.alarmweekon and input_boolean.alarmweekday ?
Thanks
maurizio53
(Maurizio Fabiani)
October 14, 2018, 11:52am
11
What is inside input_boolean.freebox ?
Hi,
Sorry for the late.
alarmweekday allow to trigger alarm only the working days
alarmweekon is the activated button for alarm.
The freebox is a french isp box, this boolean allow to power on the box with the alarm.
maurizio53
(Maurizio Fabiani)
October 17, 2018, 9:15am
14
Can you tell me how to change the default alarm clock hour?
I tried to change the sensor.alarm_time, but really don’t understand how…
The line is the following:
{{ "%0.02d:%0.02d" | format(states("input_number.alarmhour") | int, states("input_number.alarmminutes") | int) }}'
Hi @maurizio53
I repost my last config for alarm clock
Test and say me if that resolve your issue
in your configuration.yaml :
input_number:
alarmhour:
name: Heure
icon: mdi:timer
initial: 6
min: 0
max: 23
step: 1
mode: slider
alarmminutes:
name: Minutes
icon: mdi:timer
initial: 35
min: 0
max: 59
step: 5
mode: slider
input_boolean:
alarmweekday:
name: Les jours de la semaine
initial: on
icon: mdi:calendar
alarmweekon:
name: Activee
initial: on
in the automations.yaml :
- alias: "reveil matin Aurore Semaine"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: state
entity_id: calendar.jours_feries_en_france
state: 'off'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 300) | timestamp_custom("%H:%M") == states.sensor.alarm_time.state) }}'
action:
- service: light.turn_on
entity_id: light.chambre
data:
transition: 600
brightness: 255
- alias: "reveil matin Aurore les weekend"
trigger:
- platform: time
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
service: light.turn_on
entity_id: light.chambre
data:
transition: 600
brightness: 255
in the sensor.yaml :
- platform: template
sensors:
alarm_time:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.alarmhour") | int, states("input_number.alarmminutes") | int) }}'
in the group.yaml :
alarmclock:
name: Wake Me Up
entities:
- sensor.alarm_time
- input_number.alarmhour
- input_number.alarmminutes
- input_boolean.alarmweekday
- input_boolean.alarmweekon
the calendar.jours_feries_en_france means days off in France
maurizio53
(Maurizio Fabiani)
October 18, 2018, 10:27am
16
It works as before. What i don’t understand is how to set a default alarm hour than 06:35? Where to change it?
The default value is on the declaration of input_number value initial …
I had to change platform: time to platform: time_pattern
because of a error when saving. But stil not working for me
Is it possible that there has to be made more changes to let it work on HA 0.94.3 ?
trigger:
- platform: time
minutes: '/1'
seconds: 0
To >
trigger:
- platform: time_pattern
minutes: '/1'
#seconds: 0
Hi,
For me the code works well i wake up everyday with that :
- id: reveil matin Aurore Semaine
alias: reveil matin Aurore Semaine
trigger:
- platform: time_pattern
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: input_boolean.automa
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: state
entity_id: calendar.jours_feries_en_france
state: 'off'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 300) | timestamp_custom("%H:%M")
== states.sensor.alarm_time.state) }}'
action:
- service: light.turn_on
entity_id: light.chambre
data:
transition: 600
brightness: 255
Thank you for your quick responce hokagegano ,
I tried your piece of code but that didn’t do the trick either.
Here is what I have
configuration.yaml
input_number:
alarmhour:
name: Heure
icon: mdi:timer
initial: 6
min: 0
max: 23
step: 1
mode: slider
alarmminutes:
name: Minutes
icon: mdi:timer
initial: 35
min: 0
max: 59
step: 5
mode: slider
input_boolean:
alarmweekday:
name: Les jours de la semaine
initial: on
icon: mdi:calendar
alarmweekon:
name: Activee
initial: on
automations.yaml
- alias: "reveil matin Aurore Semaine"
trigger:
- platform: time_pattern
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'on'
- condition: state
entity_id: calendar.jours_feries_en_france
state: 'off'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ ((now().strftime("%s") | int + 300) | timestamp_custom("%H:%M") == states.sensor.alarm_time.state) }}'
action:
- service: light.turn_on
entity_id: light.voordeurlamp
#data:
# transition: 600
# brightness: 255
- alias: "reveil matin Aurore les weekend"
trigger:
- platform: time_pattern
minutes: '/1'
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarmweekon
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
service: light.turn_on
entity_id: light.voordeurlamp
#data:
# transition: 600
# brightness: 255
Created a sensors.yaml file and added ’ sensor: !include sensors.yaml ’ to configuration.yaml
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
sensor: !include sensors.yaml
sensors.yaml
- platform: template
sensors:
alarm_time:
friendly_name: 'Time'
value_template: '{{ "%0.02d:%0.02d" | format(states("input_number.alarmhour") | int, states("input_number.alarmminutes") | int) }}'
And created a group.yaml, only I dont’s know if does anything because I use Lovelace frontend.
sensors.yaml
alarmclock:
name: Wake Me Up
entities:
- sensor.alarm_time
- input_number.alarmhour
- input_number.alarmminutes
- input_boolean.alarmweekday
- input_boolean.alarmweekon
So I also created a Custom Card in Lovelace
Hope you can tell what is wrong with this setup