Dead man's switch

Hi everybody,

I hope you will excuse my use of a rather morbid title. However I think this could be one of the most important automations in your configuration - that is, if it ever gets triggered.

A dead man’s switch […] is a switch that is automatically operated if the human operator becomes incapacitated, such as through death, loss of consciousness, or being bodily removed from control. Originally applied to switches on a vehicle or machine, it has since come to be used to describe other intangible uses like in computer software. (from Wikipedia)

The purpose is to make your smart home, aware of an accident, like a fall, that have made you unable to move as a result.

To be clear, it’s not likely that you are gonna have a very bad fall in your home, rendering you unconscious or paralyzed - however, in case it happens you will thank yourself for having some code in place that can take action when you can’t.

A couple of years back, a friend of mine was discovered by her boyfriend, laying on her livingroom floor, paralyzed from her neck down. She had fallen in her own apartment, and as a result, had to go through some operations, and 6 month of intense training. She is relatively fine today, still having some issues with finer motor function.

My point here being, taking the boyfriend out of the equation could dramatically have changed the outcome for my friend. This is scary to think about, but it can be really important to have in mind in case something happens. Ask yourself;

  • How often are you expected somewhere?

For me, being a single university student, this is often between 2 or 3 days. And even then, it’s not even sure to curse concern if i don’t show up.

Have a automation running in HA, that registres if there isn’t any movement when there should be, in other words - A dead man’s switch. The automation, once triggered and conditions are met, should run a script that notify others that you might be in need of assistants via. a siren or something like that.

How this is accomplished if of course dependent on your home setup. In my apartment it would make sense to use a combination of: my phones gps coordinates being “home” for x number of hours as a trigger, and the lack of motion for x number of hours as conditions or vise versa. Whatever route you take, time is gonna be important for the condition.

I have removed my initial example in favor for a much more complete one. The system so far consist of 3 entities, 3 automations and 2 scripts, all detailed below


    name: "Dead man's switch"
    initial: off
    icon: mdi:robot
    name: "Manual override"
    initial: off
    icon: mdi:account-check
    name: Override timer
    icon: mdi:timer
    initial: 20
    min: 1
    max: 48
    step: 1
    name: "Emergency"
    - input_boolean.emergency
    - input_boolean.emergency_override
    - input_slider.emergency_override_hours


    ### This is the main DMS automation
    - alias: 'Dead mans switch triggere'
    # It will trigger if the hallway sensor havent seen motion for 14 hours
        platform: state
        entity_id: sensor.bevgelse_i_gang
        from: 'True'
        to: 'False'
          hours: 14
          minutes: 0
          seconds: 0
        condition: and
    # Checks if the override is on
          - condition: state
            entity_id: input_boolean.emergency_override
            state: 'off'
    # Checks if vacation mode is on 
          - condition: state
            entity_id: input_boolean.vacation_mode
            state: 'off'
    # Checks if my phone has been home in over 14 hours
          - condition: state
            entity_id: device_tracker.iphoneGPS
            state: 'Home'
              hours: 14
              minutes: 0
              seconds: 0
    # Runs a script that sends a DMS triggered notification via my telegram bot
        - service: script.turn_on
          entity_id: script.emergency_notify
    # Turns on the DMS itself
        - service: homeassistant.turn_on
          entity_id: input_boolean.emergency

    #### This automation gives me 15 minutes to disable the DMS manually in case of a falls positiv
    - alias: 'Dead mans switch activates 15 minuts after triggering'
        platform: state
        entity_id: input_boolean.emergency
        from: 'off'
        to: 'on'
          hours: 0
          minutes: 15
          seconds: 0
          - service: script.turn_on
          entity_id: script.emergency_alarm_triggerd

    #### This automation vil disable the manual override after x hours if i forget, or on the off chance that something have happend. 
    - alias: 'Dead mans switch override disabled after x hours'
        platform: state
        entity_id: input_boolean.emergency_override
        from: 'off'
        to: 'on'
        - delay: '{{ states.input_slider.emergency_override_hours.state | int }}:00:00'
        - service: homeassistant.turn_off
          entity_id: input_boolean.emergency_override


    - service: notify.Alfred
        message: 'The dead man switch have been triggered, you have 15 minuts to respond before the alarm is activated.'

    - service: notify.Alfred
        message: 'The dead man switch have been activated.'
    ## add lights and sirens goes here

