mkanet
(MKANET)
January 23, 2021, 3:19am
32
I’m very bad with yaml. However, I’ve found out that Home Assistant is extremely picky sometimes (for no apparent reason) when it comes to which items are chosen to be preceded by a hyphen in yaml code.
The main difference I see between the code I’m using (below) and the one you’re using is in the sequence… you’re adding a hyphen to - service instead of - data . Try making your code as close to mine as possible by taking off the hyphens from service … and adding hyphens to data instead. Maybe, that’s all that you need to do?
- id: '1598025836523'
alias: 'Back Door open warning: Alexa/Google'
description: Alexa/Google voice message after back door has been open for more than
7 minutes
trigger:
- entity_id: binary_sensor.ecolink_door_window_sensor_sensor_2
for: 00:07:00
from: 'off'
platform: state
to: 'on'
action:
- repeat:
sequence:
- data:
volume_level: 0.7
service: media_player.volume_set
entity_id: media_player.living_room_speaker
- data:
entity_id: media_player.living_room_speaker
message: Please remember to close the back door!
service: tts.google_translate_say
- data:
volume_level: '0.8'
service: media_player.volume_set
entity_id: media_player.kookoo_s_echo_flex
- data:
data:
type: announce
message: Please remember to close the back door!
target:
- media_player.mka_net_echo_dot
- media_player.kookoo_s_echo_flex
service: notify.alexa_media
- delay: 00:02:00
until:
- condition: state
entity_id: binary_sensor.ecolink_door_window_sensor_sensor_2
state: 'off'
mode: single
finity
January 23, 2021, 3:59am
33
Your indentation is off.
look at the example here and make yours look the same.
My indentation is different from the example because I have my configuration split up.
I use different files for automation :
automation: !include ../automations.yaml
automation jja: !include_dir_list ../entities/automations/
Please try using an alert like someone suggested at the top of them thread. The hard work has already been done for you.
Tried it, but unfortunately a new error:
Invalid config for [automation]: extra keys not allowed @ data['action'][0]['repeat']['until'][0]['mode']. Got None must contain at least one of service, service_template. @ data['action'][0]['repeat']['sequence'][0]. Got None must contain at least one of service, service_template. @ data['action'][0]['repeat']['sequence'][1]. Got None. (See ?, line ?).
Tried it, but no luck either.
finity
January 23, 2021, 2:58pm
38
the indentation i was referring to has nothing at all to do with the splitting up of your config.
It has to do with the syntax of the code for the “repeat” section of your automation as you had it posted.
Did you even look at the link I posted?
If you did then you would see that your “repeat” code syntax (indentation) is not the same as the example given there.
Offcourse I looked at the link you posted, but I just couldn’t get it right.
finity
January 23, 2021, 6:23pm
40
action:
- service: media_player.volume_set
data:
entity_id: media_player.keuken
volume_level: 0.8
- alias: herhaal bericht totdat de deur gesloten is
repeat:
# count: '4'
sequence:
- service: tts.google_say
data:
entity_id: media_player.keuken
message: 'Hallo! Graag de deur dicht doen, anders wordt de verwarming uitgeschakeld'
- delay: '00:00:10'
until:
- condition: state
entity_id: binary_sensor.sonoff_keuken_deur_01
state: 'off'
and you also don’t need the “alias” portion in the repeat section. It’s only there as a description for commenting.
action:
- service: media_player.volume_set
data:
entity_id: media_player.keuken
volume_level: 0.8
- repeat:
sequence:
- service: tts.google_say
data:
entity_id: media_player.keuken
message: 'Hallo! Graag de deur dicht doen, anders wordt de verwarming uitgeschakeld'
- delay: '00:00:10'
until:
- condition: state
entity_id: binary_sensor.sonoff_keuken_deur_01
state: 'off'
I also changed “data_template” to “data:” since the “_template” is no longer needed.
And you were missing quotes (') around the “off” state.
1 Like
finity:
action:
- service: media_player.volume_set
data:
entity_id: media_player.keuken
volume_level: 0.8
- repeat:
sequence:
- service: tts.google_say
data:
entity_id: media_player.keuken
message: 'Hallo! Graag de deur dicht doen, anders wordt de verwarming uitgeschakeld'
- delay: '00:00:10'
until:
- condition: state
entity_id: binary_sensor.sonoff_keuken_deur_01
state: 'off'
Thank you!
Seems I haven’t paid attention. You’re my hero!
1 Like
oldmaker
(rosario moggia)
January 1, 2022, 11:57am
42
finity:
Realize tho that once this triggers and starts the count the actions will continue to run for 4 repeats even if the door gets closed in the meatime. That might get annoying. (but maybe that’s the plan so they won’t forget to close the door the next time? )
If that’s not what you want then maybe the alert integration would be better.
Hi.
I have tried your solution. But what is repeated is only the first mp3. The second is only played once.
This is my config:
- id: gg_food_waste
alias: gg_food_waste
trigger:
platform: time
at: '20:00:00'
condition:
condition: time
weekday:
- tue
- thu
- sat
action:
- repeat:
count: 2
sequence:
- data:
entity_id: media_player.gm_mini
volume_level: '0.3'
service: media_player.volume_set
- data:
entity_id: media_player.gm_mini
media_content_id: '/media/local/annunciazione.mp3'
media_content_type: audio/mp3
service: media_player.play_media
- wait_for_trigger:
- platform: state
entity_id: media_player.gm_mini
from: playing
to: idle
timeout:
seconds: 10
- data:
entity_id: media_player.gmini
media_content_id: '/media/local/conf_umido.mp3'
media_content_type: audio/mp3
service: media_player.play_media
mode: single
Any idea? Thanks
finity
January 1, 2022, 5:00pm
43
the automation itself looks OK.
is there anything in the logs or in the automation trace to indicate why it’s failing?
123
(Taras)
January 1, 2022, 5:46pm
44
You are using repeat - count
with two iterations so here’s what that looks like. Steps 1-4 are the first iteration and steps 5-8 are the second one.
Set volume
Play annunciazione
Wait for it to finish
Play conf_umido
Set volume
Play annunciazione
Wait for it to finish
Play conf_umido
Notice how it waits for annunciazione to finish before it proceeds to play conf_umido.
In the second iteration, does it wait for conf_umido to finish playing before it proceeds to set volume and play annunciazione? No.
I suggest you fix that.
1 Like
finity
January 1, 2022, 6:28pm
45
good catch. I missed the lack of delay on the second iteration to wait for the second audio to stop playing.
oldmaker
(rosario moggia)
January 2, 2022, 11:40am
46
Hi for all.
This works:
- id: gg_food_waste
alias: gg_food_waste
trigger:
platform: time
at: '12:37:00'
condition:
condition: time
weekday:
- sun
- thu
- sat
action:
- repeat:
count: 2
sequence:
- data:
entity_id: media_player.gm_mini
volume_level: '0.3'
service: media_player.volume_set
- data:
entity_id: media_player.gm_mini
media_content_id: '/media/local/annunciazione.mp3'
media_content_type: audio/mp3
service: media_player.play_media
- wait_for_trigger:
- platform: state
entity_id: media_player.gm_mini
from: playing
to: idle
timeout:
seconds: 10
- data:
entity_id: media_player.gm_mini
volume_level: '0.3'
service: media_player.volume_set
- data:
entity_id: media_player.gm_mini
media_content_id: '/media/local/conf_umido.mp3'
media_content_type: audio/mp3
service: media_player.play_media
- wait_for_trigger:
- platform: state
entity_id: media_player.gm_mini
from: playing
to: idle
timeout:
seconds: 10
mode: single
123
(Taras)
January 2, 2022, 12:38pm
47
Here’s another way to do the same thing:
- id: gg_food_waste
alias: gg_food_waste
trigger:
- platform: time
at: '12:37:00'
condition:
- condition: time
weekday:
- sun
- thu
- sat
action:
- variables:
media: ['annunciazione','conf_umido']
- repeat:
count: 2
sequence:
- service: media_player.volume_set
target:
entity_id: media_player.gm_mini
data:
volume_level: '0.3'
- service: media_player.play_media
target:
entity_id: media_player.gm_mini
data:
media_content_id: '/media/local/{{ media[repeat.index-1] }}.mp3'
media_content_type: audio/mp3
- wait_for_trigger:
- platform: state
entity_id: media_player.gm_mini
from: playing
to: idle
timeout:
seconds: 10
mode: single
oldmaker
(rosario moggia)
January 2, 2022, 7:21pm
48
Hi taras
This solution is very interesting.
The code is much more compact. When the files to be played are more than one, it is very useful.
Thanks
waank1
(Waank1)
September 14, 2023, 10:11pm
49
Just commenting on an old post, there is a much easier way to do it now if anyone doesn’t know it, reply and I will explain.
nelzo
January 13, 2024, 4:59am
50
Trying to do something similar. Please explain.
waank1
(Waank1)
January 15, 2024, 6:23pm
51
When you are writing your automation in actions, select repeat, select number of times do your task in in the task include a step to wait 90 seconds.