🐝 Bee In The Hive Sensor

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

GitHub Link Click Here

Get smart about occupancy with a Bee In The Hive Sensor! :artificial_satellite:

Like this blueprint? Consider hitting the :heart: button below :+1:

Version: 1.1 :fire:

Need help? :eyes: See our FAQ: Click Here

:newspaper: The Automation:

The Bee In The Hive Sensor is designed for enclosed spaces like bathrooms or toilets. It functions as a virtual occupancy sensor by combining a door contact sensor and a motion sensor. This blueprint sets up a toggle helper that acts like a sensor, allowing you to use it in your automations.

Why use it?

PIR motion sensors alone can struggle to detect occupancy when someone is sitting still, leading to lights, switches, or other entities turning OFF too soon. This often occurs when reading in the bath, using the toilet, showering behind a screen, or in areas where the motion sensor doesn’t cover every corner of the room. The Bee In The Hive Sensor works in conjunction with a door contact sensor to provide more reliable occupancy detection, ensuring the room remains occupied until the door is opened. While it still has limitations, it might just be the sensor you’ve been looking for.

How does it work?

  1. Door closes + motion changes from clear to detected = The room is Occupied (Toggle Helper ON).
  2. Door closes + motion is clear = The room is Unoccupied (Toggle Helper OFF).
  3. Door closes + motion remains detected after the set door time delay = The room is Occupied (Toggle Helper ON).
  4. Door closes + motion is detected but clears before the set door time delay = The room is Unoccupied (Toggle Helper OFF).
  5. If the room is Occupied + door opens = The room is Unoccupied (Toggle Helper OFF).

Blueprint Integration:

  • :bulb: Sensor Light: To fully utilize all features of the Sensor Light Blueprint, it is recommended to set up a template binary sensor and group it with your motion sensor. This eliminates the need to use this blueprint.

    :point_right: Click here for setup instructions.

:rocket: CHANGELOG

Version: 1.1 - 16 Feb-25 - Update links and descriptions in the automation process.
Version: 1.0 - 8 Feb-25 - Initial release

:shield: MY OTHER BLUEPRINTS

:bulb: Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time
:high_brightness: Smart Light - Entity - Sun Elevation - Ambient & Time Triggers
:infinity: Sensor Light Add On - Media & Movie Lights - House Alarm Lights - Smoke Alarm Lights & Exhaust Fans + More
:shower: Bathroom Humidity Exhaust Fan
:low_battery: Low Battery Notifications & Actions
:vibration_mode: Appliance Notifications & Actions - Washing Machine - Clothes Dryer - Dish Washer - ETC
:loudspeaker: Notifications & Announcements
:calendar: Calendar Notifications & Actions
:round_pushpin: State Notifications & Actions
:stop_button: Manual Control Status Tracker
:robot: Android Notification Channel Manager
:toilet: Toilet Exhaust Fan with time delay
:hourglass_flowing_sand: Entity - Run ON Timer
:stopwatch: Trigger - Run ON Timer
:magic_wand: Manual light control with auto OFF
:door: Closet, Pantry, and Cupboard Lighting
:timer_clock: Timer
:thermometer: Temperature Control Fan
:snowflake: Temperature Control Exhaust Fan - Inverted
:eight_spoked_asterisk: Toggle Switch - Turn ON & OFF Entities
:nazar_amulet: Press Button - Turn ON & OFF Entities
:on: Switch - Turn ON & OFF Entities

Like this blueprint? Consider hitting the :heart: button below :+1:

6 Likes

FAQ

Q: How to set up the blueprint?

A: For more information click here

Q: How to create a Bee In The Hive Template Binary Sensor (Without Using the Blueprint)? This allows you to utilize all features of the Sensor Light Blueprint.

A: For more information click here

Q: How to use it in the :bulb: Sensor Light Blueprint?

A: For more information click here

Q: How to create a group helper in Home Assistant?

A: For more information click here

How to Create a :honeybee: Bee In The Hive :honeybee: Template Binary Sensor (Without Using the Blueprint)

If you prefer to manually create a Bee In The Hive template binary sensor to fully utilize all features of the Sensor Light Blueprint, use the code below. Add it to your configuration.yaml file. You will need a File Editor installed into Home Assistant to edit your configuration.yaml file. For more information on how to install the File Editor add-on Click here

Applying the Changes

