Hi. I have 433 sensor connecting through Sonoff RF bridge via MQQT to HASS.IO, and I can see state of test door 1 changing from opened to closed, and I can send test text to google home, but my first automation will not work, tried ever permutation of case I can think of! Can anyone spot what is wrong please?
##Automation number 1
alias: ‘test door 1 to google’
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
from: ‘Closed’
to: ‘Opened’
action:
- service: tts.google_say
data_template:
entity_id: media_player.Living_room_Home
message: “woo hoo its working”
1 - could be formatting, you haven’t posted your code within code tags so we can’t check the indentaion.
2 - are the states (rather than the representiion in the UI) defintely ‘Open’ and ‘Closed’ or could it be in lowercase, or (more likely) ‘on’ and ‘off’
3 - the entity_id in your trigger should be in lowercase
4 - the entity_id for your media player in your action should be in lowercase
5 - I haven’t used google for a while, but is the service not google_translate_say
these days?
6 - is the automation loaded, is it switched on, does the message work if you manually trigger it?
7 - …
Marc you are a star!
Changed to on and off, and to google_translate_say, and it works!
Thank you.
Is there a repository / library anywhere that defines things like google_translate_say and that doors use on and off, bit display opened and closed in the UI?
google_translate_say is the name of the service in the docs for the google tts integration, as here…
For states, ideal is to check the states page under developer tools for the correct states for each entity, but usually it is on/off for anything that is binary
Thanks again.
I’m stuck again, I’m using a door sensor that sends codes for open and closed, and my next step is to trigger on on and off, with different actions. I can only get the code to work on the second trigger / action, and that works with to: ‘on’ or to: ‘off’. Any idea why the first trigger is ignored?
##Automation number 1
alias: 'test door 1 to google opened'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'on'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "door opened"
alias: 'test door 1 to google closed'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'off'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "door closed"
You need hyphens to signify the start of each separate automation…
##Automation number 1
- alias: 'test door 1 to google opened'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'on'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "door opened"
##Automation number 2
- alias: 'test door 1 to google closed'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'off'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "door closed"
Thanks again - that works a treat.
And thanks for the other tips too. A big learning curve for me.
Sorry, me again. Appreciate more re YAML now, and have a better understanding of HASS.IO architecture. But. Latest tests configuration and automation has two two-way door sensors and a PIR. Door 1 automation and PIR automations work great. Door 2 is intermittent. I can see state changes in UI are consistent, but automation for door 2 sporadic. Any ideas please?
##Automation Test_door_1 open
- alias: 'test door 1 to google opened'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'off'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "test door one opened"
##Automation Test_door_1 closed
- alias: 'test door 1 to google closed'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_1
to: 'on'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "test door one closed"
##Automation Test_door_2 open
- alias: 'test door 2 to google opened'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_2
to: 'off'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "test door two opened"
##Automation Test_door_2 closed
- alias: 'test door 1 to google opened'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_door_2
to: 'on'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "test door two closed"
##Automation Test_PIR triggered
- alias: 'test door 1 to google closed'
hide_entity: true
trigger:
- platform: state
entity_id: binary_sensor.Test_PIR
to: 'on'
action:
- service: tts.google_translate_say
data_template:
entity_id: media_player.Living_room_Home
message: "holy crap there is a burglar in the house"
##Reset Test PIR
- alias: 'Reset Test_PIR state'
hide_entity: true
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.Test_PIR
from: 'off'
to: 'on'
for:
seconds: 5
action:
- service: mqtt.publish
data:
topic: tele/longrood/RESULT
payload: "D58E2Eoff"
Not sure, but you’re still mixing case for your entity_ids, should be all lowercase. If it’s triggering sometimes and not others then something is unreliable with the trigger, if it triggers all the time but the action is only firing sometimes and not others then your action is unreliable.
Off the top of my head I can’t see anything that narrows down which it is from your code.
Thanks Marc. Bricked the Pi somehow and have had to start again with fresh install. That will be next weekend, back to the day job now.
Regards
Alan
Hi Marc
Really strange, Pi bricked, didn’t have snapshot, so rebuilt, but did have copies of configuration.yaml and automations.yaml. re-applied these - everything works without any changes.
Does hass.io / Pi have “funnies” like this?
Thanks for your help,
Regards
Alan
Not usually, but possibly it was a symptom of whatever bricked the device.