Switch the lights off when no one in the room

Hi
I am playing with smart home ideas for years and I am getting the same issue in all systems I checked except HomeSeer.
I wonder how it is solved in this system.
I have a motion sensor and light in the room.
I want the light to switch on when someone enters the room and switch off when there is no motion for let say 3 minutes.
The problem is that if i will setup just when motion switch the light on and switch off after 3 minutes than it will go on and off lol the time instead of just switching off after 3 minutes after no motion is detected.
The issue is that when next motion is detected the counter of that 3 minutes does not stop just goes and after 3 minutes it switches off.
How is it done in HA?
Also if i have a tuya is the reaction to motion same delayed as in tuya interface around 3-5 seconds or it is faster because of HA

Hi Irek,

My friend this can certainly be a very frustrating topic. I seem to be always tinkering with my settings to optimise the experience for the people using rooms with motion based lights.

First question about room sensor.

In my time working on this exact challenge i have come to realise that different variables have a big part to play. So there is no one correct way to do things.
For example, these variables need to be considered.

  • The type of motion sensor you use. RF or Zigbee or zWave or something else like Wyze or DIY
  • If the underlying sensor communications are local or cloud based.
  • The quality of the sensor components can influence how accurate or sensitive the sensor is.
  • The number of sensors you put in the room compared to the room size.
  • how much movement does the person make inside the room.

The way i am handling this in home-assistant is to turn on the light & start a timer when motion is detected. Then every time motion is subsequently detected the timer is restarted. The light will only go off when the timer has finished & the motion sensor has been inactive for a minute or so.
For me the question becomes, how long should the timer be? Constant tinkering to find the right values & each room might be different. For example, my laundry & garage timers have much shorter times since people dont normally hang around in these rooms for long periods. On the other hand the bathroom has been more of a challenge, especially with children seem to take FOR EVER to shower. So i’ve had big challenges getting timings right for turning off the exhaust fan. It’s a constant work in progress.

For the second question about Tuya devices.

If you can flash them with alternate firmware like tasmota or esphome then the devices are only locally controlled. No cloud delays to worry about. I dont know for sure but i don’t think that home-assistant would make your Tuya cloud devices react any faster. However, you say 3-5 seconds… that’s way long dude.

Hope that helps.
Cheers
Nick