Question, I have an zigbee Aqara Motion/Illumination sensor talking to a Tasmota converted Sonoff Zigbee gateway. In the blueprint I put in my Motion and Illumination sensors, a bulb I want triggered and ‘Turn off wait time’ set to 1. All is working fine, it does as supposed to. But of course I want the lamp to be triggered when its dark… My illumination values are between 1.0 and about 500.0 lx. When I put a number/value of 8 or 8.0 in the (OPTIONAL) Illuminance cutoff value, and of course my illumination value is below 8 . The motion is triggered but the bulb does not get triggered. any ideas??? btw it doesnt matter which value I enter in the illuminance field the bulb wont come on, but the motion is triggered…
Update:
In the logs it said:
Logger: homeassistant.helpers.condition
Source: helpers/condition.py:458
First occurred: 01:10:14 (1 occurrences)
Last logged: 01:10:14
Error during template condition: UndefinedError: ‘None’ has no attribute ‘state’
This is really a cool blueprint, takes a lot of things into consideration that I’ve often done with motion sensors. The only problem for me is that everything is so restrictive that I cannot use it as-is and had to heavily modify it for my needs.
The Z-Wave motion sensors my system detected don’t come up as “device_class: motion”, so I removed that so that any sensor would work. The exact same problem with the illuminance sensor. I also added fields to specify the off minutes and some of the other values rather than look to an input helper so I didn’t have to create entities to utilize the blueprint and could create them on-the-fly.
But I do really like the blueprint, much more comprehensive than many others that do similar things.
Thanks for that correction. I got confused since Home Assistant allows you to say what the unit of measurement is for the input boolean, so I just figured I could name it as any measure of time and it would work in the code.
So now that thats fixed the code does appear to be working as intended. So now I have a suggestion.
Here’s how its working for me. I have my light on and I have that input boolean to either have my motion lights turn the light on, or to prevent it from happening. Here’s what can happen:
Input boolean is “off”, so motion sensor turns the light on as intended. In one instance, motion is detected, so the light turns on. I decide that I dont want it to turn off, so I change the input boolean to “on” so that the motion sensor shouldnt turn the light on. But since either Home Assistant takes a while to relay that the input boolean is changed, or the automation is already in progress and so changing the boolean wont do anything, the end result is that the light still turns off despite me wanting it to stay on. For the light to stay on, I actually need to turn the lights off, and then on again WHILE the boolean is in “on” for the lights to stay on.
My suggestion is for the change in boolean from “off” (where the motion sensor controls lights) to “on” to reset the automation, much like how the motion sensor resets the timer every time its triggered. In this way, if the light is in the ON state, and I now want it to stay in the ON state (without having to cycle the light off then on), if I change the input boolean to “on”, the timer will reset (or turn off), and the light wont still continue with the automation and turn the lights off when the timer runs out.
I hope that makes sense, but if not I can try explaining it again.
You have already asked for this before, and I have already responded to this request.
I am a bit hesitant to add this, since it would require a lot more input parameters, which would significantly add to the complexity of this blueprint. For instance: Percentage the light should dim to, amount of time before dimming, amount of time after dimming and turning the light off, etc. So I will not add this feature for now.
I think the problem is that you are using a hardcoded value for the illuminance cutoff value, but this template expects you to to use an input_number for that input. Take a look at the first post again, it explains how you can create this input_number. You can then use this value to set the cutoff illuminance value dynamically.
Yeah I understand your point, but I think thats a general ‘problem’ with blueprints. One of the goals of blueprints is to make it easier for newcomers to create automations. Restricting the entity domain class makes it easier tot find the correct entity id.
I can of course remove all these restrictions, but I’m not sure what’s better here.
For more ‘advanced’ users like you, it should be possible to just manually enter the entity_id in the blueprint without using the dropdown box though, so I think I will leave it as is for now.
I’m not very sure I understood you correctly, but it seems you want an input boolean to prevent the light from turning off.
If you look at the latest version of the blueprint, there are 2 (optional) inputs that are ‘blocker’ entities. One is for preventing the light turns on in the first place, and the other (‘turn_off_blocker_entity’) is for preventing the light to turn off.
The state of this input is only evaluated after the delay has passed. So even if the state of this input is set to ‘on’ at the last second of the delay period, it should prevent the target entity from turning off.
I think you can achieve what you want by using this input.
Ok so I would like to turn on a light by presence motion and with a minimum of brightness but only from 7 p.m. until 6 a.m. on the next day, so over 2 days.
For now, this exemple works:
But not this one:
I think it’s limited because of this part of your value template condition:
{% elif time_limit_before != none and time_limit_after != none %}
{{ states[time_limit_before].state > current_time and states[time_limit_after].state < current_time }}
But if it could possible to set it over 2 days it could be perfect for me!
You are right! I was able te reproduce the bug, and I think I fixed it now.
Please test with the most recent version of the blueprint and let me know if it works for you now.
I just fixed one more small bug where it would break when no time limits were set after the previous change from today.
Please update to latest version if you had just updated to the previous version
Thanks for your reply:
I’m an absolute beginner in HA and Yaml, don’t understand always what and where everything is going,
trying shortcuts to get ‘something’ working. But in my defense, the more experienced contributors dont make it always easy for us beginners and always assume the knowledge is there to get something working.
But I got your blueprint working, created two helpers and added them to my lovelacecard and indeed I can now select a cuttoff illumination and a turn of time… Again thanks for pointing me in the right direction, learned a lot…
You are totally right, it is very hard and requires quite a lot of time to fully understand everything about HA! And for more advanced users it is very easy to forget someone else does not possess all required knowledge to create something like an automation! But that’s what this community is for, every contributor needs feedback about what is not clear and also about the many bugs that will occur with every change
I have extended the blueprint with a new feature:
Being able to determine a entity to turn off after the delay period, which is different from the original target entity.
This can be helpful for instance in the following scenario:
I want to turn on a light with a certain brightness and color temperature, so I define a scene for that.
I want this light to turn off after the delay period
In this case target_entity would be the scene, and target_off_entity would be the light itself.
With previous versions of this blueprint this was not possible, because a scene entity cannot be turned ‘off’, only activated.
My use case for this is defining different scenes for different times of day.
For my hallway light near by bedroom I have a day and night scene, and thus 2 automations generated from this blueprint with different target entity scenes and different time limit values.
Example automations:
automation:
- alias: Turn on second floor hallway lights on motion detected during day
description: ''
use_blueprint:
path: homeassistant/motion_illuminance_activated_entity.yaml
input:
motion_sensor: binary_sensor.motion_sensor_2nd_floor_hallway_occupancy
target_entity: scene.second_floor_hallway_day
illuminance_sensor: sensor.motion_sensor_2nd_floor_hallway_illuminance_lux
illuminance_cutoff: input_number.illumination_2nd_floor_hallway_low_cutoff
no_motion_wait: input_number.second_floor_hallway_no_motion_turn_off_delay
time_limit_after: input_datetime.2nd_floor_hallway_lights_turn_on_after_limit
time_limit_before: input_datetime.2nd_floor_hallway_lights_turn_on_before_limit
target_off_entity: light.second_floor_hallway
- alias: Turn on second floor hallway lights on motion detected during night
description: ''
use_blueprint:
path: homeassistant/motion_illuminance_activated_entity.yaml
input:
motion_sensor: binary_sensor.motion_sensor_2nd_floor_hallway_occupancy
target_entity: scene.second_floor_hallway_night
illuminance_sensor: sensor.motion_sensor_2nd_floor_hallway_illuminance_lux
illuminance_cutoff: input_number.illumination_2nd_floor_hallway_low_cutoff
no_motion_wait: input_number.second_floor_hallway_no_motion_turn_off_delay
time_limit_after: input_datetime.2nd_floor_hallway_lights_turn_on_before_limit
time_limit_before: input_datetime.2nd_floor_hallway_lights_turn_on_after_limit
target_off_entity: light.second_floor_hallway
No sure if this will work perfectly but I’ll test in the coming days.
Tried AFAIK the latest version and for me the wait time is not used at all, as soon as my motion detector says no motion detected it will also turn off my light. The illuminance threshold does not work either…using the lux value that is given from my miflora devices which gives a float possibly since I can see values with decimals like 127.5 lux…and the automation is never triggered if the value is below so I can’t use the feature.
Notice that the fields says entities…maybe I have made a mistake on how to use the blueprint…can’t you input fixed numbers?..do you have to have your values input into entities?!
Hi Frank,
I ran into the same thing with my zigbee Aqara Motion/Illumination sensor, wanting to trigger when dark. I learned that the Illuminance value does not get updated until a motion detected event. I believe that is why I couldn’t get the routine to work depending on darkness. Always happy to be corrected though!
I am going to read up on helpers to see if that is a solution.
Andy