Motion based room occupancy

I’m trying to create a decent, mostly reliable, motion-based room occupancy routine.

I think this should well enough…but:

  1. I can’t seem to it to restart the timer. timer.start should restart a running timer. Bug? (The problem is usually behind the keyboard.)
  2. Has anyone been able to change the default reset time on the xaiomi human body sensor?
timer:
  timer_dining:
    duration: '00:05:00'
automation:
  - alias: Dining Motion Detected
    initial_state: true
    trigger:
    - platform: state 
      entity_id: binary_sensor.motion_sensor_158d000236b201
      to: 'on'
    condition: []
    action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.dining_occupancy
    - service: timer.start
      entity_id: timer.timer_dining 

The motion detector resets after 2:00 minutes.

  • So it turn restarts at 2 and at 4 minutes (1 minute left on the initial timer)
  • The timer expires at 5 minutes (one minute later)
  • The motion detector is already on…so it doesn’t re-fire the new event for another minute

timer.start seems like a pretty core part of an automation project…so I’m pretty sure it’s me.

I also have a couple of Xiaomi motion sensors, which seem to be stuck 1 minute detection time for me, and I don’t think that’s configurable. I set up separate automations for turning the lamps on and off, like this:

https://github.com/joch/home-assistant-config/blob/master/automation/kitchen/lights.yaml#L6

Nice. I’m working on the model of separating the desired “need states” of an occupied house/room/area, from how the occupancy is detected and managed. The setting for that areas lights, music, temperature, blinds, etc is specific to some context.

  • time: early morning, daytime;
  • ambient conditions: dark and stormy, severe weather watch;
  • mode: ‘getting ready’, dinner party, netflix and chill, yoga

Triggers can then check a collection of states to create desired behavior. More like how a windows system behaves if window gets and loses focus.

Interesting! Maybe the bayesian sensor could be of help, where multiple inputs could determine occupancy.