I will be testing this for a week or two before adding actual lights and sirens :slight_smile:

How would you set this up in your home?


Interesting! This is something I will implement as well. I will probably use the device tracker to determine if someone is home and that there hasn’t been any motion throughout the house for several hours (and it’s not night time). In that case, send a push message to everyone in the family, possibly with photos from the surveillance cameras).

My first thought is an emergency alert necklace or phone. However that doesn’t help if someone is unconscious. For this to work there first has to be presence detected in the house and presence detection can be rather tricky. But Assuming that you have an accurate method of detecting presence in the house, if we knew whether events were triggered by an automation (HA, Appdaemon, etc), or by a real world action (someone turning on the light switch), then could we assume that no real world actions for X number of hours and no motion when someone is registered as being home, would be an emergency? Even then, there would have to be some type of warning notification (a text or something) where you could say “No everything is fine, don’t call the ambulance”. This would require a database of daily actions that are learned and adapted over time.

@turboc I agree that this is very reliant on reliable presence detection. I have used the iPhones GPS (via the iCloud component) with great accuracy. However I need to test what happens if the phone runs out of battery and therefor don’t report anything to icloud.

I don’t think that the real-world-activity is hard to determine If you have motion sensors around the house (I use the Philips Hue Motion sensors in 4 rooms). Then it’s more a question of how long no-motion is normal? I might need to combine this with my status (Home, sleeping etc.)

@joch Let me know how you do, I got a feeling that I have to make multiple dead man’s switches, at least on for sleeping mode being excessively long with no activity, and on for being home with no activity. I like the surveillance camera idea, even though i don’t have any jet :slight_smile:

I have added a much more complete example in the original post. I will be testing this in the coming weeks.
Let me know what you think can be improved or what you would do different. :slight_smile:

You might want to consider some way for HA to notify the user and ask “Are you okay?” or something, so that the person this is for can acknowledge they’ve been lazy on the couch for 6 hours and that they aren’t actually unconscious. Kind of a warning alert before alerting external people of a possible problem.


I created a very simple automation to try this out. It notifies all phones in the household group (me and my girlfriend) when at least one of us are at home and not asleep, and there hasn’t been any movement for three hours.

@justyns I agree, this is done in the second (and first) automation - giving myself a heads up and 15 minutes to manually disable the switch :slight_smile:

That being said - the whole point of this is that it should never ever be triggered if it’s not an emergency. I think you need to have a long testing period before hooking this up to anything else then a notification to oneself. This is also why I added the manual override timer. As is now it goes from 1 hour up to 48 hours, honestly I can’t envision a scenario in my life where that would ever be necessary - but better implement it now, I can always scale down later :wink:

Looks great @joch, this is of course very scenario-specific, but 3 hours seems a bit low to me?. However mine is set to 14 hours, because I haven’t yet found a way to automate sleep. I had a look at your config and it seems like you are using the power draw of a plug to determine sleep state? - that’s beautiful - exactly what I need to do myself :smile:

@GigabitGuy thanks, yes I use power draw from the fibaro wall plugs to determine when someone is sleeping. That lets me automate a lot of the lighting. :smile:

Agreed, 3 hours may be a bit on the low side, but I looked at the history of the state in Grafana, and I couldn’t see non-motion for more than two consecutive hours while home and not asleep in my recent history. I’ll probably up it to 4 hours just to be sure to remove any false alarms, and maybe include a motion sensor in the bedroom as well.

Thanks for a great idea! :slight_smile:

@GigabitGuy doh, I didn’t read your example all the way ;). It is a cool idea though, I’ll have to think of some way to integrate something similar into my setup, thanks!

Happy to give something back to the community :smiley:

Just finished testing the manual override timer - it should work as intended.

Brilliant idea, very cool… But for me this would trigger every night when I put my phone on my bed table.Given that I wouldn’t carry my phone with me if I got up in the night, when I’m most likely going to trip over in the dark, this could be a flaw.

If the phone somehow had a way of transmitting “I’m on charge” this would help avoid merely using a “night-time” setting, which would be ineffective for nights I was carrying my phone with me and tripped, for e.g., coming home late at night drunk.

Integration with any number of fitness trackers would be great here, as you would have access to much more movement information and potentially heart rate. I have long thought there has been a market for a good completely open source fitness tracker, but haven’t come across anything yet.

Until the days of medical implants, I can’t see this being incredibly effective, but I’ve loved the thought and the work making the scripts; Cheers!