After adding your template binary sensor code to your configuration.yaml file, you have two options to apply the changes:

  1. Go to Developer Tools > YAML and click Template Entities.
  2. Restart Home Assistant.

Each time you modify the code, you’ll need to perform one of these actions for the changes to take effect.

Required Customizations

Make sure to replace the placeholders in the code with your actual entity names:

  • binary_sensor.your_door_sensor_here → Your door contact sensor
  • binary_sensor.your_motion_sensor_here → Your room motion sensor

Optional Customizations

  • "Bee In The Hive" → Choose any name for your new sensor.
  • Device Class ("occupancy") & Icon ("mdi:account-box-outline") → Customize to fit your preferences.
  • "10" → Adjust the door time delay (in seconds) to set how long the system waits after the door closes to allow the motion sensor to clear. Add extra time to ensure the motion sensor properly registers that no motion is detected. See Determine the Door Time Delay below for more information.

The Code

template:
  - trigger:
      - trigger: state
        entity_id: binary_sensor.your_door_sensor_here
        to: "on"
      - trigger: state
        entity_id: binary_sensor.your_door_sensor_here
        to: "off"
        for:
          seconds: 10
      - trigger: state
        entity_id: binary_sensor.your_motion_sensor_here
        to: "on"
    binary_sensor:
      - name: "Bee In The Hive"
        device_class: occupancy
        icon: mdi:account-box-outline
        state: >
          {{ is_state('binary_sensor.your_door_sensor_here', 'off') and is_state('binary_sensor.your_motion_sensor_here', 'on') }}

Testing & Extra Help

1. Determine the Door Time Delay

To set an appropriate Door Time Delay, follow these steps:

  • Add your Motion Sensor, Door Sensor, and this Template Binary Sensor to an Entities Card in a dashboard.
  • In your dashboard, click Edit, select Add Card, choose the Entities card, add your three entities (motion sensor, door contact sensor, and template binary sensor), then click Save.

This will allow you to monitor and see what is happening. Now, test how long it takes for your Motion Sensor to clear after exiting the room:

  • Walk into the room so the motion sensor detects movement.
  • Walk out, close the door, and start a stopwatch.
  • Observe how long it takes for the motion sensor to return to “clear.”

Suggested Door Time Delay settings:

  • If the sensor clears in 4-5 seconds, set the Door Time Delay to around 10 seconds.
  • If the sensor clears in 60 seconds, set the Door Time Delay to around 70 seconds.

:pushpin: Note: You may need to adjust these settings if you experience false readings.

2. Verify the Binary Sensor Stays CLEAR When the Room is Empty

  • Walk into the room (motion detected, door open, binary sensor is clear).
  • Walk out, close the door, and wait for the motion sensor to clear.
  • The binary sensor should remain clear. If it turns to detected, increase the Door Time Delay.
  • Fine-tune the delay to prevent false readings.

3. Verify the Binary Sensor Turns DETECTED When the Room is Occupied

  • Walk into the room (motion detected, door open, binary sensor is clear).
  • Close the door and keep moving inside the room until the Door Time Delay passes.
  • The binary sensor should turn to Detected.
  • Stay still
 once the motion sensor clears, the binary sensor should remain Detected.
  • Open the door
 the binary sensor should turn Clear instantly.

4. Final Test: No Motion, Door Closed, Then Motion Detected

  • Walk into the room (motion detected, door open, binary sensor is clear).
  • Close the door and stay still so the motion sensor does not detect you.
  • Once the Door Time Delay passes and your motion sensor is clear, the binary sensor should remain Clear.
  • Move again
 when the motion sensor detects motion, the binary sensor should turn Detected instantly.

:tada: Your :honeybee: Bee In The Hive :honeybee: sensor is now fully set up and ready to use in your automations! :tada: :partying_face:

Why Grouping the Sensors is Necessary

When you enter the room and trigger the motion sensor, the light will turn ON as expected based on the blueprint. However, the Bee In The Hive occupancy sensor ensures the light stays ON, even when the motion sensor alone might not detect movement.

By grouping the Motion Sensor with the Bee In The Hive template binary sensor, the automation functions more reliably while allowing you to take full advantage of all Sensor Light Blueprint features. You’ll then use this group as the trigger for your automation. Click here for grouping instructions.

Enjoy

Blacky :smiley:

Initial Release1.0

Get smart about occupancy with a Bee In The Hive Sensor! :artificial_satellite:

I created a :honeybee: Bee In The Hive :honeybee: template sensor back in August 2023, and I’ve now built a blueprint based on that sensor.

This blueprint makes setup incredibly easy
 no need to write code or understand YAML! The Bee In The Hive Sensor is designed for enclosed spaces like bathrooms or toilets. It functions as a virtual occupancy sensor, combining a door contact sensor and a motion sensor to enhance occupancy detection.

This blueprint automatically sets up a toggle helper that acts like a sensor, allowing you to seamlessly integrate it into your automations.

I hope you like it!

Above, I’ll include the code if you’d prefer to manually create a :honeybee: Bee In The Hive :honeybee: template sensor.

Let me know if this helps with your automations! :rocket:

Blacky :smiley:

First thanks for all of the great blueprints!!

I’m not clear what the Toggle Helper should be in this blueprint. I have Sensor Light setup to control the lights in the bathroom with a motion sensor group and I’ve added a door contact sensor for the Bee sensor. But, I don’t know what to use for the Toggler Helper in the Bee sensor blueprint.

Thanks!

@Ross1

There are two ways to do this:

First Method – Using the Blueprint

  • Use this blueprint and configure it with your motion sensor, door contact, and toggle helper.
  • In your Sensor Light blueprint, set the toggle helper as Bypass Option 1 and use the motion sensor as the trigger only.

:warning: Note: Do not group your motion sensor with the toggle helper or door sensor; use it exclusively in the trigger.

You can, however, group the toggle helper with your motion sensor and use the group in the trigger. While this creates a group that may not be necessary, it can be useful if you want to transition from normal light to night light. If that’s your goal, grouping them will work best for you.

Second Method – Using a Template Binary Sensor

  • If you’re not using the blueprint and have created your own template binary sensor as described here, you’ll need to group your motion sensor and the template binary sensor.
  • Then, use the group as your trigger.

Blacky :grinning:

Thank you for the extra information, it’s helpful. I finally figured out I needed to create a Toggle Helper. :slight_smile:

@Ross1

Yep and that toggle helper will be your :honeybee: Bee In The Hive :honeybee:.

You then can use it for so many things in all different automations.

Let us know how you go.

Blacky :grinning:

Hi Blacky.
Very nice work indeed.
When I thought I’ve tried all the “wasp in the box” blueprints, pop(!), showed up your bee

I put it on test

I have to do something with the delay at start, maybe a group with motion or who knows
 I’ll see

But I don’t know why, after 4 or 5 correctly executed tests, comes up one when the “bee in the hive” remained ON, after I go out of the room and I closed the door.
Any advice?

FAQ - How to Set Up the Blueprint

Before You Start


To fully utilize all features of the Sensor Light Blueprint, it is recommended to set up a template binary sensor and group it with your motion sensor. This eliminates the need to use this blueprint.

:point_right: Click here for setup instructions.

If you still would like to set up this blueprint then follow these steps:

1. Import and Create an Automation

After importing the blueprint, navigate to:
Settings > Automations & Scenes > Blueprint Tab, then search for the Bee In The Hive blueprint and click on it. This will create an automation using the blueprint. Once you save it, the automation will appear under the Automations tab. You can repeat this process multiple times to create multiple automations.

2. Select the Motion Sensor

Under Motion Sensor, choose the motion sensor that detects movement inside the room.

3. Select the Door Sensor

Under Door Sensor, choose the door contact sensor that detects when the door is opened (ON) or closed (OFF).

4. Select or Create a Toggle Helper

Under Toggle Helper, select a toggle helper to use exclusively for this blueprint. It must be independent and not shared with other automations. You can create a toggle helper in two ways:

  • Method 1 (Quick Creation in the Blueprint)
    Click the dropdown in the Toggle Helper input, scroll to the bottom, and select Create a new Toggle Helper. Enter a name, optionally choose an icon, and click Create.
  • Method 2 (Manually via Settings)
    Go to Settings > Devices & Services > Helpers Tab, click Create Helper, select Toggle, enter a name, choose an optional icon, and click Create.

5. Determine the Door Time Delay

To set an appropriate Door Time Delay, follow these steps:

  • Add your Motion Sensor, Door Sensor, and Toggle Helper to an Entities Card in a dashboard.
  • In your dashboard, click Edit, select Add Card, choose the Entities card, add your three entities (motion sensor, door contact sensor, and toggle helper), then click Save.

