Peleke
(Frederik Niedernolte)
February 27, 2019, 8:48am
1
After an upgrade from HA 0.84 to 0.88 the following automation doesn’t work anymore but I cannot find out why. Can someone with more knowledge/experience help me please to identify the problem?
#Schlummern
- id: schlummern_on
alias: "Schlummern einschalten"
trigger:
platform: state
entity_id: timer.schlummern
to: 'active'
action:
service: media_player.volume_mute
data:
entity_id: media_player.schlafzimmer
is_volume_muted: yes
- id: schlummern_off
alias: "Schlummern ausschalten"
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: 'timer.schlummern'
action:
service: media_player.volume_mute
data:
entity_id: media_player.schlafzimmer
is_volume_muted: no
# Radiowecker
- id: radiowecker_werktags
alias: "Radiowecker werktags"
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: media_player.volume_set
data_template:
entity_id: media_player.schlafzimmer
volume_level: 0.1
- service: tts.google_say
data_template:
entity_id: media_player.schlafzimmer
message: Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}
cache: false
- delay: 00:00:15
- service: media_player.play_media
data_template:
entity_id: media_player.wecker
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/mp3'
- id: radiowecker_wochenende
alias: "Radiowecker am Wochenende"
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: media_player.volume_set
data_template:
entity_id: media_player.schlafzimmer
volume_level: 0.1
- service: tts.google_say
data_template:
entity_id: media_player.schlafzimmer
message: Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}
cache: false
- delay: 00:00:15
- service: media_player.play_media
data_template:
entity_id: media_player.wecker
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/mp3'
Pippyn
February 27, 2019, 8:57am
2
It’s platform: time
it should be time_pattern
the one with the weekday: should not be time_pattern btw
Pippyn
February 27, 2019, 9:02am
3
I would also recommend to add
initial_state: true
to your automations, to make sure they are on when you restart your system. See example
Pippyn
February 27, 2019, 9:13am
4
And another thing; Your wakeup automations are spamming your system. You run these automations every minute. I wouldn’t do that. Add the time sensor and change the trigger to match the wakeup time to the time sensor
Peleke
(Frederik Niedernolte)
February 27, 2019, 9:33am
5
Thanks for the quick reply and support.
I have the wakeups in the automation so that I can change the alarm time dynamically with sliders in the frontend. Don’t know how I could use the time sensor instead.
I changed the automatisations now to this:
#Schlummern
- id: schlummern_on
alias: "Schlummern einschalten"
initial_state: true
trigger:
platform: state
entity_id: timer.schlummern
to: 'active'
action:
service: media_player.volume_mute
data:
entity_id: media_player.schlafzimmer
is_volume_muted: yes
- id: schlummern_off
alias: "Schlummern ausschalten"
initial_state: true
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: 'timer.schlummern'
action:
service: media_player.volume_mute
data:
entity_id: media_player.schlafzimmer
is_volume_muted: no
# Radiowecker
- id: radiowecker_werktags
alias: "Radiowecker werktags"
initial_state: true
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: time
weekday:
- mon
- tue
- wed
- thu
- fri
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.alarm_time.state }}'
action:
- service: media_player.volume_set
data_template:
entity_id: media_player.schlafzimmer
volume_level: 0.1
- service: tts.google_say
data_template:
entity_id: media_player.schlafzimmer
message: Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}
cache: false
- delay: 00:00:15
- service: media_player.play_media
data_template:
entity_id: media_player.wecker
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/mp3'
- id: radiowecker_wochenende
alias: "Radiowecker am Wochenende"
initial_state: true
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: media_player.volume_set
data_template:
entity_id: media_player.schlafzimmer
volume_level: 0.1
- service: tts.google_say
data_template:
entity_id: media_player.schlafzimmer
message: Guten Morgen. Es ist {{now().hour}} Uhr {{now().minute}}
cache: false
- delay: 00:00:15
- service: media_player.play_media
data_template:
entity_id: media_player.wecker
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/mp3'
you mean something like:
trigger:
platform: template
value_template: >
{{ states('sensor.time') ==
(state_attr('input_datetime.sleeptime','timestamp') | int | timestamp_custom('%H:%M', False)) }}
or to make it use a wake-timer:
trigger:
platform: template
value_template: >
{{ states('sensor.time') == states('sensor.alarmclock_we_time_template') }}
I wonder if that would make any significant difference for the spamming as you call it, since it would still trigger every minute?
Pippyn
February 27, 2019, 10:03am
7
Yes, that’s what i mean. First of all; it’s a better practice (cleaner code). Secondly it doens’t check the conditions every minute. Only checks the trigger every minute. With one automation it should affect the system much, but with a couple it could slow everything down.
Pippyn
February 27, 2019, 10:04am
8
Does it work now? Does HA trow any errors?
suppose you’re right, let’s see what happens:
automation:
- alias: Alarm Clock
id: 'Alarm Clock'
initial_state: 'on'
trigger:
- platform: template
value_template: >
{{ states('sensor.time') == states('sensor.alarmclock_we_time_template') }}
- platform: template
value_template: >
{{ states('sensor.time') == states('sensor.alarmclock_wd_time_template') }}
# platform: time
# minutes: '/1'
# seconds: 00
condition:
condition: or
conditions:
- condition: and
conditions:
# - condition: template
# value_template: >
# {{ now().time().strftime("%H:%M") ==
# states('sensor.alarmclock_wd_time_template')}}
- condition: template
value_template: >
{{ is_state('input_boolean.alarmclock_wd_enabled','on')}}
- condition: template
value_template: >
{{ is_state('binary_sensor.workday_sensor','on')}}
- condition: and
conditions:
# - condition: template
# value_template: >
# {{ now().time().strftime("%H:%M") ==
# states('sensor.alarmclock_we_time_template')}}
- condition: template
value_template: >
{{ is_state('input_boolean.alarmclock_we_enabled','on')}}
- condition: template
value_template: >
{{ is_state('binary_sensor.workday_sensor','off')}}
action:
service: script.alarmclock_ring
update
confirmed: this works just fine, hope to see some extra % taken off the processor-usage
1 Like