Detect when we go to sleep

Hello!

I’ll give it a try. I’m curious to see if the forum is better than AI. I’ve had quite a bit of practice with AI.

We have an automation that detects when we charge both cell phones and it is later than a certain time. This indicates that we are going to sleep. Then a group of lights on the ground floor is turned off.

After a while, we noticed that the automation doesn’t work if one cell phone shuts down in the evening because the battery is empty.

So here’s my idea:

  • HA remembers that the person has come home

  • assumes that they are still at home, even if the cell phone is unreachable

This way, the automation would also trigger if only one cell phone is charging and the other is unreachable, provided that it was present before.

After all, it is very unlikely that someone would leave the house at night without a charged cell phone.

I couldn’t get it to work. Neither could AI.

Thank you.

alias: Lichter Parterre aus wenn beide Mobile laden
description: ""
triggers:
  - entity_id: sensor.sm_s9080_charger_type
    to: ac
    for:
      minutes: 2
    trigger: state
  - entity_id: sensor.sm_s9010_charger_type
    to: ac
    for:
      minutes: 2
    trigger: state
conditions:
  - condition: template
    value_template: |
      {{ states('sensor.sm_s9080_charger_type') in ['ac', 'usb'] }}
  - condition: template
    value_template: |
      {{ states('sensor.sm_s9010_charger_type') in ['ac', 'usb'] }}
  - condition: state
    entity_id: person.lukas_metzler
    state: home
  - condition: state
    entity_id: person.erika_inauen_metzler
    state: home
  - condition: or
    conditions:
      - condition: time
        after: "21:00:00"
      - condition: time
        before: "06:00:00"
actions:
  - action: script.turn_on
    data: {}
    target:
      entity_id: script.parterre_lights_off

What do the states of these sensors show when one phone has run out of battery?

sensor.sm_s9080_charger_type
sensor.sm_s9010_charger_type
person.lukas_metzler
person.erika_inauen_metzler

Simulating an empty battery is a bit tricky. Is switching it off the same thing?

It might be, it might not.

But you need to have the exact state in order to use it as a condition; you seem to think that it might actually happen reasonably frequently.

I stopped thinking about all scenarios , Now i have a Button “Strategically” Placed, within reach.
I hit it when i go to bed, an the Bedtime Automation Kicks in ) i.e checks/turn of some “forgotten” lights, an activate motion for lead-lights, for “needs”
( No, i never forget to hit it, because the light in the hallway to the bedroom would still be on then :wink:

This one I find it also tricky to get it right and I think the closest you get without user intervention is putting some sensor on your bed to detect that you are in it.
There are some good examples here for that.

Other then that, I think having a button placed strategically which you push when the last one goes to bed is, IMHO, the best option.
That’s how I did it.

well i don’t have any “bed sensors” but hitting the button turns on a plug, so i have "lead lights even under the bed, so the get activated by motion, when someone walks along the longside, or getting out of bed , 2 sensors/slings pointing each way, and adjusted, so no false detection’s( And lights only turn on at the side of detection), not when people walk along footend, or to far from bed :grin:

Edit, i.e Aqara Motion Sensors have about 1 minute detection interval, so Head Light in Bedroom turns OF after 1 minute if No motion, this one Covers the Door and part of the Footend area ( Not any part of the Bed !!! )

Yes, that’s how I did it too: a motion sensor to turn lights on (dimmed) when the house is in a sleep state as well other lights which turn on dimmed when motion is detected.

The point is, how do you differentiate the wake/sleep state.
This one could be the best option to handle it without user intervention: Bed Presence for ESPHome by Elevated Sensors

Still, I don’t think it fits all the scenario’s: it can work if the only thing you do is sleeping in your bed.

I dont ( But i diffinitely don’t want a bright light in sealing, unless im “looking” for something, and i have 1 Bedlight at the backend (over the head, warm dimmed, if needed), beside 2 side/read lamps, Yes they don’t have mind reading capabilities , so they are also manual :smile:

I was mainly trying to give ideas of do’s and don’t to OP because of newcomers can go wild on trying to automate stuff to find themselves, or other members in the house end up frustrated.

I also have wireless switches on the bedside to control the lights (On/Off/Dim/Brighten)

True, and i have a feeling sometimes people over complicate it , as there can be many “scenarios”, And also it depends upon the “households” common Routines
I always try to get that into the picture, because sometimes the easiest/comfortable ideas springs out of that thought. ( I know when i go to the bedroom and hit the Button, i will go to bed within few minutes To Sleep. )
I.e one of the last things i do, is Brush my Teeth and Pee :laughing: …Not sure howto get that into an Automation thou, or whether i will

I think there is a sort of people who like the nerdy side of home automation and want to install technology as much as possible to change the usual every day routine.

I have a simple solution for you to solve this: buy an electric/smart toothbrush, first pee and then brush teeth et voilà! :partying_face::man_facepalming:

Well , to “prone” , if i just drank half a bottle of Vodka, i might skip the Tooth Brushing , im sure my Teeth Will survive over the night, without extensive bacteria attacks :joy:

In that case: you will most likely sleep but your house will not know this…

As i said, i never forget to hit the Button, it’s a simple basic Routine, like hitting a light switch when it’s dark