Occupancy Blueprint

Hi @alexbabel, I have a Philips hue motion sensor. What is the recommended time delay for that? Because I’m still having the lights turning off while I’m still in the room with the default setting.

It looks like this for me.

I use an Aqara Door & Window sensor and a Philips hue sensor

It looks like you have a newer version of the blueprint. You have an extra input field named “motion sensor delay”. I have used the version from your GitHub. Can you share the updated blueprint?

Of course. I forgot that. Now the new version is on GitHub

1 Like

Thanks. I will try that one later today.

The problem is fixed with the latest version. Thanks mate!

1 Like

I’m going crazy, I finally got this. Thank you Alex.

2 Likes

This blueprint works so well in my bathroom and study, thanks for building it! :slightly_smiling_face:

Could the turn off delay be changed to accept an input number helper, to dynamically change the delay during the day?

Does the blueprint itself trigger the light to turn on or do I need a separate automation to turn them on?

Thanks! I’m absolutely brand new to HA and I managed to get this working using a Shelly Blu door sensor and Shelly motion sensor for my bathroom light.

I just set it up so we’ll see how it goes over the next few days!

Maybe you already sorted this out, but I set up another automation to based on the Occupancy Helper state.

For the trigger I selected Entity and then State. Then you can search for Occupancy Helper, and select “To:” ON.

Then you can continue with the rest of the automation you want for when the light is on.

Then set another automation to turn it off when the state changes to OFF. Maybe there is a way to do it with one automation, but I’m not smart.

Wow! This is among one of nicest occupancy automations I’ve seen.

But maybe it would be helpful to implement it more as a finite state machine to avoid any bugs?

Or perhaps even set this up as a Bayesian belief with

  • P(Wasp Inside | Wasp Detected): The probability that the wasp is inside given that it is detected. Likely to be high.
  • P(Wasp Inside | Box Closed, Prior Wasp Inside): The probability that the wasp is still inside given that the box was closed while the wasp was inside. Also high.
  • P(Wasp Inside | Wasp Not Moving, Box Closed): The probability that the wasp is inside given that it has stopped moving and the box is closed. The probability will decay exponentially as time since last movement increases.

Perhaps you can even incorporate a network of interconnected boxes with known distances and a prior number of wasps known, using movement in nearby rooms as evidence of the wasp’s escape… Kind-of like a Markov process…

1 Like

Hi, thanks a lot for the blueprint. I tried it and it works perfectly except for one situation. If I enter the room and leave the door open, it will turn off the light if I stop moving for some time or get out of sensor’s range.

I would like to always keep the light on if the door is opened. Only turn off the light, if the door is closed a no moevemnt inside is detected. How can I do that?

Working perfectly for me, thanks Alex. I knew what I wanted but couldn’t figure out the logic. I may need to upgrade to a sensor with a shorter timeout though as my IKEA one takes 20 seconds to clear and it’s easily possible to close the door and sit still within that time which makes the lights turn off.

This works great. Thank you.
Did you consider an option to set occupancy when the door is opened? That would be great to reduce the delay until one is detected by the motion sensor when entering the room.

1 Like

Isn’t that the way it works now?

      - conditions:
          - condition: state
            entity_id: input_boolean.xxxx_room_occupancy
            state: 'on'
          - condition: or
            conditions:
...
              - condition: and
                conditions:
                  - condition: trigger
                    id: door_opened
                  - condition: state
                    entity_id: binary_sensor.xxxx_room_motion
                    state: 'off'
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.xxxx_room_occupancy
    default: []

The delay is caused by a different block if both motion is detected while the door is opened. And in that case, it looks like it pins off the Motion Sensor turn off delay time which personally I set to zero for my use case.

Thank you!

I have a problem! How can I make it so that when I leave the room and close the door, the status changes to “Not occupied” and therefore the door is closed And the lights go out!

I’ve been trying to use the automation but when i’m not detected inside of the bathroom it will still switch the wasp to off

Here is a timeline of the various elements in play:

Bathroom → doorsensor
PIR motion → motion sensor
Wasp → wasp boolean
Lights → actual state of the lights

@alexbabel or someone, can you explain me how to use the last motion helper?. I usually leave the bathroom door closed. Thanks