I also would like to know. As google home mini need to be already on or in standby mode to play spotify music. Currently, I use with alexa.
Does Amazon echo works differently than Google home?
Are you able to cast audio from Spotify to echo always even if the echo is not in “Spotify mode”?
Yes. with alexa I can cast audio from spotify. The status from ha for media_player.alexa is always show standby. but media_player.google always off.
Ok thanks. Pretty disappointed from the Google home.
is it possible to show the time until the alarm?
do you have some example? thanks
I’m using your code but it does not work I can not understand where I’m wrong
can you help me?
Thank you
**Automations.yaml**
- alias: 'Wake Me Up'
trigger:
- platform: time_pattern
minutes: '/1'
seconds: 0
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
- sat
- condition: template
value_template: '{{ now().time().strftime("%R") == states.sensor.alarm_time.state }}'
- condition: and
conditions:
- condition: state
entity_id: input_boolean.alarmstatus
state: 'on'
- condition: state
entity_id: input_boolean.alarmweekday
state: 'off'
- condition: template
value_template: '{{ now().time().strftime("%R") == states.sensor.alarm_time.state }}'
action:
- service: notify.mypushbullet
data:
title: "Alarm"
message: "Good morning Sir. Time to Wake Up!"
- service: switch.turn_on
entity_id: switch.luce_principale
- alias: Turn off Alarm
trigger:
- platform: time_pattern
minutes: '/1'
seconds: 0
condition:
- condition: template
value_template: '{{ now().time().strftime("%R") == states.sensor.alarm_time_fin.state }}'
action:
- service: switch.turn_off
entity_id: switch.luce_principale
**Configuration.yaml**
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 0
longitude: 0
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 0
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Europe/Rome
# Customization file
# customize: !include customize.yaml
# Show links to resources in log and frontend
introduction:
# Enables the frontend
frontend:
# Enables configuration UI
config:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
# https://home-assistant.io/blog/2016/10/25/explaining-the-updater/
updater:
# Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true
# Discover some devices automatically
discovery:
# Allows you to issue voice commands from the frontend in enabled browsers
conversation:
# Enables support for tracking state changes over time
history:
# View all events in a logbook
logbook:
# Enables a map showing the location of tracked devices
map:
# Track the sun
sun:
# Allow diagnosing system problems
system_health:
# Sensors
#sensor:
# Weather prediction
# - platform
sensor:
- platform: dht
sensor: DHT11
pin: 24
monitored_conditions:
- temperature
- humidity
- platform: template
sensors:
alarm_hour:
# friendly_name: 'Hour'
value_template: '{{ states("input_number.alarmhour") | round(0) }}'
alarm_minutes:
# friendly_name: 'Minutes'
value_template: '{{ states("input_number.alarmmins") | round(0) }}'
alarm_time:
friendly_name: 'Time'
value_template: '{% if states("sensor.alarm_hour")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hour") }}:{% if states("sensor.alarm_minutes")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutes") }}'
alarm_hour_fin:
# friendly_name: 'FinHour'
value_template: '{{ states("input_number.alarmfinishhr") | round(0) }}'
alarm_minutes_fin:
# friendly_name: 'FinMinutes'
value_template: '{{ states("input_number.alarmfinishmins") | round(0) }}'
alarm_time_fin:
# friendly_name: 'FinTime'
value_template: '{% if states("sensor.alarm_hour_fin")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hour_fin") }}:{% if states("sensor.alarm_minutes_fin")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutes_fin") }}'
switch:
- platform: rpi_gpio
ports:
11: luce principale
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
# Text to speech
tts:
- platform: google
# Cloud
cloud:
group: !include groups.yaml
automation: !include automations.yaml
input_boolean: !include input_booleans.yaml
#script: !include scripts.yaml
**groups.yaml**
alarmclock:
name: Wake Me Up
#view: yes
entities:
- sensor.alarm_time
- input_number.alarmhour
- input_number.alarmmins
- input_boolean.alarmstatus
- input_boolean.alarmweekday
- sensor.alarm_time_fin
- input_number.alarmfinishhr
- input_number.alarmfinishmins
- sensor.dht_sensor_humidity
- sensor.dht_sensor_temperature
- switch.luce_principale
alrmclock:
name: Wake Me Up!
view: yes
entities:
- group.alarmclock
**Input_booleans.yaml**
alarmstatus:
name: Wake Me Up
initial: on
icon: mdi:alarm-check
alarmweekday:
name: Weekdays Only
initial: on
icon: mdi:calendar
It looks like you aren’t using the sensors correctly…
mine looks like this after a recent update…
- platform: template
sensors:
alarm_hour:
# friendly_name: 'Hour'
entity_id: input_number.alarmhour
value_template: '{{ states("input_number.alarmhour") | round(0) }}'
alarm_minutes:
# friendly_name: 'Minutes'
entity_id: input_number.alarmmins
value_template: '{{ states("input_number.alarmmins") | round(0) }}'
alarm_time:
friendly_name: 'Time'
entity_id:
- sensor.alarm_hour
- sensor.alarm_minutes
value_template: '{% if states("sensor.alarm_hour")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hour") }}:{% if states("sensor.alarm_minutes")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutes") }}'
alarm_hour_fin:
# friendly_name: 'FinHour'
entity_id: input_number.alarmfinishhr
value_template: '{{ states("input_number.alarmfinishhr") | round(0) }}'
alarm_minutes_fin:
# friendly_name: 'FinMinutes'
entity_id: input_number.alarmfinishmins
value_template: '{{ states("input_number.alarmfinishmins") | round(0) }}'
alarm_time_fin:
friendly_name: 'FinTime'
entity_id:
- sensor.alarm_hour_fin
- sensor.alarm_minutes_fin
value_template: '{% if states("sensor.alarm_hour_fin")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hour_fin") }}:{% if states("sensor.alarm_minutes_fin")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutes_fin") }}'
alarm_hoursat:
# friendly_name: 'Hoursat'
entity_id: input_number.alarmhoursat
value_template: '{{ states("input_number.alarmhoursat") | round(0) }}'
alarm_minutessat:
# friendly_name: 'Minutessat'
entity_id: input_number.alarmminssat
value_template: '{{ states("input_number.alarmminssat") | round(0) }}'
alarm_timesat:
friendly_name: 'Timesat'
entity_id:
- sensor.alarm_hoursat
- sensor.alarm_minutessat
value_template: '{% if states("sensor.alarm_hoursat")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hoursat") }}:{% if states("sensor.alarm_minutessat")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutessat") }}'
alarm_hour_finsat:
# friendly_name: 'FinHour'sat
entity_id: input_number.alarmfinishhrsat
value_template: '{{ states("input_number.alarmfinishhrsat") | round(0) }}'
alarm_minutes_finsat:
# friendly_name: 'FinMinutessat'
entity_id: input_number.alarmfinishminssat
value_template: '{{ states("input_number.alarmfinishminssat") | round(0) }}'
alarm_time_finsat:
entity_id:
- sensor.alarm_hour_finsat
- sensor.alarm_minutes_finsat
friendly_name: 'FinTimesat'
value_template: '{% if states("sensor.alarm_hour_finsat")|length == 1 %}0{% endif %}{{ states("sensor.alarm_hour_finsat") }}:{% if states("sensor.alarm_minutes_finsat")|length == 1 %}0{% endif %}{{ states("sensor.alarm_minutes_finsat") }}'
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 I also have an echo spot in the Bedroom, but a dot will work just as well.
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):
I hope this helps anyone who needs it!
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
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
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
i have been tryin this for almost a week with not any luck
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 }}'
Thank you, the “big problem” was that i havent enabled the sensor.time.
So happy that everything now works fine.