---
blueprint:
name: AWTRIX 🚪️ Door Status Monitor 🔍️
description: >
This blueprint is designed to monitor the status of a door (or any other contact sensor)
displaying alerts when the status changeas as well as tracking the time a specific door has been open.
It works with **binary_sensor** and **cover** entities.. (I think)
Generally it will track 4 different states:
- `opened`: When the door opens
- `is_opened`: How long a door has been ajar
- `closed`: When a door closes
- `error`: Any error associated with the sensor
domain: automation
input:
awtrix:
name: AWTRIX Device
description: Select the Awtrix light
selector:
device:
filter:
integration: mqtt
manufacturer: Blueforcer
model: AWTRIX 3
multiple: true
app_name:
name: Awtrix Applicaiton name
description: This is the app name listed in the MQTT topic - it should be unique
selector:
text:
default: door_monitor
trigger_sensor:
name: Door Sensor
description: Binary sensor to track door status
selector:
entity:
filter:
domain:
- binary_sensor
- input_boolean
- cover
open_text:
name: 📝 Device Opened Message
description: Text to be displayed when an open event occurs
selector:
text:
default: "open"
is_open_text:
name: 📝 Device Remained Open Message
selector:
text:
default: ""
description: >
The default is to show just an icon and a time-display - if you add text here it will be appended to the message
close_text:
name: 📝 Device Closed Message
description: This text will be displayed along with the close icon
selector:
text:
default: "close"
error_text:
name: 📝 Error Message
description: Display text with error icon
selector:
text:
default: "error"
open_sound:
name: 🔊️ Open Notification Sound
description: >-
An RTTL sound to play when the door opens. I personally use:
short:d=4,o=5,b=100:16e6
Leave this blank if you don't want a sound
selector:
text:
default: "short:d=4,o=5,b=100:16e6"
close_sound:
name: 🔊️ Closing sound for Notification
description: >
An RTTL to play upon door closing. I personally use:
two_short:d=4,o=5,b=100:16e6,16e6
Leave this blank if you don't want a sound
selector:
text:
default: "two_short:d=4,o=5,b=100:16e6,16e6"
error_sound:
name: 🔊️ Sound for initial error Notification
description: >
An RTTL Sound to play upon door closing. I personally use:
sms:d=4,o=5,b=45:32d,32g#,32d,32f,32c#,32e
Leave this blank if you don't want a sound
selector:
text:
default: "sms:d=4,o=5,b=45:32d,32g#,32d,32f,32c#,32e"
quiet_time_start:
name: Quiet time
description: >
Quiet time start/stop
selector:
time:
default: "00:00:00"
quiet_time_end:
name: Quiet time
description: >
Quiet time start/stop
selector:
time:
default: "00:00:00"
icon_set:
name: Icon Set
description: >-
Here you can select from various "pre-defined" icon sets. Alternatively you can select `custom` if you wish to use your own icons.
The quickest way to get these icons is to run this script:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/jeeftor/HomeAssistant/master/icons/upload_icon.sh)"
This script will download the icon set you desire from GitHub and upload it to your clock
Icon's themselves are named:
### Front Door




`front_door_open.gif`,`front_door_is_open.gif` `front_door_close.gif` `front_door_error.gif`
### Sliding Door




`sliding_door_open.gif`,`sliding_door_is_open.gif` `sliding_door_close.gif` `sliding_door_error.gif`
### Shed/House




`house_shed_open.gif`,`house_shed_is_open.gif` `house_shed_close.gif` `house_shed_error.gif`
### Window




`window_open.gif`,`window_is_open.gif` `window_close.gif` `window_error.gif`
### Garage




