Occupancy Blueprint

For your 1st “corner case” I’m afraid its just the limitation of your hardware and there is nothing you are doing wrong. There is no way around it, you need a motion sensor with a cooldown of less than a few seconds. (you can use my solution for problem number two, but it feels a bit invasive for a toilet or bathroom) For this I just bought the aqara p1 sensor as it had an adjustable cooldown period of 1-300 seconds or something like that. I set it to 2 seconds, more than enough time for the sensor to catch me inside the room moving just after closing the door.

And for your second issue I use a PIR to turn on the lights and Frigate to turn off the lights, and while I’m at it everything else in the Livingroom.
A small $50-$100 rtsp camera, and a HA server powerful enough to run frigate for object detection.
Any recent desktop or laptop should be enough… not sure about a pie though.

Thank you very much @alexbabel !

Will try to run i through it’s paces tomorrow instead of the AppDaemon version

Looking at the blueprint it in the visual editor, I think it might help new users if for each helper field you provided the same short description of the type of helper needed as you have in your Requirements section here.

Thank you Alex, will try your blueprint later and update you .

Hi Alex,
thanks a lot for your blueprint. I am quite unexperienced, yet, when it comes to HA automations.
so far, I was able to get the script running and my boolean helper (“bathroom_wasp”) works… what now?
could you please give me some guidance: I want to set a light scene depending on bathroom occupancy, respectively switch off all bathroom lights when the room is empty… how can I achieve that?

Until now I used another blueprint (“toggle scene”) that relies on a motion sensor… however, I cannot simply put my occupancy-helper as trigger there :frowning:
thanks a lot!

Hey @lensherm,

thank you for your feedback. I just updated the description for both helpers.

Hey @docNeptun ,

you can use the wasp helper as a trigger for further automations. Just choose as a trigger type State and search for the helper (bathroom_wasp), then you can choose the state changes (offon for movement and onoff for no movement [as two separate triggers]).

There are also some blueprints that can help you to achieve the light dimming behaviour. Currently, I use a modified version of the default motion blueprint. I also plan to publish my version as soon as I have the time to polish it. Presently, it’s not in a state to be published.

Update: It was not the default motion blueprint. I used the following blueprint as a template: Turn on light, switch, scene, script or group based on motion, illuminance, sun (+ more conditions)

1 Like

Thank you. Apologies for the confusion, I should have been more clear. What I meant was giving the user the type of a helper they have to create - one of them needs to be of the type “toggle” and the other has to be the “date and time” helper.

Oh ok. I will add that too. Thanks again

I’m getting an error adding the blueprint:

mapping values are not allowed here in "<unicode string>", line 31, column 35: name: Occupancy Helper (type: input_boolean) ^

Hey @nitaybz,

thanks for the hint. It should work again now.

I was hoping this would solve my bathroom lighting automation troubles which so far I’ve been battling with a custom automation but it seems I have an issue with the blueprint that hasn’t been mentioned above;

I have an Aqara Human Presence Sensor in the bathroom and it sometimes triggers false positives (wind moving curtains etc.) - when this happens it triggers your blueprint but doesn’t seem to recover (i.e. the input_boolean remains on until the next event).

Hi I’m would you consider implementing a QOL change and expose the ability to add conditions through the UI this would be really helpful, Thanks.

@alexbabel

Hello there,

I found a bit problem your automation.

So i create a automation, that turn on the light, when door is open and turn off it, when input_boolean from this blueprint switch off.

My problem is that i open the door and sit more time in the bathroom (more that about 2 min) the light turn off. When i do some movement, it turn on again and it still on when i’m here in the room. (so works as expected)

it possible to somehow fix that first time not switch off the light and not need to move it?

Edit:

I think solve the problem:

binary_sensor:
  - platform: template
    sensors:
      wc_motion_template:
        value_template: "{{ is_state('binary_sensor.0x00158d0007e2d214_occupancy', 'on') }}"
        delay_on: 0:00:15
        device_class: motion

Create a sensor template, and delay the “on” state 15 sec.

How did you make the automation? With Node-Red or with Automations?
Can you share your automation with me?

Hello, here:

- id: '1673703971400'
  alias: Földszint WC lámpa kapcsolás
  description: ''
  trigger:
  - platform: state
    entity_id:
    - input_boolean.wc_jelenlet_foldszint
  - platform: state
    entity_id:
    - binary_sensor.xxxxxxx_contact
    from: 'off'
    to: 'on'
  condition: []
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: binary_sensor.xxxxxxx_contact
        state: 'on'
      sequence:
      - service: light.turn_on
        data: {}
        target:
          device_id: xxxxxxx
    - conditions:
      - condition: state
        entity_id: input_boolean.wc_jelenlet_foldszint
        state: 'off'
      sequence:
      - service: light.turn_off
        data: {}
        target:
          device_id: xxxxxxx
  mode: single
1 Like

Hi, I just implemented the automation and run into the known issues.
My Hue motion sensor detects Motion and keeps that state for 10 seconds.
The door sensor acts instandly.
The first motion after opening the door should trigger the occupancy to on and keep it that way if the door is closed. Otherwise you need to move again for the occupancy to stay true.

this is the reason that i create a motion template sensor.

Now my side is working here:

  1. Open the door, trigger the door sensor, the light is on. It also trigger the motion sensor, but this Blueprint is not started, because it not set it directly, set it the template sensor.
  2. 15 sec later (it is totally true that the door is closed) the motion template is trigger the blueprint (wasp in the box) and the light is constantly on, not need other movement, because the door is closed, no way to left the room.
  3. If we are finish, open the door. The bluprint is finish. When the motion sensor is “cool down” (and the pre set delay is ower) the light turn it off.

@alexbabel, in addition to toggling the boolean, as an option, would you consider adding the ability to allow the users to enter their own actions when the occupancy goes to on and to off?

I’m guessing a good number is using your blueprint for triggering a set of lights. From the standpoint of usability, the above feature could be useful in not having to chain together two automations to trigger one set of lights.

In either case, as I mentioned before, thanks for your work!

Maybe I’m missing something. Let me check if I understand it.

The idea is when the door is openend for the first time and there is motion detected inside the room, there is a person. As long as the door stays closed, the person is present and thus the light should be turned on. If the door get’s openend again and there hasn’t been a movement for a while the light can be turned off. If the door gets openend but there is still movement then the lights should continue to stay on.

Now I can turn on the lights with opening the door, or even with the boolean be turned on. But the boolean turns of pretty fast. So where do I put the light off command?

At the very basic level you can do something along these lines here:

alias: Occupancy Light - Utility Room
description: ""
trigger:
  - platform: state
    entity_id:
      - input_boolean.utility_room_occupancy
    to: "on"
    id: "On"
  - platform: state
    entity_id:
      - input_boolean.utility_room_occupancy
    to: "off"
    for:
      hours: 0
      minutes: 0
      seconds: 30
    id: "Off"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "On"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.utility_room_lights
      - conditions:
          - condition: trigger
            id: "Off"
        sequence:
          - service: light.turn_off
            target:
              entity_id: light.utility_room_lights
mode: single