I have defined a number of automations to control a home alarm system.
A. Alarm Triggered - plays a media file (siren) on media players around the house
B. Alarm disarmed - pauses playback on all media players around the house
C. Turn on alarm using 433Mhz remote - Arms the alarm system
D. Turn off alarm using 433Mhz remote - Disarms the alarm system
The problems I am having are:
- Automation C will often fire once and once only (it is triggered when I press a button on a Sonoff 433MHz remote). If I press the button a second time the automation is not fired again. I can only get it to fire again if I restart HA. Sometimes I can get it to fire more than once in a short period of time, but often not. I use the MQTT console to check for button presses and every press is being registered.
- Automation D will often not fire at all - even though the MQTT console is showing every button press.
- When Automation A has been triggered (and the alarm media files are playing), Automation D (when I can actually get it to run) does not pause the media playback on the media players. It should do this by causing Automation B to fire (Automation B pauses media playback). Even if both D and B fire correctly, the media playback continues until I disarm the alarm manually using the Alarm Panel card in Lovelace. The alarm is actually disarmed when I press the button, but the media keeps playing.
Are the triggers or logic that I’m using inherently unreliable, or is there a flaw in the way I have things defined?
Definitions are below:
Automation A:
- alias: Alarm triggered
trigger:
- platform: state
entity_id: alarm_control_panel.home_alarm
to: triggered
action:
- service: media_player.play_media
target:
entity_id:
- media_player.study_speaker_3
- media_player.lounge_speaker
- media_player.kitchen_speaker_3
data:
media_content_id: http://www.mydomain.com/countdown15s_alarm2m.mp3
media_content_type: audio/mp3
- service: input_boolean.turn_on
data:
entity_id:
- input_boolean.alarm_triggered
id: 387f56544fdd401e9178511f50f7f38b
Automation B:
- alias: Alarm disarmed
trigger:
- platform: state
entity_id: alarm_control_panel.home_alarm
to: disarmed
action:
- service: media_player.media_pause
data:
entity_id: media_player.study_speaker_3
- service: media_player.media_pause
data:
entity_id: media_player.lounge_speaker
- service: media_player.media_pause
data:
entity_id: media_player.kitchen_speaker_3
id: 2eb84bc3ca924bada273d0e1f42e103e
Automation C:
- id: '1630948007972'
alias: Turn on alarm using Sonoff 433MHz remote
description: ''
trigger:
- platform: state
entity_id: binary_sensor.sonoff_433mhz_remote
to: 'on'
condition: []
action:
- service: alarm_control_panel.alarm_arm_away
target:
entity_id: alarm_control_panel.home_alarm
mode: single
Automation D:
alias: Turn off alarm using Sonoff 433MHz remote
description: ''
trigger:
- platform: state
entity_id: binary_sensor.sonoff_433mhz_remote
to: 'off'
condition: []
action:
- service: alarm_control_panel.alarm_disarm
target:
entity_id: alarm_control_panel.home_alarm
mode: single
…and here is the binary_sensor I have defined for the 433MHz remote:
binary_sensor:
#Sonoff 433MHz remote button 1 (top left)
- platform: mqtt
name: "Sonoff 433MHz Remote"
state_topic: "tele/rf-bridge/RESULT"
value_template: '{{value_json.RfReceived.Data}}'
payload_on: "773B78"
payload_off: "773B7C"
qos: 1