@wingers1290 that’s exactly what I’m doing. Using a Fibaro wall plug for my chargers, and when they are connected, it’s assumed that I’m sleeping. Using the following binary sensor and then added to the dead man’s switch automation I posted above.

This is absolutely brilliant and almost exactly what I’m looking for, I am quadriplegic and I’m trying to reduce my reliance upon people asking whether I’m okay for them to get that information.

I want them to be able to pick up an iPad, glance at it and be able to see that I’m well, don’t need anything right now and they have no reason to come into my office and interrupt me while I’m working.

This is going to be enormously useful to me!



Hi Stuart,

I’m happy to hear that you see a use case for something like, this in your everyday life. I’m kind of queries, so let me know who you plan on implementing it. Inspiration is key :smiley:


Thank you for the offer of help and yes this is going to be enormously useful when I finally figure out exactly how to use it, it’s got the very beginnings is something I really want to do.

I successfully got it all up and running on my Home Assistant installation, but do you think you could do me a favour and tell me how you would use what you’ve created please?

That is, when I look at the user interface I can see two switches and a slider. How would you go about using them day-to-day would be my question?

Thanks again!

Hi Stuart,

The dead mans switch is the switch itself. It triggers when all the conditions in the first automation is meet (which in my case should be never, you might won’t to make it more sensitiv). When it triggers I am given a warning (on my telegram bot), I then have 15 minutes to intervene if the switch is triggered unintended. This is done by simply turning the dead man switch off before 15 minutes have passed.

The manual override switch is giving the opportunity to override the dead man switch for the amount of hours defined by the override slider. … This functionality is just a comfort - I don’t intent on using it, the only usecase I see for it is if should get very sick and just have to sleep, then It could be useful to make sure the dead man’s switch is not triggered.

The big difference between my original usecase and yours, as I understand it, is that you are going to be using this more actively. In the sense that this should be more sensitive and might react quicker if something goes south? And at the same time it should not be made too paranoid so you get disturbed all the time?

You are very welcome to write some more about how you imagine this could be adopted to your usecase. You can do this either here or PM me, would love to try to come up with something.

This is a great idea. Sorry if I’m chiming in without having read everyone’s comments in great detail.

My first thought on this, is to forget the sirens etc. and to always go with the element of “human trust”, that is to say do something that will get other humans to react.

Email notifications seem the best way to do this. However, just notifying your wife, parents, whatever, might not be adequate.

How about sending emails to 10 people you know, they could be good friends, or just work colleagues whom you trust will get something done.

The key is to send everyone the following information:

  • “this person may need assistance, please call them immediately on the phone to check they are ok”
  • share everyone’s contact details with each other, e.g. your work colleague can call your parents

The biggest problem with this could be “false alarm”. You are the most unreliable person in the equation. Let’s say you are at a concert, your phone is turned off, and there’s a search party out for you with police and distant acquaintances being woken up late at night, etc.

So perhaps a staggered approach is best: email your parents first. They can call your close friend. Your close friend says “it’s ok, I think he is at a concert tonight, I saw it on his facebook”, whatever…

Needs a lot of thought, can be a complex problem, but yes - this is a way that technology could literally save your life, prevent long term brain damage, you name it…

This is a great idea, and I think it’s very important for everyone who stays alone for more than 1 day. Even then, if this switch can be calibrated good enough to react within a few minutes without causing false alarm, it would be great for everyone.

So, some thoughts about how it’s useful and what logic I think is best here. Just laying out my thoughts.

Use cases:

Well. Anything can happen to us. And it’s good if you are in any condition to call 911 (or similar service for your country. But it actually seems that most countries mimick 911 number, by the way :smiley: works in Russia, even though our own main number is 112, alias of 911 works too). And it can happen to all of us, however healthy we are. As simple as tripping in the bathroom, fall, hit your head. Maybe you’ll wake up on your own, good. But what if you hit it badly, and you have 1 hour for medical assistance, or you die? What if you had a stroke, or a pressure spike? It can happen to even the healthiest people, and often hard to predict.

Right now I’m in a situation where my wife left me, and I had a huge stress recently, and my pressure got up, so I even had to call out my work for a week, to rest. And I try to hold my phone with me all the time, but I keep thinking - will I even be able to call it, if something bad happens?

Not so long ago a relative, about 50 years old, just fainted, fell, hitting head on the table. Woke up an hour or two later, in blood, with cat standing and just shouting without pause :smiley: The only dead-man’s switch that triggered. And probably helped with waking up. But it would be much better if some alarm was triggered.

Had another relative, who was… chubby, and got stuck in a narrow bath. Could not get out of it herself. And it so happened, that she was visited often, but at that moment there was a delay of 3 days. 3 days in that bath, only being able to drink water from it. For some time. Only then, by coinsidence, someone finally tried to reach out, and finally forced the door open and came in, and called for help. But that already caused irrevesible damage to old-person’s health, so basically this event triggered the final countdown timer, so to speak… And thinking of it, something as simple as voice-controlled system would help that time. As simple as calling “Hey google, send a message “i need help im stuck, etc” to this contact”.

So. I can go on, but I think there’s enough said for everyone to realise that in theory, I think we all, all people, need such system.

Now about implementation

I think that we should approach it with human side. How would human react to this? Or say - Jarvis :smiley: AI system.

First and important thing, noted by @GigabitGuy , is a warning. False alarms are bad, we all know the story with the boy who alarmed the village with “Wolves” each night, until nobody came when there was real trouble.

So. Mixing how a real person would approach this and what a system should do
1 - Try to call the person, gently, asking if he\she is ok.
Sort of like if you found something lying in an awkwrad pose, first thing is to call their name. This should be done through multiple systems. I would suggest SMS, Pushbullet, WhatsApp, Skype and ideally through some acoustic system at home, with TTS.
Now it gives just a few minutes to respond. I think something like 2 minutes should be enough at this stage.

2 - Try to wake the person up.
Like if in real life you would probably try to shake a person, to wake up. If there’s an audio system at home, I would suggest trying triggering an alarm. Or maybe triggering an alarm on person’s phone. Actualy loud one. It could wake the person up. If it has fitness tracker, it would be perseft to vibrate it or something.
Give 1-2 minutes more to respond

3 - If all that fails, send a warning about triggering an alarm.
I’d say 5 minutes, summing it up to 7-10 minutes for the whole thing. Which is already much, in fact, if a person is in need of immediate assistance. Considering that medics need time to be alerted and arrive as well. But better than nothing.

So, wait 5 more minutes. Optionally it may be time to send some ‘soft’ notification to parents\wife. Closest person or two. Something soft like “Please, try to reach out to this person, it may be in need of assistance. This is just a first-line warning, it may be false alarm. Thank you for your time, etc.”, I’m not that good with english to give the best phrasing here. But it should give a clear indication, that it may be false alarm.

4 - Finally, notify people.
This time the message should be relayed to more people, and sound differently. Like "This person is very likely in need of medical assistance. I could not reach out to him to turn off the dead-man’s switch alarm, this is the final warning. Try to reach out to the person, and if you fail, he may be in need of medical assistance. Last known location - X. Last movement in the house - Y. " and some more information maybe.

So this system has 3 points at which it can be turned off, and 10 minutes to switch it off. 10 minute and 3 pre-alarm notify threshold against false alarms.

It should also have multiple ways of turning it off. I, for example, have a self-written AI\Voice assistant system at home, and it has a skype-bot interface, so I can just write something to skype, like “false alarm”, and it would be able to contact HASS and turn it off.

Now the hardware part.

Clearly, just using prescence detection is not reliable. And not everyone would like to spend money on lots of PIR sensors, or time on setting them up. Using WiFi detection is also not reliable, my wife, for example, turns wifi off at night. With me - turning off detection by scedule is also not a good idea.I often have irregular schedule. Or at least not regular enough for this system to work.

So even a mix of all things discussed would not work for me. It leaves too much windows when something can go wrong and not trigger an alarm.

So I think that the most reliable option here is using fitness tracker with heart rate. This way we could even have multiple layers of alarm. Depending on heartbeat. If there’s no movement - that’s soft alarm. If there’s no heart beat or it gets too irregular or fast, thats another situation. At night sensitivity can be lowered, when the person goes to sleep, but it should still be on. We still move at night, and we still have a heartbeat.

So… I think that it’s actually very important to be able to read data from fitness trackers. Without that, or some similar system, such systems are not reliable, and in most cases they may cause more hassle and trouble, than help. In that case, I would prefer to have a single-click button, like an app on my phone, or an actual button (like Fibaro’s button), which triggers the alarm immediately. So if I feel bad, I will only need to crawl to the button and punch it, then I can faint safely :smiley: