Skip to content

Instantly share code, notes, and snippets.

@DannyFeliz
Last active June 30, 2023 01:01
Show Gist options
  • Save DannyFeliz/dae286845d76397c241ad7564b2f9f61 to your computer and use it in GitHub Desktop.
Save DannyFeliz/dae286845d76397c241ad7564b2f9f61 to your computer and use it in GitHub Desktop.
alarmo.yaml
blueprint:
name: Alarmo Keypad Sync with nightmode
description: Keypad sync with Alarmo added nightmode
domain: automation
input:
state_topic:
name: MQTT State Topic of your Zigbee2MQTT Keypad
description: "The State Topic is composed of your Zigbee2MQTT base_topic (see your Z2M Addon Configuration) and the Friendly Name of your keypad in Z2M. Example: zigbee2mqtt/Keypad"
selector:
text:
set_topic:
name: MQTT Set Topic of your Zigbee2MQTT Keypad
description: "This is the same as your State Topic, with the addition of /set. Example: zigbee2mqtt/Keypad/set"
selector:
text:
entity:
name: Alarmo entity
description: "An alarm control panel entity from alarmo."
selector:
entity:
domain: alarm_control_panel
integration: alarmo
trigger:
- platform: state
entity_id: !input entity
to: disarmed
id: to_state_disarmed
- platform: state
entity_id: !input entity
to: armed_home
id: to_state_armed_home
- platform: state
entity_id: !input entity
to: armed_night
id: to_state_armed_night
- platform: state
entity_id: !input entity
to: armed_away
id: to_state_armed_away
- platform: state
entity_id: !input entity
to: arming
id: to_state_arming
- platform: state
entity_id: !input entity
to: pending
id: to_state_pending
- platform: state
entity_id: !input entity
to: triggered
id: to_state_triggered
- platform: mqtt
topic: !input state_topic
id: keypad_command
- platform: event
event_type: alarmo_failed_to_arm
id: event_arm_failure
- platform: event
event_type: alarmo_command_success
id: event_command_success
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: to_state_disarmed
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "disarm"
}
}
- conditions:
- condition: trigger
id: to_state_armed_home
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "arm_day_zones"
}
}
- conditions:
- condition: trigger
id: to_state_armed_night
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "arm_night_zones"
}
}
- conditions:
- condition: trigger
id: to_state_armed_away
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "arm_all_zones"
}
}
- conditions:
- condition: trigger
id: to_state_arming
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "exit_delay"
}
}
- conditions:
- condition: trigger
id: to_state_pending
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "entry_delay"
}
}
- conditions:
- condition: trigger
id: to_state_triggered
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"mode": "in_alarm"
}
}
- conditions:
- condition: trigger
id: keypad_command
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.action == "disarm" }}'
sequence:
- service: alarmo.disarm
data:
entity_id: !input entity
code: "{{ trigger.payload_json.action_code }}"
context_id: "{{ trigger.payload_json.action_transaction }}"
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.action == "arm_all_zones" }}'
sequence:
- service: alarmo.arm
data:
entity_id: !input entity
mode: away
code: "{{ trigger.payload_json.action_code }}"
context_id: "{{ trigger.payload_json.action_transaction }}"
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.action == "arm_day_zones" }}'
sequence:
- service: alarmo.arm
data:
entity_id: !input entity
mode: home
code: "{{ trigger.payload_json.action_code }}"
context_id: "{{ trigger.payload_json.action_transaction }}"
- conditions:
- condition: template
value_template: '{{ trigger.payload_json.action == "arm_night_zones" }}'
sequence:
- service: alarmo.arm
data:
entity_id: !input entity
mode: night
code: "{{ trigger.payload_json.action_code }}"
context_id: "{{ trigger.payload_json.action_transaction }}"
- conditions:
- condition: trigger
id: event_arm_failure
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.event.data.reason == 'invalid_code' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "invalid_code"
}
}
- conditions:
- condition: template
value_template: "{{ trigger.event.data.reason == 'open_sensors' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "not_ready"
}
}
- conditions:
- condition: template
value_template: "{{ trigger.event.data.reason == 'not_allowed' }}"
- condition: template
value_template: "{{ trigger.event.data.command|lower == 'disarm' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "already_disarmed"
}
}
- conditions:
- condition: trigger
id: event_command_success
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.event.data.action == 'arm' }}"
- condition: template
value_template: "{{ trigger.event.data.context_id != null }}"
- condition: template
value_template: "{{ trigger.event.data.mode == 'away' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "arm_all_zones"
}
}
- conditions:
- condition: template
value_template: "{{ trigger.event.data.action == 'arm' }}"
- condition: template
value_template: "{{ trigger.event.data.context_id != null }}"
- condition: template
value_template: "{{ trigger.event.data.mode == 'home' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "arm_day_zones"
}
}
- conditions:
- condition: template
value_template: "{{ trigger.event.data.action == 'arm' }}"
- condition: template
value_template: "{{ trigger.event.data.context_id != null }}"
- condition: template
value_template: "{{ trigger.event.data.mode == 'night' }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "arm_night_zones"
}
}
- conditions:
- condition: template
value_template: "{{ trigger.event.data.action == 'disarm' }}"
- condition: template
value_template: "{{ trigger.event.data.context_id != null }}"
sequence:
- service: mqtt.publish
data_template:
topic: !input set_topic
payload: |-
{
"arm_mode":
{
"transaction": {{ trigger.event.data.context_id }},
"mode": "disarm"
}
}
mode: parallel
max: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment