How to use one Aqara P1 sensor to turn lights on then off

I am a newbie here. It took me days to set HA, and I need HA for my wife. She is partially blind.

I do not know how to write correctly an automation to do the following:

  • Aqara P1 sensor is by her bed
  • Detects and triggers when she gets out of bed (the sensor is in her nightstand)
  • Turn the mastered room ceiling lights at 5%

This part I can do… I do not know how to do the following automation with the same Aqara P1 sensor below:

I do not know how long it will take her to return to bed, so timers do not work to turn off lights after xx time

  • when the sensor detects motion again, AND
  • mastered room lights are ON
  • turn OFF mastered room lights
  • delay the trigger for xx-seconds so she can get in bed

The second part being new to this for 2-days I do not know how to write this automation.

not hard to do…
I think you intended to say you know how to do the first part. could you post the automation that you did for the first part? it will be easiest for you if we edit that to achieve the second part.

1 Like

Thanks for the reply.

I wrote a simple automation to turn it on…when she gets out of bed.

I do not know how to write the second part…or even an entire new automation if needed for when she returns to bed and then turn the lights off

take a look at the link @Stiltjack posted. that has the core info you need. but if you still need help, post the automation you have. it will be easiest to modify it. yes, i understand you wrote the turn on part. we’ll use that to do the second part too.