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?
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.
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') }}
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:
Navigate to Settings > Device & Services > Helpers tab at the top.
Click the Create helper button.
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.
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 %}
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 %}
In the bee in the hive example I have the below statement. It says once you create this sensor (bee in the hive) then group with you motion sensor and add the group to the trigger.
Iāll keep refining the post to make it as clear as possibleā¦ thank you so much for your feedback, it really helps! Sorry if my earlier explanations werenāt quite clear, but I think weāre on the same page now, and hopefully, youāve got it working."
Hello, I like your blueprint, i am having a hard time getting this to work without issue. The different items not working, and i have to manually run it after ha reboot or if i run a scene or manually change the lights.
I have changed a few things. Note; because you are using dynamic lighting option 1 if you change the brightness and normal lights are active then dynamic lighting will change the brightness to suit.
Removed script in Scenes - Scripts To Turn OFF. Because you are using light entities you donāt need a end scrip to turn OFF you lights.
In Ambient condition set your LUX levels to reflect dynamic lighting levels you have set.
Could you create a toggle helper and add it into dynamic lighting Dynamic Lighting - Toggle Helper (Optional). You have set a Dynamic Lighting - Min Brightness Value to 0% so you will need to add this toggle helper in.
In Night Light Control I have un-ticked Yes - Manage OFF script when crossing over as I removed the script you had above in 1.
Because you are using dynamic lighting in Light Control I have un-ticked Use Brightness. It wont matter if it is ticked but because you are using dynamic lighting option 1 it will not be used.
Below is you new code, Just remember to update your people in zone.
I can see you getting a bit advanced in your set up.
No because you donāt have
template: !include template.yaml
I personally do it this way and create folders but it is getting a bit off topic of this post/blueprint. HA is starting to do it all through helpers now but they are yet to have template trigger so I only have my template trigger sensors and some advance sensors there now and I use the helpers as it is a lot cleaner and easier to manage. If you need more help splitting your templates then maybe create a new topic or research the forum as there will be a lot of information on this. Even YouTube has people showing you how to.
template:
- trigger:
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "on"
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "off"
for:
seconds: 10
- trigger: 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') }}
If you go my way and add the code below to your config file
template: !include_dir_merge_list template
You then create a folder under CONFIG (if using studio code server) or homeassistant/ (if you are using file editor) called template.
Once you done that in template folder you can create sub folders or just yaml files. I have a sub folder called binary. In binary you the create a file for your sensor say badevƦrelse_optaget_sensor.yaml. In the file add this code
# You can add a note here for future if you like
- trigger:
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "on"
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "off"
for:
seconds: 10
- trigger: 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') }}
Youāre right that I donāt need a script, nor a toggle.
I didnāt saw that I can select a scene in the āentityā picker.
I think your example is probably too complex for a āfirst introductionā to the solution. If you have never faced the situation you will not see the value, and it makes you think that the only way to take advantage of the feature is with all that added complexity.
I may be the weirdo here, but I think that a āsimpleā and a ācomplexā example will make things easier. Or maybe a disclaimer? āthis is only needed if you want to transition from normal lights to night lights that stay onā or something like that.
Cheers
Yeah it is a big blueprint and has so many featuresā¦ this can be overwhelmingā¦ It can do so many things.
Hope you got it working, to start just add a trigger (motion sensor) enter in your light/s entities and click save. That starts your lights coming ON and OFF. Then tackle night lights in a similar way.
Thanks!
I will definently look into splitting it up into folders and additional files, that would give a much better overview!
It seems like the Bee In The Hive sensor is working! Thank you!
I use your blueprint for all my motion-activated lights. Some of the lights also have a switch attached to them, so you can also manually turn on (and off) the lights. How does that affect the automation? If i manually turn on the lights and the motion sensor detects motion in the room (because i move around in the room) would the automation still turn off the lights? I ask because i have the impression that sometimes when the lights are turned on manually (usually because they have been turned off accidentally for some time) they stay on. Do you know why?
Thereās still a problem with the sensor, but iām not sure what. Maybe itās the position of my motion sensor; i have it pointing not directly towards but along the wall where the door is. This means motion is detected before the door is closed. Could that be the problem? (After just reading your docs, it seems no, it should be using scenario 2.
There are 2 times that affect this automation, the motion sensor reset time in the āBee In The hiveā template sensor, and the āTime Delayā value in the blueprint.
The āBee in the hiveā sensor should reflect the time it takes for the motion sensor to reset to āno motion detectedā from āmotion detectedā. For my Aqara Motion sensor P1, i have 2 time vaules: āDetection interval: Time interval between action detectionā and āOccupancy timeout: Time in seconds after which occupancy is cleared after detecting it.ā i guess it is the latter, which by default is set to the value of ādetection intervalā+2s. Detection interval is 10s, which means the other sensor must be 12s. So i set the delay value in the āBee in the hiveā sensor to 20s.
The āTime delayā value in the blueprint is set to 2 minutes.
I open the door, go in, close the door, do motion for 20s, then stand totally still. The lights turn off after 2 minutes. Why?
template sensor:
- trigger:
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "on"
- trigger: state
entity_id: binary_sensor.badevaerelse_sensor_dor_aqara_contact
to: "off"
for:
seconds: 20
- trigger: 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') }}
start section of blueprint: (iām not going to insert 6000+ lines of code)
Sorry your having trouble . I have just made a test sensor for this and it works perfectly.
NOTE: Every time you change/edit your template sensor YAML you have to reload it for it to take effect. Easiest way is to go into developer tools > YAML tab > scroll down to Template Entities and click itā¦ you should see a green tick.
Let try a few things to make it clear. In a dashboard add an entities card. In the card enter your door contact sensor, your sensor group, your motion sensor and your bee In The Hive sensor like shown below.
Now you can see at what is happening. Test a few things.
Trigger your motion sensor and time how long it takes to go from detected to clear. Then add a few seconds (+5) to your time (seconds). Use this time as a starting point replacing your 20 seconds. Make sure you reload your template senors every time you change it as described above.
Close the door, stand still not to trigger your motion sensor and wait until it is clear. Everything must be clear, then make your motion sensor go detected. You should see the group and bee in the hive go to detected. It should stay that way until you open the door.
Close the door, keep your motion sensor detected past your seconds. You should see the group and bee in the hive go to detected. It should stay that way until you open the door.
If you would like to show me your settings please dont copy 6000+ lines of code. What you do is go into your automation, top right 3 dots, Edit in YAML, copy all the code (will be a small amount of YAML just your settings), come back to the forum and in your reply at the top tool bar click on ā</>ā and paste code in there.