User story: We live in central Florida and have a nice pond in our backyard. Wifey loves to spend her mornings drinking coffee looking out over the pond while watching the ducks, egrets and baby alligator who call it home. This usually results in me – an hour later with the air conditioner running full blast – to “lovingly” remind her to turn off the air conditioner next time. Automatically turning off the air conditioner when we open the back door was her “killer feature” that sold her on letting me tinker around with HA.
So, the problem was how to read that the back door was open. Sure, a ZWave sensor would do it, but we also already have an Alarm.com alarm system with a sensor on the back door. So why have two things when just one will do it.
The Alarm.com integration is great at arming/disarming – and I was already using it in several other integrations. In the Developer States page, I could see that opening the backdoor resulted in a state change with “sensor_status: Z6 SLIDERS is open.”
How to get this piece of data into something that could turn off the air conditioner so Wifey could enjoy both the pond and her coffee?
[NOTE: May 12, 2019 update. See the end of this post for a more elegant solution using the template
sensor platform.
Ingredients:
- Alarm.com alarm system
- Ecobee thermostat
- Input_select custom field
- Input_text custom field
I ended up writing my own automation that triggers on any state change to the alarm_control_panel.alarm_com object. Then, using a Jinga regex filter, I parsed the sensor_state for the important events to be kept in “input_select.backdoor”.
- id: '12345'
alias: Alarm - State Change Decoder
trigger:
- entity_id: alarm_control_panel.alarm_com
platform: state
condition: []
action:
- service: input_select.select_option
data_template:
entity_id: input_select.backdoor
option: "{% if state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('Z6\
\ SLIDERS is Open', ignorecase=TRUE) %}\n open\n{% else %}\n closed\n{%\
\ endif %}\n"
For readability, the Jinga part is written out below with some whitespace:
{% if state_attr('alarm_control_panel.alarm_com', 'sensor_status')|regex_search('Z6 SLIDERS is Open', ignorecase=TRUE) %}
open
{% else %}
closed
{% endif %}
Then, a second automation watches “input_select.backdoor” for a state change. After 5 minutes of being open, it will save the state of the Ecobee thermostat – in “input_text.ecobee_mode” and turn it off. A third automation watches for the door to close again and restores the original state of the thermostat.
You know what they say – happy wife, happy life. She’s out there enjoying her coffee right now as I write this out. She’s named the baby alligator “Arlo” – he just showed up a few weeks ago and is, I imagine, a terror to frogs and small fish everywhere.