Give people 'sleep' or 'awake' states

I’ve been lurking these forums for a long time now getting really exited about Home Assistant and I’m trying to set something up but I’m not sure about the best way to do this.

My goal is to have home assistant turn off all the lights when me and my wife are both in bed. Currently we both use Tasker to trigger sleep tracking based on a few profiles (time, wifi connected, power ac etc.). What I want is to use tasker to trigger Home Assistant to turn of all the lights, however it should only turn off the lights when the last person goes to bed. When we both add the http post to turn of all the lights the person going to bed last will be in the dark since the first person going to bed already triggered it. Home assistant should only trigger this when we’re both in bed. I’m not sure how to configure this. I was thinking maybe people have besides a ‘home’ state also a ‘sleep’ state, but I have no idea if it is even possible to configure this. And maybe there is a much smarter way to set this up.

3 Likes

I was thinking of creating a input boolean for each of us and make tasker toggle the input boolean on or off as in asleep or awake using HTTP POST. Then run an automation that both have to be on (or asleep) to run the automation.

I’ll leave the changing of the entities as an exercise for the interested student :wink:, but you can declare two input_select’s, one for each of you. Set them to have options like Home, Away, Asleep, etc. Then you can have an automation that triggers when both are Asleep. Something like this:

input_select:
  my_status:
    name: My Status
    options:
      - Home
      - Away
      - Asleep
    icon: mdi:human-male
  wife_status:
    name: Wife Status
    options:
      - Home
      - Away
      - Asleep
    icon: mdi:human-female
automation:
  - alias: Turn off lights
    trigger:
      platform: template
      value_template: >
        {{ is_state('input_select.my_status', 'Asleep') and
           is_state('input_select.wife_status', 'Asleep') }}
    action:
      service: light.turn_off
      entity_id: all
1 Like