Hello all,
I have a light switch in my guest bathroom that I wish to configure in such a way that depending on how long motion is detected in the room, the light will go off after a different time. I’m still learning automation in HA, so please bare with me.
First off, the devices. I have a Smartlife light switch, and an Aqara Motion Sensor P1.
Here’s my thinking -
Scenario 1: A person walks into the bathroom just to quickly wash their hands, no longer than a minute. Motion is detected for up to one minute. I would like the light to turn on upon motion, but then have the light turn off immediately after no motion is detected.
Scenario 2: A person walks into the bathroom and is in there for more than a minute. Motion is detected for more than a minute but potentially no motion is further detected because the person is showering and the shower curtain is drawn. I would like the light to turn on upon initial motion and stay on for 15 minutes, regardless if motion is further detected or not. After 15 minutes, if there is no further motion, the light will turn off. If within that 15 minutes, motion is again detected, the light will stay on for another 15 minutes.
The second scenario is more like those analog motion sensing light switch, where it will stay on for however many minutes you set it to until no motion is detected.
I’m not sure how I should set this automation. As I’m writing this, I’m starting to think that it might not be possible, but hopefully it is. I have a feeling that one automation will overwrite the other.
I currently tested this with 3 automations -
- turn on the light based on motion and that’s it
- When motion sensor changes from detected to clear for 1:00, turn off the light
- Well, I had a third one but as I was writing this, I think my third one was completely incorrect, so I don’t have a third one.
Any suggestion on how I should do this?
Also, on a separate topic, how do I create an automation where I can edit the yaml file? I tried creating a light-off automation with a delay that I add manually to the “edit in yaml” section, but whenever I save it, it disappears.