This will allow you to monitor and see what is happening. Now, test how long it takes for your Motion Sensor to clear after exiting the room:

  • Walk into the room so the motion sensor detects movement.
  • Walk out, close the door, and start a stopwatch.
  • Observe how long it takes for the motion sensor to return to “clear.”

Suggested Door Time Delay settings:

  • If the sensor clears in 4-5 seconds, set the Door Time Delay to around 10 seconds.
  • If the sensor clears in 60 seconds, set the Door Time Delay to around 70 seconds.

:pushpin: Note: You may need to adjust these settings if you experience false readings.

6. Verify the Toggle Helper Stays OFF When the Room is Empty

  • Walk into the room (motion detected, door open, toggle helper OFF).
  • Walk out, close the door, and wait for the motion sensor to clear.
  • The toggle helper should remain OFF. If it turns ON, increase the Door Time Delay.
  • Fine-tune the delay to prevent false readings.

7. Verify the Toggle Helper Turns ON When the Room is Occupied

  • Walk into the room (motion detected, door open, toggle helper OFF).
  • Close the door and keep moving inside the room until the Door Time Delay passes.
  • The toggle helper should turn ON.
  • Stay still
 once the motion sensor clears, the toggle helper should remain ON.
  • Open the door
 the toggle helper should turn OFF instantly.

8. Final Test: No Motion, Door Closed, Then Motion Detected

  • Walk into the room (motion detected, door open, toggle helper OFF).
  • Close the door and stay still so the motion sensor does not detect you.
  • Once the Door Time Delay passes and your motion sensor is clear, the toggle helper should remain OFF.
  • Move again
 when the motion sensor detects motion, the toggle helper should turn ON instantly.

:tada: Your :honeybee: Bee In The Hive :honeybee: blueprint is now fully set up and ready to use in your automations! :tada: :partying_face:

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

FAQ - How to Use It in the :bulb: Sensor Light Blueprint

Once you have created the Bee In The Hive sensor, you have two options:

  1. Create a group using your motion sensor and template binary sensor.
    Use this group in the trigger of the Sensor Light automation. This method allows you to utilize all features of the Sensor Light Blueprint and is the recommended approach. However, you will need to create a template binary sensor manually, rather than using the blueprint.

    For instructions on how to do this, click here.

  2. Add the toggle helper (used in the blueprint) to Bypass Option 1.
    This will turn your light ON and keep it ON, but you won’t be able to use all the features in the Sensor Light Blueprint. It’s a quick and easy solution if you’re just turning a light ON and OFF without creating an additional group helper.

    Link to my :bulb: Sensor Light blueprint


How to Create a Group Helper in Home Assistant

To create a Group Helper that includes your Motion Sensor and Template Binary Sensor, follow these steps:

  1. Go to: Settings > Devices & Services > Helpers Tab
  2. Click Create Helper
  3. Select Group
  4. Choose Binary Sensor Group
  5. Enter a name for your group (e.g., Room Occupancy Sensor)
  6. Click Add Members and select your Motion Sensor and Template Binary Sensor
  7. Click Create

Your new Group Helper is now ready! Use this group as the trigger in your Sensor Light Blueprint to fully leverage its features. :rocket:

Enjoy

Blacky :smiley:

Back to FAQ: Click Here

New update 1.1

Get smart about occupancy with a Bee In The Hive Sensor! :artificial_satellite:

:toolbox: Maintenance

  • Update links and descriptions in the automation process to better explain how to use it.

If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

@eac

Thanks for your kind words
 it’s been around since August 2023 and I shared it in a post but unless you know of it and know how to create a binary template sensor it can be out of reach for some of the community. The good thing about the blueprint and using a toggle helper rather than using a binary template sensor is helper you can override the toggle helper forcing it OFF or ON if needed.

The set up is tricky at first but once you understand what to do it is simple. I created a FAQ now on all of this click here for more info. Also how to use in in the sensor light blueprint click here

Hope this helps

Blacky :grinning:

@Ross1

I created a FAQ now on all of this click here for more info. Also how to use in in the sensor light blueprint click here

Blacky :grinning:

1 Like

I used the Template Binary Sensor method with Sensor Light, it works! Thanks!

@Ross1

Yeah it is a really good sensor and now you have a bee in the hive ( Occupancy ) sensor light blueprint with all the features.

