Any chance you might include a link or code box containing the related “script.wakeup_sequence” that this package calls… or perhaps pointers on how to write one that works for this flow. I will modify the above pacakage to include the entity-IDs.
PS. Thanks in advance this is very helpful…
I have the below inside a package called ‘alarm_clock.yaml’. You will see a few comments where I plan to make some changes but haven’t yet as they are not a priority right now.
script:
bedroom_wake_up:
sequence:
- service: scene.turn_on
entity_id: scene.bedroom_wake_up
# - service: shell_command.yeelight_bedroom_artificial_dawn
- condition: state
entity_id: input_boolean.bedroom_alarm_clock_music
state: 'on'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.10'
- service: media_player.play_media
data_template:
entity_id: media_player.bedroom
media_content_id: http://pub1.diforfree.org:8000/di_chillntropicalhouse_hi # look at changing this to a selector with multiple music streams
media_content_type: 'audio/mp4'
# - condition: state
# entity_id: sensor.master_bedroom_multisensor_luminance
# below: '10'
- delay: '00:01:00'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.15'
- delay: '00:01:00'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.20'
- delay: '00:01:00'
- service: media_player.volume_set
data:
entity_id: media_player.bedroom
volume_level: '0.25'
Thank you very very much indeed for your prompt reply. Currently I’m migrating my hassio install from a Ubuntu laptop via docker to my server docker. I’m excited to set this up and give it a go. One awesome thing is that I already have an entity named media_player.bedroom (Chromecast…) so half of my setup is already going to be easier… Thanks again. And if you have any other suggestions ideas or questions please feel free to contact me. I’ll return here to fallow up soon…
Sorry for the late reply.
here is my wakeup_sequence script that calls other scripts as well but i’ll give you the general idea
'wakeup_sequence':
alias: wakeup_sequence
sequence:
- data:
message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state }} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{ states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state }} ) 00:{{ states.input_number.alarm_1_offset.state | int }}:00
service: notify.zchat
- data: {}
service: script.wakeup_dim
- delay: 00:00:02
- service: script.wakeup_bright
- delay: '00:{{ states.input_number.alarm_1_offset.state | int }}:00'
- data: {}
service: script.play_wakeup_music
here my scripts to slowly up the light
'wakeup_dim':
alias: wakeup_dim
sequence:
- data:
brightness: '0'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
kelvin: '2200'
transition: '0'
service: light.turn_on
- data:
brightness: '0'
entity_id:
- light.gateway_light_286c07fa2642
- light.yeelight_rgb_34ce008d0d2f
rgb_color:
- 255
- 169
- 92
service: light.turn_on
- data:
brightness_pct: '0'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
transition: '0'
service: light.turn_on
'wakeup_bright':
alias: wakeup_bright
sequence:
- data_template:
brightness: '255'
kelvin: '2700'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
service: light.turn_on
- data_template:
brightness: '255'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
service: light.turn_on
and to play my music from my stereo after selecting the right inputs and a random spotify playlist
'play_wakeup_music':
alias: play_wakeup_music
sequence:
- data:
entity_id:
- media_player.denon
- media_player.spotify
service: media_player.turn_on
- delay: 00:00:01
- data:
message: denon on
service: notify.zchat
- delay: 00:00:02
- data:
entity_id: media_player.denon
source: Shield
service: media_player.select_source
- delay: 00:00:01
- data:
entity_id:
- media_player.denon
volume_level: '0.3'
service: media_player.volume_set
- delay: 00:00:01
- data:
message: Denon selected source Spotify
service: notify.zchat
- delay: 00:00:01
- data:
entity_id: media_player.spotify
source: SHIELD
service: media_player.select_source
- delay: 00:00:01
- data:
message: Spotify selected Denon
service: notify.zchat
- data:
entity_id: media_player.spotify
media_content_type: playlist
data_template:
media_content_id: '{{ ["spotify:user:spotify:playlist:37i9dQZEVXcK5C3ela3Jxr", "spotify:user:spotify:playlist:37i9dQZEVXcIzJ38jqdiEE", "spotify:user:spotify:playlist:37i9dQZF1DX26DKvjp0s9M", "spotify:user:krodgers84:playlist:691iHoxn3pk84XAqHIU00e"]
| random}}'
service: media_player.play_media
- delay: 00:00:05
- data:
message: now playing spotify on some device
service: notify.zchat
- delay: 00:05:00
- data:
entity_id:
- media_player.denon
volume_level: '0.35'
service: media_player.volume_set
- delay: 00:05:00
- data:
entity_id:
- media_player.denon
volume_level: '0.4'
service: media_player.volume_set
updated to 82.1, somehow my alarmclock stopped working, not sure why. i added entity_ids with no avail.
any input appreciated
Is there a way to show how much time will pass till the alarm?
Suppose that is 22:00 and I set an alarm for 06:00
It should show 08:00 because will pass 8 hours between the current time and the alarm.
Is this possible?
Thanks
Hey bott0r… did you manage to get your code working again? Would you show us your current version? (and for a newbie like me tell me the names of the files you put it in )
Thanks a lot
Hey, Yes it works. However, you have to split up the configuration files.
I have a alarm_1.yaml
input_number:
alarm_1_hour:
name: Hours
icon: mdi:timer
initial: 7
min: 0
max: 23
step: 1
alarm_1_minutes:
name: Minutes
icon: mdi:timer
initial: 0
min: 0
max: 59
step: 1
alarm_1_offset:
name: Transition
icon: mdi:blur-linear
initial: 15
min: 0
max: 60
step: 15
input_boolean:
alarm_1_weekday:
name: Weekdays
initial: on
icon: mdi:calendar
alarm_1_weekend:
name: Weekends
initial: off
icon: mdi:calendar
sensor:
- platform: template
friendly_name: sensor.alarm_1_time
sensors:
alarm_1_time:
friendly_name: 'Alarm Time'
value_template: >-
{{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour") | int, states("input_number.alarm_1_minutes") | int) }}
- platform: template
entity_id: sensor.alarm_1_time_minus_offset
sensors:
alarm_1_time_minus_offset:
friendly_name: 'Offset Time'
value_template: >-
{{ '%0.02d:%0.02d' | format( ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset'))| int)/60)| int),(((((((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)) - ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)| int))*100) | int)*60/100) | round) ) }}
group:
alarm_1:
name: Wake Me Up
entities:
- sensor.time
- sensor.alarm_1_time
- sensor.alarm_1_time_minus_offset
- input_number.alarm_1_hour
- input_number.alarm_1_minutes
- input_number.alarm_1_offset
- input_boolean.alarm_1_weekday
- input_boolean.alarm_1_weekend
and i have my automations setup this way in the automations.yaml
- id: alarm_1_weekday
alias: Wake me up (weekday)
trigger:
- platform: time
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarm_1_weekday
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_1_time_minus_offset.state }}'
action:
- data:
message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is
set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state
}} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{
states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state
}} ) test {{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour")
| int, states("input_number.alarm_1_minutes") | int) }}
service: notify.zchat
- data: {}
service: script.wakeup_sequence
- id: alarm_1_weekend
alias: Wake me up (weekend)
trigger:
- platform: time
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarm_1_weekend
state: 'on'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_1_time_minus_offset.state }}'
action:
- data:
message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is
set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state
}} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{
states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state
}} ) test {{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour")
| int, states("input_number.alarm_1_minutes") | int) }}
service: notify.zchat
- data: {}
service: script.wakeup_sequence
finally i have a script in script.yaml
'wakeup_dim':
alias: wakeup_dim
sequence:
- data:
brightness: '0'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
kelvin: '2200'
transition: '0'
service: light.turn_on
- data:
brightness: '0'
entity_id:
- light.gateway_light_286c07fa2642
- light.yeelight_rgb_34ce008d0d2f
rgb_color:
- 255
- 169
- 92
service: light.turn_on
- data:
brightness_pct: '0'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
transition: '0'
service: light.turn_on
'wakeup_bright':
alias: wakeup_bright
sequence:
- data_template:
brightness: '255'
kelvin: '2700'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
service: light.turn_on
- data_template:
brightness: '255'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
service: light.turn_on
'wakeup_sequence':
alias: wakeup_sequence
sequence:
- data:
message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state }} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{ states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state }} ) 00:{{ states.input_number.alarm_1_offset.state | int }}:00
service: notify.zchat
- data: {}
service: script.wakeup_dim
- delay: 00:00:02
- service: script.wakeup_bright
- delay: '00:{{ states.input_number.alarm_1_offset.state | int }}:00'
- data: {}
service: script.play_wakeup_music
@bott0r love the alarm clock code; I’m trying to do something similar where I can tweak the wakeup time from the front end. Can you help me explain your automation, specifically your trigger? What’s happening there?
trigger:
- platform: time
minutes: /1
seconds: 0
Why wouldn’t I want my trigger to be the current time matching my alarm_clock_time? (the following is incorrect syntax I’m just trying to understand the logic)
trigger:
- platform: time
states.sensor.time.state == states.sensor.alarm_clock_time
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
action:
-blah blah blah...
I use the workday sensor which I love and so my thought was that:
While workday sensor is true the alarm clock automation triggers when the current time is equal to the set time which I configured using your alarm_1.yaml package. Thanks in advance
i have below alarmclock
it use input_time ( this is actually updated by tasker on my android to always be the next alarm time of my phone )
i also have an condition on the automation so it only triggers between 22:30 and 12:30 because i have some other alarms as reminders of tasks, and no need for the bedroom lights to turn on/off for that.
Also a condition to see that i am actually home, no need for it to trigger when i am away on worktrip.
Then it:
1, start dimming up bedroom light 30 min before alarm
2, at alarm set light to 100%, start playing internet radio on the closest google home mini, turn on an automation that prevents me turning off the google home mini for 10 minutes.
In tasker on my phone i just made an “intent received” profile from event -> system
then in action i wrote “android.app.action.NEXT_ALARM_CLOCK_CHANGED”
and as a task i made HTTP post with:
server:port = https://
path = /api/services/input_datetime/set_datetime?api_password=
data / file = { “entity_id” : “input_datetime.next_alarm”, “time” : “%taskertime”, “date” : “%year-%month-%day” }
( the above variables are from tasker plugin called autoalarm )
group:
alarmclock:
name: Alarmclock
control: hidden
entities:
- input_datetime.next_alarm
- automation.alarmclock
- automation.keep_morning_radio_on
input_datetime:
next_alarm:
name: Next phone alarm
has_date: true
has_time: true
automation old:
#####################
#
# Alarmclock
# start 30 min before alarm
#
#####################
- alias: Alarmclock
trigger:
- platform: template
value_template: "{{ (states('sensor.date') + ' ' + states('sensor.time')) == ( states.input_datetime.next_alarm.attributes.timestamp | int - (30*60) ) | timestamp_custom('%Y-%m-%d %H:%M', True) }}"
condition:
# Only run between 22:30 and 12:30
- condition: template
value_template: "{{ states('sensor.time') >= '22:30'|timestamp_custom('%H:%M', True) or states('sensor.time') <= '12:30'|timestamp_custom('%H:%M', True) }}"
# Only run automation if i'm home
- condition: state
entity_id: binary_sensor.simon
state: 'on'
action:
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 1
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 3
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 5
- delay: '00:4:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 10
- delay: '00:4:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 15
####### ~18 min before alarm rings #######
- delay: '00:3:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 25
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 35
- delay: '00:3:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 45
####### ~10 min before alarm rings #######
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 55
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 65
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 75
- delay: '00:2:00'
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 85
####### ALARM RINGS #######
- delay: '00:2:00'
- service: automation.turn_on
entity_id: automation.keep_morning_radio_on
- service: light.turn_on
entity_id: light.master_bedroom
data_template:
brightness_pct: 100
- delay: '00:00:02'
- service: script.radio
- delay: '00:00:01'
- service: media_player.volume_set
data:
entity_id: media_player.kitchen_home_mini
volume_level: '0.65'
# make sure morning radio is on for atleast 10 min
- delay: '00:10:00'
- service: automation.turn_off
entity_id: automation.keep_morning_radio_on
#####################
#
# keep radio on during morning
#
#####################
- alias: Keep morning radio on
initial_state: false
trigger:
- platform: state
entity_id: media_player.kitchen_home_mini
from: 'playing'
to: 'off'
- platform: state
entity_id: media_player.kitchen_home_mini
from: 'playing'
to: 'paused'
condition:
action:
- service: script.radio
- delay: '00:00:02'
- service: media_player.volume_set
data:
entity_id: media_player.kitchen_home_mini
volume_level: '0.65'
What do you mean editing the wake up time from the front end. i have it like this
when you add group.alarm_1 to your frontend groups
Sorry for the confusion. What I meant was that I had a “wake up alarm” automation that I triggered by setting a time as the trigger for that automation. What I didn’t like about that was if I wanted to wake up at 6:30 instead of 6:15 I had to open up my computer, adjust my automations.yaml and then save the file and reload the automations.
For the improved version of this I wanted to use parts of your code and setup an alarm clock / wake me up group in my frontend to easily allow me to adjust my exact wakeup time. I use the workday binary sensor and I don’t have any dimmable lights so I got rid of the offset, transitions, and weekday/weekend stuff but I’m having trouble getting it to trigger. I also moved the groups and automations into the package rather than listening them separately. Here is what my front end looks like and code is below.
#INPUTS
input_number:
alarm_clock_hour:
name: Hour
icon: mdi:timer
initial: 6
min: 0
max: 23
step: 1
alarm_clock_minutes:
name: Minute
icon: mdi:timer
initial: 15
min: 0
max: 59
step: 5
# alarm_1_offset:
# name: Transition
# icon: mdi:blur-linear
# initial: 15
# min: 0
# max: 60
# step: 15
# input_boolean:
# alarm_1_weekday:
# name: Weekdays
# initial: on
# icon: mdi:calendar
# alarm_1_weekend:
# name: Weekends
# initial: off
# icon: mdi:calendar
#SENSORS
sensor:
- platform: template
friendly_name: sensor.alarm_clock_time
sensors:
alarm_clock_time:
friendly_name: 'Alarm Clock Time'
value_template: >-
{{ "%0.02d:%0.02d" | format(states("input_number.alarm_clock_hour") | int, states("input_number.alarm_clock_minutes") | int) }}
# - platform: template
# entity_id: sensor.alarm_1_time_minus_offset
# sensors:
# alarm_1_time_minus_offset:
# friendly_name: 'Offset Time'
# value_template: >-
# {{ '%0.02d:%0.02d' | format( ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset'))| int)/60)| int),(((((((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)) - ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)| int))*100) | int)*60/100) | round) ) }}
#FRONT END
group:
alarm_clock:
name: Wake Me Up
entities:
# - sensor.time
- sensor.alarm_clock_time
# - sensor.alarm_1_time_minus_offset
- input_number.alarm_clock_hour
- input_number.alarm_clock_minutes
# - input_number.alarm_1_offset
# - input_boolean.alarm_1_weekday
# - input_boolean.alarm_1_weekend
# AUTOMATIONS
automation:
- id: alarm_clock_workday
alias: Wake me up (workday)
trigger:
- platform: time
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_clock_time }}'
action:
- data:
message: time to wakeup
service: notify.ios_garrett_iphone
- data: {}
service: script.1544825537507
The package system is somewhat depreciated, you have to separate the files, then it will probably trigger.
oh really? when did that happen? I have a door locks package that works great or at least I think it does.
I’m using a folder for both packages and then have packages: !include_dir_named packages
in my config file.
That’s why I started the topic. Because I updated and the packed automation stopped working, now I am insecure.
ooooooohhhhhhh interesting.
There isn’t a way in the UI to test triggers by creating a fake event is there? Something similar to how you can call a service or set a state?
Looks like this is broken as of 0.86
I’m guessing:
- Automation: Split time_pattern triggers from time trigger (@armills - #19825) (automation.interval docs) (automation.time docs) (breaking change)
Works now for me in packages recent hass.io version:
input_number:
alarm_1_hour:
name: Hours
icon: mdi:timer
initial: 7
min: 0
max: 23
step: 1
alarm_1_minutes:
name: Minutes
icon: mdi:timer
initial: 0
min: 0
max: 59
step: 1
alarm_1_offset:
name: Transition
icon: mdi:blur-linear
initial: 15
min: 0
max: 60
step: 15
input_boolean:
alarm_1_weekday:
name: Weekdays
initial: on
icon: mdi:calendar
alarm_1_weekend:
name: Weekends
initial: off
icon: mdi:calendar
sensor:
- platform: template
friendly_name: sensor.alarm_1_time
sensors:
alarm_1_time:
friendly_name: 'Alarm Time'
value_template: >-
{{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour") | int, states("input_number.alarm_1_minutes") | int) }}
- platform: template
entity_id: sensor.alarm_1_time_minus_offset
sensors:
alarm_1_time_minus_offset:
friendly_name: 'Offset Time'
value_template: >-
{{ '%0.02d:%0.02d' | format( ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset'))| int)/60)| int),(((((((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)) - ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)| int))*100) | int)*60/100) | round) ) }}
group:
alarm_1:
name: Wake Me Up
entities:
- sensor.time
- sensor.alarm_1_time
- sensor.alarm_1_time_minus_offset
- input_number.alarm_1_hour
- input_number.alarm_1_minutes
- input_number.alarm_1_offset
- input_boolean.alarm_1_weekday
- input_boolean.alarm_1_weekend
automation:
- id: 'alarm_1_weekday'
alias: Wake me up (weekday)
trigger:
- platform: time_pattern
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarm_1_weekday
state: 'on'
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_1_time_minus_offset.state }}'
action:
#- data:
# message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state }} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{ states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state }} ) test {{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour") | int, states("input_number.alarm_1_minutes") | int) }}
# service: notify.zchat
- data: {}
service: script.wakeup_sequence
- id: 'alarm_1_weekend'
alias: Wake me up (weekend)
trigger:
- platform: time_pattern
minutes: /1
seconds: 0
condition:
- condition: state
entity_id: input_boolean.alarm_1_weekend
state: 'on'
- condition: time
weekday:
- sat
- sun
- condition: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_1_time_minus_offset.state }}'
action:
#- data:
# message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state }} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{ states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state }} ) test {{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour") | int, states("input_number.alarm_1_minutes") | int) }}
# service: notify.zchat
- data: {}
service: script.wakeup_sequence
script:
'wakeup_dim':
alias: wakeup_dim
sequence:
- data:
brightness: '0'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
kelvin: '2200'
transition: '0'
service: light.turn_on
- data:
brightness: '0'
entity_id:
- light.gateway_light_286c07fa2642
- light.yeelight_rgb_34ce008d0d2f
rgb_color:
- 255
- 169
- 92
service: light.turn_on
- data:
brightness_pct: '0'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
transition: '0'
service: light.turn_on
'wakeup_bright':
alias: wakeup_bright
sequence:
- data_template:
brightness: '255'
kelvin: '2700'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.lamp_kitchen1
- light.lamp_kitchen2
- light.lamp_kitchen3
- light.lamp_dinning1
- light.lamp_dinning2
- light.lamp_dinning3
- light.office_lamp_new
- light.lamp_couch
- light.bedroom_lamp1
- light.bedroom_lamp2
- light.hallway_lamp_new
service: light.turn_on
- data_template:
brightness: '255'
transition: '{{(states(''input_number.alarm_1_offset'') | int ) *60}}'
entity_id:
- light.colour_bulb
rgb_color:
- 255
- 169
- 92
service: light.turn_on
'wakeup_sequence':
alias: wakeup_sequence
sequence:
- data:
message: Alarm ! Current time is {{ states.sensor.time.state }} and alarm is set to {{ states.sensor.alarm_1_time.state }} with an offset of {{ states.input_number.alarm_1_offset.state }} set to {{ states.sensor.alarm_1_time_minus_offset.state }} Weekdays ({{ states.input_boolean.alarm_1_weekday.state }} ) and Weekends ({{ states.input_boolean.alarm_1_weekend.state }} ) 00:{{ states.input_number.alarm_1_offset.state | int }}:00
service: notify.zchat
- data: {}
service: script.wakeup_dim
- delay: 00:00:02
- service: script.wakeup_bright
- delay: '00:{{ states.input_number.alarm_1_offset.state | int }}:00'
- data: {}
service: script.play_wakeup_music
I modified the automation to allow you to select any day of the week. Code is below if you’re interested.
input_number:
alarm_1_hour:
name: Hours
icon: mdi:timer
initial: 5
min: 0
max: 23
step: 1
alarm_1_minutes:
name: Minutes
icon: mdi:timer
initial: 40
min: 0
max: 59
step: 1
alarm_1_offset:
name: Transition
icon: mdi:blur-linear
initial: 10
min: 0
max: 60
step: 5
input_boolean:
alarm_1_enable:
name: "Enable Alarm"
# initial: on
alarm_1_mon:
name: Monday
# initial: on
icon: mdi:calendar
alarm_1_tue:
name: Tuesday
# initial: on
icon: mdi:calendar
alarm_1_wed:
name: Wednesday
# initial: on
icon: mdi:calendar
alarm_1_thu:
name: Thursday
# initial: on
icon: mdi:calendar
alarm_1_fri:
name: Friday
# initial: on
icon: mdi:calendar
alarm_1_sat:
name: Saturday
# initial: off
icon: mdi:calendar
alarm_1_sun:
name: Sunday
# initial: off
icon: mdi:calendar
sensor:
- platform: time_date
friendly_name: current_time_for_alarm_1
display_options:
- 'time'
- platform: template
sensors:
alarm_1_time:
friendly_name: 'Alarm Time'
value_template: >-
{{ "%0.02d:%0.02d" | format(states("input_number.alarm_1_hour") | int, states("input_number.alarm_1_minutes") | int) }}
- platform: template
sensors:
alarm_1_time_minus_offset:
friendly_name: 'Offset Time'
value_template: >-
{{ '%0.02d:%0.02d' | format( ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset'))| int)/60)| int),(((((((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)) - ((((states('input_number.alarm_1_hour') | int)*60 + (states('input_number.alarm_1_minutes') | int) - (states('input_number.alarm_1_offset')) | int)/60)| int))*100) | int)*60/100) | round) ) }}
group:
alarm_1:
name: Work Alarm
entities:
- input_boolean.alarm_1_enable
- sensor.alarm_1_time
- sensor.alarm_1_time_minus_offset
- input_number.alarm_1_hour
- input_number.alarm_1_minutes
- input_number.alarm_1_offset
- input_boolean.alarm_1_mon
- input_boolean.alarm_1_tue
- input_boolean.alarm_1_wed
- input_boolean.alarm_1_thu
- input_boolean.alarm_1_fri
- input_boolean.alarm_1_sat
- input_boolean.alarm_1_sun
automation:
- id: alarm_1
alias: 'Work Alarm'
trigger:
- platform: time_pattern
minutes: '/1'
seconds: 00
condition:
- condition: template
value_template: "{{ states.sensor.time.state == states.sensor.alarm_1_time_minus_offset.state }}"
- condition: state
entity_id: input_boolean.alarm_1_enable
state: 'on'
- condition: or
conditions:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_mon
state: 'on'
- condition: time
weekday:
- mon
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_tue
state: 'on'
- condition: time
weekday:
- tue
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_wed
state: 'on'
- condition: time
weekday:
- wed
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_thu
state: 'on'
- condition: time
weekday:
- thu
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_fri
state: 'on'
- condition: time
weekday:
- fri
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_sat
state: 'on'
- condition: time
weekday:
- sat
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarm_1_sun
state: 'on'
- condition: time
weekday:
- sun
action:
- data: {}
service: script.bedroom_sunrise
indent preformatted text by 4 spaces
I found my issue, i was using
trigger:
platform: time
minutes: /1
seconds: 0
Rather then
- platform: time_pattern
minutes: /1
seconds: 0
all checks are now passing thanks guys