`garage_open.gif`,`garage_is_open.gif` `garage_close.gif` `garage_error.gif`
### Blinds
(Images are blurry because they are resized)
`blinds_open.gif`,`blinds_is_open.gif` `blinds_close.gif` `blinds_error.gif`
# CUSTOM ICONS BELOW
The icon settings below only will take effect if you've selected custom
selector:
select:
options:
- label: Front Door
value: front_door
- label: Sliding Door
value: sliding_door
- label: House Shed
value: house_shed
- label: Garage Door
value: garage
- label: Window
value: window
- label: Blinds
value: blinds
- label: Use Custom icons
value: custom
default: custom
custom_open_icon:
name: CUSTOM Open icon
description: >
Icon to show on Door Open notification (usually animated).
The Here are some examples I use:
-  `53195` - Sliding Door Open
-  `53234` - House/Shed door opening
-  `53266` - Front Door opening
-  `23103` - Window opening
selector:
text:
default: "custom_open"
custom_is_open_icon:
name: CUSTOM Is-Open Icon
description: >
Icon to show for door remaining open
-  `53201` - Sliding Door is Open
-  `53236` - House/Shed door is open
-  `53267` - Front door is open
-  `53290` - Window is open
selector:
text:
default: "custom_is_open"
custom_close_icon:
name: CUSTOM Close icon
description: >
Icon to show for door closing notification
Here are some examples I use:
-  `53197` - Sliding Door Close
-  `53235` - House/Shed Door Close
-  `53265` - Front Door Close
-  `23104` - Window Close
selector:
text:
default: "custom_close"
custom_error_icon:
name: CUSTOM Error Icon
description: >
Icon to show if the state of the sensor is an unknown state. If you are running an MQTT sensor this could
indicate the server is down or the sensor dropped off your network.
Here are some examples I use:
-  `53227` - Sliding Door Error
-  `53237` - House/shed Error
-  `53268` - Front Door Error
-  `53291` - Window Error
selector:
text:
default: "custom_error"
mode: queued
max: 10
variables:
qt_start: !input quiet_time_start
qt_end: !input quiet_time_end
mute: "{{ iif(qt_start > qt_end, not (today_at(qt_end) < now() < today_at(qt_start)),today_at(qt_start) < now() < today_at(qt_end)) }}"
device_ids: !input awtrix
app_topic: !input app_name
message_topics: >-
{%- macro get_device_topic(device_id) %}
{{ states((device_entities(device_id) | select('search','device_topic') | list)[0]) }}
{%- endmacro %}
{%- set ns = namespace(devices=[]) %}
{%- for device_id in device_ids %}
{%- set device=get_device_topic(device_id)|replace(' ','') %}
{% set ns.devices = ns.devices + [ device ~ '/custom/' ~ 'jeef_' ~ app_topic] %}
{%- endfor %}
{{ ns.devices | reject('match','unavailable') | list}}
notification_topics: >-
{%- macro get_device_topic(device_id) %}
{{ states((device_entities(device_id) | select('search','device_topic') | list)[0]) }}
{%- endmacro %}
{%- set ns = namespace(devices=[]) %}
{%- for device_id in device_ids %}
{%- set device=get_device_topic(device_id)|replace(' ','') %}
{% set ns.devices = ns.devices + [ device ~ '/notify'] %}
{%- endfor %}
{{ ns.devices | reject('match','unavailable') | list}}
trigger_sensor: !input trigger_sensor
last_change_seconds: "{{ as_timestamp(now()) - as_timestamp(states[trigger_sensor].last_changed | default(0)) }}"
last_changed_str: "{{relative_time(states[trigger_sensor].last_changed
| default(0))
| replace('hours','hr')
| replace('hour','hr')
| replace('seconds','sec')
| replace('minutes','min')
| replace('minute','min')}}"
icon_set: !input icon_set
custom_open_icon: !input custom_open_icon
custom_is_open_icon: !input custom_is_open_icon
custom_close_icon: !input custom_close_icon
custom_error_icon: !input custom_error_icon
# Open icon
open_icon: "{{iif(icon_set == 'custom', custom_open_icon ,icon_set ~ '_open')}}"
open_text: !input open_text
open_sound: !input open_sound
is_open_icon: "{{iif(icon_set == 'custom', custom_is_open_icon ,icon_set ~ '_is_open')}}"
is_open_text: !input is_open_text
# If we have open text then add it and a space to the end of the last_changed_str message
is_open_message: "{{iif(open_text,last_changed_str,[last_changed_str,open_text]|join(' '))}}"
close_icon: "{{iif(icon_set == 'custom', custom_close_icon ,icon_set ~ '_close')}}"
close_text: !input close_text
close_sound: !input close_sound
error_icon: "{{iif(icon_set == 'custom', custom_error_icon ,icon_set ~ '_error')}}"
error_text: !input error_text
error_sound: !input error_sound
open_payload: >-
{"text":"{{open_text}}", "icon":"{{open_icon}}", "rtttl":"{{iif(mute,'',open_sound)}}"}
close_payload: >-
{"text":"{{close_text}}", "icon":"{{close_icon}}", "rtttl":"{{iif(mute,'',close_sound)}}"}
is_open_payload: >-
{"text": "{{is_open_message}}", "icon":"{{is_open_icon}}"}
error_message_payload: >-
{"text": "{{error_text}}", "icon":"{{error_icon}}", "color":"#FFFF00"}
error_alert_payload: >-
{"text": "{{error_text}}", "icon":"{{error_icon}}", "color":"#FFFF00", "rtttl":"{{iif(mute,'',error_sound)}}"}
trigger_variables:
trigger_sensor: !input trigger_sensor
trigger:
- trigger: time_pattern
minutes: /1
id: time
- trigger: template
id: opened
value_template: "{{ states(trigger_sensor) in ['on', 'open'] }}"
- trigger: template
value_template: "{{ states(trigger_sensor) in ['closed','off'] }}"
id: closed
- trigger: template
value_template: "{{ states(trigger_sensor) not in ['off','on', 'open','closed', 'closing', 'opening'] }}"
id: error
condition: []
action:
- choose:
# Time update and door is still open
- conditions:
- and:
- condition: trigger
id: time
- condition: template
value_template: "{{ states(trigger_sensor) in ['on', 'open'] }}"
- condition: template
value_template: "{{ last_change_seconds > 60 }}"
sequence:
- repeat:
for_each: "{{ message_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: "{{is_open_payload}}"
# Fix an issue with a lingering close state after reboot
- conditions:
- and:
- condition: trigger
id: time
- condition: template
value_template: "{{ states(trigger_sensor) in ['off', 'closed'] }}"
sequence:
- repeat:
for_each: "{{ message_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: "{}"
# Door open logic (Notification + message)
- conditions:
- condition: trigger
id: opened
sequence:
- repeat:
for_each: "{{ notification_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: >
{{open_payload}}
# Door Close Logic
- conditions:
- condition: trigger
id: closed
sequence:
- repeat:
for_each: "{{ notification_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: >
{{close_payload}}
- repeat:
for_each: "{{ message_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: "{}"
# Door error status
- conditions:
- condition: trigger
id: error
sequence:
- repeat:
for_each: "{{ notification_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: >
{{error_alert_payload}}
- repeat:
for_each: "{{ message_topics }}"
sequence:
- action: mqtt.publish
data:
qos: 0
retain: false
topic: "{{ repeat.item }}"
payload: >
{{error_alert_payload}}