Nice one glad you got it all working.

Blacky :grinning:

Moin moin ,hab den Biene im Bienenstocksensor Blueprint ĂŒbernommen, aber ÜberprĂŒfung ,nach TĂŒrzeitverzögerung,bei mir 60 sek. wird nach belegung ,der umschalhelfer nicht aktiviert wenn er frei wird und ich noch im raum bin.Kannst du mir helfen,bin absoluter neuling.

@lohti-58

Have a look at this post click here. Below is steps 5 to 8 translated to German for you.

5. Bestimmen Sie die TĂŒrzeitverzögerung

Um eine angemessene Torzeitverzögerung zu setzen, gehen Sie wie folgt vor:

  • FĂŒgen Sie Ihren Bewegungssensor, Ihren TĂŒrsensor und Ihren Toggle Helper zu einer Entities Card in einem Armaturenbrett hinzu.
  • Klicken Sie in Ihrem Dashboard auf Bearbeiten, wĂ€hlen Sie die Karte hinzufĂŒgen, wĂ€hlen Sie die EntitiesEntities-Karte, fĂŒgen Sie Ihre drei EntitĂ€ten (Bewegungssensor, TĂŒrkontaktsensor und Kipphilfe) hinzu, und klicken Sie auf Speichern.

Auf diese Weise können Sie ĂŒberwachen und sehen, was passiert. Testen Sie nun, wie lange es dauert, bis Ihr Bewegungssensor nach dem Verlassen des Raumes gerĂ€umt ist:

  • Gehen Sie in den Raum, damit der Bewegungssensor Bewegung erkennt.
  • Gehen Sie hinaus, schließen Sie die TĂŒr und starten Sie eine Stoppuhr.
  • Beobachten Sie, wie lange es dauert, bis der Bewegungssensor wieder „klar“ ist.

Empfohlene TĂŒrzeitverzögerungseinstellungen:

  • Wenn der Sensor in 4-5 Sekunden klĂ€rt, setzen Sie die TĂŒrzeitverzögerung auf etwa 10 Sekunden.
  • Wenn der Sensor in 60 Sekunden segelt, legen Sie die TĂŒrzeitverzögerung auf etwa 70 Sekunden.

:pushpin:Hinweis: Möglicherweise mĂŒssen Sie diese Einstellungen anpassen, wenn Sie falsche Messwerte erfahren.

6. Verifizieren Sie den Toggle Helper bleibt OFF Wenn der Raum leer ist

  • Gehen Sie in den Raum (Bewegung erkannt, TĂŒr offen, umschalten Sie den Helfer aus).
  • Gehen Sie heraus, schließen Sie die TĂŒr und warten Sie, bis sich der Bewegungssensor lichtet.
  • Der Kipphelfer sollte OFF bleiben. Wenn es sich ON dreht, erhöhen Sie die TĂŒrzeitverzögerung.
  • Feinabstimmung die Verzögerung, um falsche Messwerte zu verhindern.

7. ÜberprĂŒfen Sie, wie sich der Toggle-Helfer aufschlĂ€gt, wenn der Raum besetzt ist

  • Gehen Sie in den Raum (Bewegung erkannt, TĂŒr offen, umschalten Sie den Helfer aus).
  • Schließen Sie die TĂŒr und bewegen Sie sich im Raum**,** bis die Torzeit-VerspĂ€tung vorbei ist.
  • Der Knebelhelfer sollte sich aufdrehen.
  • Bleiben Sie ruhig
 sobald sich der Bewegungssensor klĂ€rt, sollte der Knebelhelfer ON bleiben.
  • Öffnen Sie die TĂŒr
 der Knebelhelfer sollte sofort ausschalten.

8. Abschlusstest: Kein Gang, TĂŒr geschlossen, dann Bewegung erkannt

  • Gehen Sie in den Raum (Bewegung erkannt, TĂŒr offen, umschalten Sie den Helfer aus).
  • Schließen Sie die TĂŒr und bleiben Sie still, damit der Bewegungssensor Sie nicht erkennt.
  • Sobald die TĂŒrzeitverzögerung vorbei ist und Ihr Bewegungssensor klar ist, sollte der Umschalthelfer OFF bleiben.
  • Bewegen Sie sich wieder
 wenn der Bewegungssensor Bewegung erkennt, sollte sich der Kipphelfer sofort einschalten.

Blacky :grinning: