Hi !
I’m trying to create an automation wich recognize a pin code when I press buttons of my 4-button switch in a specific order.
The purpose is to be able ton stop my system alarm alert by pressing a combination of buttons on my switch.
My idea is to keep track of buttons I push in an input_text.
And to be able to know if it worked when I pushed a button, I want my Google Home to say something.
So, just for the beginning of my combination, with just button 1 (state 1_single) and button 2 (state 2_single), here is my conf :
- alias: "Button 1"
trigger:
- platform: state
entity_id: sensor.switch_alert_action
to: '1_single'
action:
- delay: "00:00:01"
- service: input_text.set_value
target:
entity_id: input_text.alert_sequence
data:
value: "1"
- service: tts.speak
data:
cache: true
media_player_entity_id: media_player.musique_salon
message: "Button one"
language: fr
target:
entity_id: tts.google_en_com
- alias: "Button 2 after 1"
trigger:
- platform: state
entity_id: sensor.switch_alert_action
to: '2_single'
condition:
- condition: template
value_template: "{{ states('input_text.alert_sequence') == '1' }}"
action:
- delay: "00:00:01"
- service: input_text.set_value
target:
entity_id: input_text.alert_sequence
data:
value: "{{ states('input_text.alert_sequence') + '2' }}"
- service: tts.speak
data:
cache: true
media_player_entity_id: media_player.musique_salon
message: "Button two after one"
language: fr
target:
entity_id: tts.google_en_com
- alias: "Button 2 not after 1"
trigger:
- platform: state
entity_id: sensor.switch_alert_action
to: '2_single'
condition:
- condition: template
value_template: "{{ states('input_text.alert_sequence') != '1' }}"
action:
- delay: "00:00:01"
- service: input_text.set_value
target:
entity_id: input_text.alert_sequence
data:
value: ""
- service: tts.speak
data:
cache: true
media_player_entity_id: media_player.musique_salon
message: "Button two not after one"
language: fr
target:
entity_id: tts.google_en_com
It almost work… only problem is, when I push button 2 after button 1, I know it triggers the “Button 2 after 1” automation because input_text.alert_sequence get “12” as value, but my Google Home doesn’t say “Button two after one”.
Whereas when I push button 2 when I already pushed button 2, input_text.alert_sequence take “” as value and Google Home says “Button two not after one”.
I really don’t understand why the - service: tts.speak works for one automation and not for the other.