Skip to content

Instantly share code, notes, and snippets.

@smarthomehobby
Created July 29, 2018 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarthomehobby/6180a62b9d46214d2eea17d4400c5ee1 to your computer and use it in GitHub Desktop.
Save smarthomehobby/6180a62b9d46214d2eea17d4400c5ee1 to your computer and use it in GitHub Desktop.
# In the configuration.yaml file, use the input_select component
input_select:
front_door_alarm:
name: Front Door Alarm
options:
- "Unarmed"
- "Armed: Silent"
- "Armed"
- "Armed: Alarm and Notification"
- "Silence"
# These scripts perform the actions I want the different options to make.
# Put these in the scripts.yaml file
door_alarm:
alias: "Armed"
sequence:
- service: xiaomi_aqara.play_ringtone
data:
gw_mac: your_gateway_mac
ringtone_id: 2
door_alarm_silent:
alias: "Armed: Silent"
sequence:
- service: ifttt.trigger
data: {"event":"text_notification", "value1":"The Font Door Slient Alarm has been triggered."}
alarm_and_notification:
alias: Alarm and Notification
sequence:
- service: xiaomi_aqara.play_ringtone
data:
gw_mac: your_gateway_mac
ringtone_id: 2
- service: ifttt.trigger
data: {"event":"text_notification", "value1":"The Font Door Alarm has been triggered."}
silence_alarm:
alias: Disarm/Silence Alarm
sequence:
- service: xiaomi_aqara.stop_ringtone
data:
gw_mac: your_gateway_mac
- service: input_select.select_option
data:
entity_id: input_select.front_door_alarm
option: "Unarmed"
# Now, an automation to tie it all together.
# Every time the door opens, this automation is triggered.
# This goes in automations.yaml
- id: front_door_alarm
alias: Front Door Alarm
initial_state: 'on'
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0001ab56bd
from: 'off'
to: 'on'
action:
- service: homeassistant.turn_on
data_template:
entity_id: >
{% if is_state("input_select.front_door_alarm", "Armed: Silent") %}
script.door_alarm_silent
{%-elif is_state("input_select.front_door_alarm", "Armed") %}
script.door_alarm
{%-elif is_state("input_select.front_door_alarm", "Armed: Alarm and Notification") %}
script.alarm_and_notification
{%-elif is_state("input_select.front_door_alarm", "Unarmed") %}
none
{% else %}
none
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment