Trigger When Simplisafe armed

I’m having trouble triggering an Automation when Simplisafe is set to armed. I’ve tried it both with the “armed_away” and “arming” states since arming away puts it in “arming” mode for 1 minute. Here is the automation which turns off all media players when the system is armed away:

alias: Turn off Music when leaving
description: ''
trigger:
  - platform: device
    device_id: <myid>
    domain: alarm_control_panel
    entity_id: alarm_control_panel.<my>_alarm_control_panel
    type: armed_away
condition: []
action:
  - service: media_player.media_stop
    data: {}
    entity_id:
      - media_player.basement_speaker
      - media_player.office_speaker
      - media_player.bathroom
mode: single

I started all 3 media players with the system disarmed and then manually executed the script. It immediately stopped all players, so that part works.

I re-started all 3 players and then armed the system to away (making sure nobody was going to set off the alarm!). I waited until HA updated with Armed Away, but the media players kept right on playing. I waited about 5 minutes, and they were still going. Of note, I received the following error in the logs even though the system armed correctly according to the official app:

2021-01-18 17:25:14 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 119, in _handle_refresh_interval
await self.async_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
update_callback()
File "/usr/src/homeassistant/homeassistant/components/simplisafe/__init__.py", line 684, in _handle_coordinator_update
self.async_update_from_rest_api()
File "/usr/src/homeassistant/homeassistant/components/simplisafe/binary_sensor.py", line 90, in async_update_from_rest_api
self._is_on = self._sensor.triggered
File "/usr/local/lib/python3.8/site-packages/simplipy/sensor/v3.py", line 39, in triggered
return self._system.entity_data[self._serial]["status"].get(
KeyError: '[mykey]'

I also tried it with a state trigger instead:

alias: Turn off Music when leaving
description: ''
trigger:
  - platform: state
    entity_id: alarm_control_panel.<my>_alarm_control_panel
    to: away
condition: []
action:
  - service: media_player.media_stop
    data: {}
    entity_id:
      - media_player.basement_speaker
      - media_player.office_speaker
      - media_player.bathroom
mode: single

Right when I tried it, I experienced another “unable to communicate with Simplisafe” error that is pretty frequent now. It’s too bad because I think the alarm set to away is the best way to know nobody is home, but I can’t rely on simplisafe working. I guess I’ll redo the automation to check for all persons away or something like that.

I was just about to post a similar problem with simplisafe. It appears all states are being recognized as triggers except “armed_away”. If I set my automation to trigger when “arming” that works, but is not exactly what I want since that state is not always recognized before switching to armed.

Also, my automation that triggers when set to “disarmed” also works. It is only the “armed_away” trigger that is not working. Oddly, in the log screen, it correctly shows the state over time as indicated by the attached image:

Mine looks similar except the two “unavailable” states caused by failure to communicate with Simplisafe. I’m not sure if that’s because I was disarming and quickly re-arming a few times in a row, but it makes me want to look elsewhere for home and away triggers since I haven’t been able to count on my connection with Simplisafe since I installed HA last month.

EDIT: Removed image as it has my home address in there. Whoops! I keep meaning to rename that alarm control panel. I guess I will now!

I found a fix/workaround. Instead of triggering on the “device”, I was able to use the “state” instead and it worked!

Change this:

 trigger:
  - platform: device
    device_id: <myID>
    domain: alarm_control_panel
    entity_id: alarm_control_panel.<myAddress>_alarm_control_panel
    type: armed_away

to this

  trigger:
  - platform: state
    entity_id: alarm_control_panel.<myAddress>_alarm_control_panel
    to: armed_away

I hope this helps someone else.

1 Like

You certainly helped me! I was almost there, but using “away” instead of “armed_away.” I updated my automation, and it works as expected.

1 Like