I created a simple “dead man’s switch” automation. It’s a bit dreadful, but Since it’s October (Halloween time) I thought I’d share.
The basic premise is to send myself a notification every day at 12pm noon, asking me to confirm that I’m still alive. If no response is received (if I don’t press a button in Lovelace) in 12 hours, assume the worst and perform some tasks (up to you).
I’m using the Apple iPhone device trackers service, the HA app service, as well as the Google Mail Notifier service.
There are two input_boolean Helpers required, both of type “Toggle”. One for “Dead Man’s Switch” (called dead_mans_switch) which is triggered if there is no response in 12 hours. And the other for “Dead Man’s Switch Confirmation” which is the button that is pressed by the user in Lovelace to tell HA that the user has confirmed. I used the mdi:emoticon-dead icon for the dead_mans_switch, and the mdi:coffin icon for the dead_mans_switch_confirmation. I have the button published to Lovelace as a card.
Here is the Automation YAML with some data replaced by %%{{data}}%% for you to fill-in the blanks:
alias: Dead Man's Switch
description: ""
trigger:
- platform: time
at: "12:00:00"
condition: []
action:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.dead_mans_switch_confirmation
- if:
- condition: state
entity_id: input_boolean.dead_mans_switch
state: "off"
then:
- service: %%{{HA mobile app notifier}}%%
data:
title: Dead Man's Switch
message: Please Confirm You're Alive. You have 12 hours to do so.
- service: %%{{Google mail or related SMTP notifier}}%%
data:
message: >-
Please confirm you're alive. You have 12 hours to do so.
%%{{Insert Home Assistant URL - preferably Nabu Casa Cloud service}}%%
title: Dead Man's Switch
- delay:
hours: 12
minutes: 0
seconds: 0
milliseconds: 0
- if:
- condition: state
entity_id: input_boolean.dead_mans_switch_confirmation
state: "off"
then:
- service: %%{{HA mobile app notifier}}%%
data:
title: Dead Man's Switch
message: >-
NOTICE! Person hasn't responded to the Dead Man's Switch in 12
hours. He might be dead. Contact %%{{phone number of significant other}}%%.
- service: %%{{Google mail or related SMTP notifier}}%%
data:
message: >-
NOTICE! Person hasn't responded to the Dead Man's Switch in 12
hours. He might be dead. Contact %%{{phone number of significant other}}%%. Last known iPhone
location was https://maps.google.com/?q={{
state_attr("%%{{Device Tracker with latitude/longitude}}%%","latitude")
}},{{
state_attr("%%{{Device Tracker with latitude/longitude}}%%","longitude") }}
title: Dead Man's Switch
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.dead_mans_switch
- stop: Person is dead
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.dead_mans_switch_confirmation
- stop: Person is still alive
else:
- stop: Person is already dead
mode: single
Why randomize the time?
And also curious, how could this be accomplished?
Also, I was wondering if it would be possible to use a “confirmable” message so that the user could just click a button when the message was received. I tried this but it didn’t work - the standard message was delivered.
I am curious on next steps? Which actions do you take if there is no response?
One warning: you might have external connection issues with home assistant and cannot respond on timely manner and dead man’s switch could be triggered pay attention
There could be outages any time on any service (duck dns, nabucasa, aws, google/apple notification services)
As of now, I have no actions set. But, it could be an email to a significant other with additional information (i.e., Last Will & Testament, lawyer contact info, special instructions on where to go to get info on accounts & passwords, etc.) Not that she doesn’t have this info already, but it might not be readily available.
Yes, warning heeded regarding external connections. This is why I’m giving myself 12 hours to respond. I may also provide a means to respond via email, just in case something goes awry with internet connectivity or any of the related cloud-based services. Good points.
I added a few updates to this automation including:
Sending an actionable notification to the HA iPhone app, so that it’s easier to confirm alive.
Waiting for a trigger with a 12 hour timeout. The trigger is that the user presses “Confirm Alive” in the iPhone app notification. If the trigger is received, set the DMS Confirmation input boolean toggle switch ON, or continuing on if the trigger is not received.
Adding some phone numbers to the “User hasn’t responded in 12 hours” iPhone notification, for easier calling.
Updated Automation YAML below:
alias: Dead Man's Switch
description: ""
trigger:
- platform: time
at: "12:00:00"
condition: []
action:
- variables:
turn_on_dmsc: "{{ 'TURN_ON_DMSC_' ~ context.id }}"
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.dead_mans_switch_confirmation
- if:
- condition: state
entity_id: input_boolean.dead_mans_switch
state: "off"
then:
- service: notify.google_mail_notifier
data:
message: >-
Please confirm you're alive. You have 12 hours to do so.
%%{{ URL to HA }}%%
title: Dead Man's Switch
- service: notify.mobile_app_%%{{ name of mobile app }}%%
data:
title: Dead Man's Switch
message: Please Confirm You're Alive. You have 12 hours to do so.
data:
actions:
- action: "{{ turn_on_dmsc }}"
title: Confirm Alive
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ turn_on_dmsc }}"
context: {}
timeout:
hours: 12
minutes: 0
seconds: 0
milliseconds: 0
- if:
- condition: template
value_template: "{{ wait.trigger.event.data.action == turn_on_dmsc }}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.dead_mans_switch_confirmation
- if:
- condition: state
entity_id: input_boolean.dead_mans_switch_confirmation
state: "off"
then:
- service: notify.mobile_app_%%{{ name of mobile app }}%%
data:
title: Dead Man's Switch
message: >-
NOTICE! Person hasn't responded to the Dead Man's Switch in 12
hours. He might be dead. Contact %%{{ phone number of significant other }}%%.
data:
actions:
- action: CALL_WIFE
title: Call Wife
uri: tel:%%{{ phone number of significant other }}%%
- action: CALL_911
title: Call 911
uri: tel:911
- service: notify.google_mail_notifier
data:
message: >-
NOTICE! Person hasn't responded to the Dead Man's Switch in 12
hours. He might be dead. Contact %%{{ phone number of significant other }}%%. Last known iPhone
location was https://maps.google.com/?q={{
state_attr("device_tracker.%%{{ name of iPhone }}%%","latitude")
}},{{
state_attr("device_tracker.%%{{ name of iPhone }}%%","longitude") }}
title: Dead Man's Switch
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.dead_mans_switch
- stop: Person is dead
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.dead_mans_switch_confirmation
- service: notify.mobile_app_%%{{ name of mobile app }}%%
data:
message: Person is Still Alive
title: Dead Man's Switch
- stop: Person is still alive
else:
- stop: Person is already dead
mode: single
I use something like this but based on a time trigger with a location condition. If not at a certain place at a certain time after I’ve gone riding my bicycle, a high priority emergency alarm goes to my wife.