💡 Sensor Light - Motion Sensor - Door Sensor - Sun Elevation - LUX Value - Scenes - Time - Light Control - Device Tracker - Night Lights

I have something similar, but with power, when TV is running. So I created a helper with Threshold helper. It gets on or off when the conditions are set.
And the helper you use for bypass.

Could it be, that it is because my Motion Sensor is publishing the occupancy twice?
Im now trying to set the mqtt QOS to 2 , hopefully to prevent this.
Because I couldn’t find the light being immediately switched off.
If that doesn’t work i might be trying the ‘debounce’ option

Thanks, it seems like i made it work with a threshold helper! :slight_smile:

In addition to my earlier comment, i have a schedule sensor (at this time use this brightness, at that time use that brightness and so on) that i would like to implement to my bathroom lights. The states values are the percentages of the brightness, so at 10:00 it might be “20” and at 17:00 it might be “50”. Can that somehow be used with your template?

@barisahmet

Thanks for your suggestion, I done use hue but I will look into it.

Blacky :smiley:

@Strux

Now you have a humidity sensor in the bathroom maybe add a smart switch for the fan. You then can use my :shower: Bathroom Humidity Exhaust Fan blueprint to turn the fan ON and it will also keep the lights ON. In the FAQ of that blueprint I show my full set up and how I do it.

You could also us a door contact sensor so when you are in the bathroom and motion is detected it will keep the light ON until you open the door. To do this I have developed a template sensor called :honeybee: Bee In The Hive Sensor :honeybee: and this shows you how to do it, click here. This way when you are behind the shower curtain it will keep the lights ON.

Personally I use my :shower: Bathroom Humidity Exhaust Fan blueprint with this blueprint to achieve everything.

This would be done by using night lights and using night light time option and set when you would like the lights at 50% so from 17:00 to 07:00. Then set up your night lights.

Hope this helps you.

Blacky :smiley:

@Bogdis

It all looks good. When you close the door and your door sensor goes OFF for 10 seconds is your motion sensor ON?

Is there a delay for you door sensor or is it instant?

Did you reload the templates or restart your HA after you made the changes?

Blacky :smiley:

@danielo515

You can and you don’t need a script. You can use a scene or a script or just your light entities with no scene or script. It is totally up to you. But if you would like to use a scene or a script it is recommended to add a helper because scenes and scripts have no state… so in order for the automation to know if the lights are ON it looks at the helper to ensure the smooth operation of the automation.

Blacky :smiley:

Hi,

Here is a video with what’s happens.
Video

Hue motion badrum Motion - this is the motions sensor

Aqara Door Sensor Badrum - this is the door sensor

Badrumsensor Grupp - this is the group

Badrumsensor Template - and this is the template sensor

you can see in the video that the door is closed then when I open the door the motions sensor gets triggered and the door sensor closes. The group sensor is on until the motion clear then It changes to off and last the template sensor is always clear.

There is no delay for the door sensor as you can see inte the video.
I set upp the template sensor inte the UI because in the configuration.yaml I get errors when I add it and it dosent work.

I hope you can help me I really want this to work :slight_smile:

Edit:

Managed to make the template work by changing the code from - platform: state to - trigger: state and it seems to be working now but I still have a problem, the lights still turn off when someone is in the room and the lights won’t turn off when exiting the room.

I have a problem with your template. In my kitchen i have it turn on 2 different lights, when motion is detected. However, the LED strip under my kitchen cabinets slowly turn on for about .2-.5 seconds and then turn completely off, while the ceiling light turns on as it should. Do you have any idea why that happens?

Blueprint config:

id: '1729173428057'
alias: Bevægelsesaktiveret lys Køkken
description: ''
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.kokken_sensor_bevaegelse_aqara_occupancy
    light_switch:
      entity_id:
        - light.kokken_controller_ledstrip_miboxer
        - light.kokken_lampe_loft_shelly
    time_delay: 1
    include_light_control:
      - use_brightness
      - use_transition
      - use_colour_temperature
    light_transition_on: 3
    light_transition_off: 10
    light_colour_temperature: 3500
    night_lights:
      entity_id: light.kokken_controller_ledstrip_miboxer
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_transition_on: 3
    night_light_transition_off: 3
    night_lights_after_time: '23:00:00'
    night_lights_before_time: '05:00:00'

Sunds very promising with the Bee in the hive automation! I’ve read about it and tried implementing it, but i can’t seem to figure out where to input the code?
Is it a helper? An automation? Should i put it into configuration.yaml, under sensors?

  - trigger:
      - platform: state
        entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
        to: "on"
      - platform: state
        entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
        to: "off"
        for:
          seconds: 10
      - platform: state
        entity_id: binary_sensor.badevaerelse_sensor_bevaegelse_aqara_occupancy
        to: "on"
    binary_sensor:
      - name: "Badeværelse Optaget Sensor"
        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') }}

I have a radar motion sensor which reports how far movement is away…
It is reported in “large”, “medium” and “small”
Is it possible to just use for example the state “small” as a trigger, so the lamp only goes on when i am in a small radius?
How could i achieve this?
Thanks!

I’ve been porting over all of my custom AppDaemon automations to this blueprint, and so far I’ve been able to make everything work well. Thank you!

Apologies if this has already been discussed. It appears this topic has so many replies that the site search is kind of broken for it!

I had this set up with my AppDaemon automation for my front motion lights. The requirement was that if the lights were manually turned on at the switch, they stay on bypassing the motion light automation. I was able to do this by:

  1. Creating a toggle helper called “Front Lights Motion is Active”.
  2. Creating a script that is called as the light turn on action. The script first checks to see if the lights are off, or if the Active helper is set. If it passes, it sets that flag:
alias: Turn On Front Light Motion
sequence:
  - if:
      - condition: or
        conditions:
          - condition: state
            entity_id: light.front_lights
            state: "off"
          - condition: state
            entity_id: input_boolean.front_lights_motion_is_active
            state: "on"
    then:
      - action: light.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: light.front_lights
      - action: input_boolean.turn_on
        target:
          entity_id: input_boolean.front_lights_motion_is_active
        data: {}
    else:
      - stop: Lights are manually controlled
description: Used by motion light automation
  1. Adding a corresponding script to handle turning things off and resetting the flag:
alias: Turn Off Front Light Motion
sequence:
  - if:
      - condition: state
        entity_id: input_boolean.front_lights_motion_is_active
        state: "on"
    then:
      - action: light.turn_off
        target:
          entity_id:
            - light.front_lights
        data: {}
      - action: input_boolean.turn_off
        target:
          entity_id:
            - input_boolean.front_lights_motion_is_active
        data: {}
description: Used by motion light automation

The only downside is that if the light was turned on by motion, and you want to keep it on using only the physical switch, you need to turn it off and on again. But, that’s how it worked in the AppDaemon automation and so far there’s been no complaints.

hey guys, i use a motionsensor in my bedroom, that triggers a light to turn on in my hallway using this blueprint. in some situations the hallway light is manualy turned on by me. if i get motion in my bedroom the light in the hallway turns off after 30 secons cause of the blueprint settings.

is there a way to let the blueprint check if the light is already turned on and if so to not run the automation to turn it off?

@Bogdis

In your group you should only have your motion sensor and your bee in the hive sensor. Don’t add the door sensor. Then the group should be the only entity in the trigger input in the blueprint.

Blacky :smiley:

@Strux

This is strange as your ceiling light stays ON. Maybe it is the LED controller with the blueprints light control. Try and disable Use Brightness and Use Transition and see if that works. If so then add one back in at a time to see what one causes the problem.

The below code goes into your configuration.yaml. The heading “template:” is where you put all your template sensors under. Normally when you have a occupancy sensor they can detect you well as long as they can see you in line of sight.

template:
  - trigger:
        - platform: state
          entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
          to: "on"
        - platform: state
          entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
          to: "off"
          for:
            seconds: 10
        - platform: state
          entity_id: binary_sensor.badevaerelse_sensor_bevaegelse_aqara_occupancy
          to: "on"
      binary_sensor:
        - name: "Badeværelse Optaget Sensor"
          device_class: occupancy
          icon: mdi:account-box-outline
          state: >
            {{ is_state('binary_sensor.badevaerelse_sensor_dor_aqara_contact', 'off') and is_state('binary_sensor.badevaerelse_sensor_bevaegelse_aqara_occupancy', 'on') }}

Blacky :smiley:

@Flo_93

You would create a template binary sensor and use the state “small” then use that template binary sensor only as the trigger.

To create a Template binary sensor, follow these steps:

  1. Navigate to Settings > Device & Services > Helpers tab at the top.
  2. Click the Create helper button.
  3. Select Template and then choose Template a binary sensor.

Next, provide a Name and Device class (motion?) of your choice. If applicable, you can link this template to an existing device so it appears under that device’s details.

In the State template field, add the code below, replacing your_radar_motion_sensor_entity_id_here with your entity ID.

{{ is_state('your_radar_motion_sensor_entity_id_here', 'small') }}

Blacky :smiley:

1 Like

@deviantintegral

Hi Andrew, you can also do it by creating a template binary sensor and add it into the bypass but you will have the same problem, that is… if the light is ON you will have to turn it OFF and back ON again for it to turn ON the binary sensor.

template:
  - trigger:
      - trigger: state
        entity_id: light.your_light_switch_here
        to: "on"
        id: "t1"
      - trigger: state
        entity_id: light.your_light_switch_here
        to: "off"

    binary_sensor:
      - name: "Manual Light Switch"
        icon: mdi:cog-pause
        state: >
          {% if trigger.id == 't1' and trigger.to_state.context.parent_id is none %}
            on
          {% else %}
            off
          {% endif %}

Blacky :smiley:

1 Like

@mase

You can but it is not perfect, that is… if the light is ON you will have to turn it OFF and back ON again for it to turn ON the binary sensor. Once you create the binary sensor you then add it to bypass option 1 as that will turn the light ON.

template:
  - trigger:
      - trigger: state
        entity_id: light.your_light_switch_here
        to: "on"
        id: "t1"
      - trigger: state
        entity_id: light.your_light_switch_here
        to: "off"

    binary_sensor:
      - name: "Manual Light Switch"
        icon: mdi:cog-pause
        state: >
          {% if trigger.id == 't1' and trigger.to_state.context.parent_id is none %}
            on
          {% else %}
            off
          {% endif %}

Blacky :smiley:

1 Like

But in your description of Bee in the hive sensorn is to add the door sensor and motion to the group or have I and ChatGPT miss read that?