Assume the way you switch your automations is by time.
The bypass overrides everything. It looks like youāre using Option 3, which maintains the current state of the light in both automations. In this case, you only need the auto-OFF functionality in one automation.
When the bypass is turned OFF, it checks your site conditions and may turn the light ON if the trigger is active. If the automation is disabled (e.g., due to time constraints), it wonāt run, ensuring that only the active automation responds to the site conditions when the bypass is turned OFF.
Thing is that the script is actually being triggered on motion, but my issue is that the script needs a variable to be passed in (the light entity the script has responsibility to turn on), but I canāt figure out how I should do that - or if itās even possible
@Blacky : Due to maintenance works on an entrance door, a Nuki lock that is usually attached has been unattached for some days, and the device in Home Assistant has been disabled. Since the Nuki lock is supposed to be reattached in a couple of days, I ignored Spookās warnings. As a consequence, the Sensor Light automations which include the binary sensor of the disabled device do not work anymore.
Hello @Blacky I have this yaml created from your blueprint āSensor lightā:
alias: outdoor lights
description: āā
use_blueprint:
path: Blackshome/sensor-light.yaml
input:
motion_trigger:
Problem is that sometimes when the light is turned ON it will never go OFF. I think it is because of the motion sensor is not far from the light which is turned on and specified light value goes over 10 lux. Could this be the problem? If yes how to solve it? Thank you.
Iām not sure I fully understand your request, but if youāre looking for a script to turn on a light with three different settings depending on the time of day, Iāve created a quick example for you. Hereās how you can use it:
Create a new script and switch to YAML editing mode.
Copy and paste the code below into the script.
Switch back to the visual editor, and youāll see three options to configure.
Youāll need to customize the light entities and times to suit your needs. See the code below:
Not sure what your askingā¦ is it that your lock in disabled for a few days and was used as the trigger? if so you will need to find another trigger that suits your needs.
Yes but you will need to create a template binary sensor that looks for your conditions and if met then the template sensor will be ON.
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 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 binary_sensor.motion_sensor and ābinary_sensor.door_sensorā with your entity ID.
Once created add this template sensor as the trigger.
{{ is_state('binary_sensor.motion_sensor', 'on') and is_state('binary_sensor.door_sensor', 'on') }}
So. Iām slowly moving everything to HA (from homey) and blueprints are a life safer. So is this one.
I have 2 questions though.
1: sleep mode. I want to test the BP in my bedroom. Is there a way to tell that when I go to sleep fade the lights to far red and the turn off. Or at least disable the automation till I wake up? I looked at the nightlight setting but I donāt think that is the way.
2: the dynamic light option, will it work when I only selected a scene? As in. Entities arenāt linked then in the automation right?
Quick tip: When sharing code in this forum, itās best to use the </> button in the editor and paste your code there. This preserves the formatting, making it easier for others to read and use.
Here are a few things to consider:
Manual Light Control:
If you turn your light ON manually and the motion sensor is not triggered, the automation wonāt turn the light OFF.
Lux Levels and Motion Sensor Behavior:
If the motion sensor is triggered and your light turns ON when the levels are below 10, but the levels later rise above 10, the light will stay ON.
This happens because you have selected YES - My Ambient Light Sensor is affected by the Lights, so the automation ignores the lux value once the light is ON.
Aaah Okey I didnāt completely get that. Thanks!
Andā¦ If I want a transition to off? Or is that the *transition to off?
And. Amazing fast reply. Thank you. I saw in the fawlq that scenes donāt work with dynamic (which makes sense) but can I add scenes and entities to the automation and the dynamic light being smart enough to only do the enitites?
Re Dynamic lighting. This only works with light entity not a script or scene. If you have a scene and a light entity it will run the scene and also control the light entity in dynamic lighting. So it will do both.
Due to maintenance works on an entrance door, a Nuki lock that is usually attached has been unattached for some days, and the device in Home Assistant has been disabled. Since the Nuki lock is supposed to be reattached in a couple of days, I ignored Spook warnings.
I use Sensor light e.g. for switching on the light in the entrance.
belongs to the unattached nuki lock / the disabled nuki integration. If I leave this binary sensor in the automation, the whole automation seems not work anymore.
Ok, maybe itās easier if I provide my script Thanks so far!
light_time_of_day:
sequence:
- alias: Turn on light with brightness determined by time of day
choose:
- conditions:
- condition: time
after: 07:00:00
before: "20:00:00"
sequence:
- action: light.turn_on
metadata: {}
data:
transition: 0.5
kelvin: 2202
brightness_pct: "{{ brightness_high }}"
target:
entity_id: "{{ light }}"
- conditions:
- condition: time
after: "20:00:00"
before: "23:00:00"
sequence:
- action: light.turn_on
metadata: {}
data:
transition: 0.25
kelvin: 2202
brightness_pct: "{{ brightness_medium }}"
target:
entity_id: "{{ light }}"
- conditions:
- condition: time
after: "23:00:00"
before: 07:00:00
sequence:
- action: light.turn_on
metadata: {}
data:
transition: 0.25
kelvin: 2202
brightness_pct: "{{ brightness_low }}"
target:
entity_id: "{{ light }}"
fields:
light:
selector:
entity:
multiple: false
required: true
name: Light
description: The light group you want to control with the script. Only one entity.
variables:
brightness_low: 10
brightness_medium: 50
brightness_high: 90
Soā¦ I have a field called light. This is the light entity to be called on light.turn_on. If this is not given, the script have nothing to activate.
So in the blueprint automation, when I select this script to run (via the UI) Iām not given any way to provide the light entity I want to control, causing my script to fail (as the field is required).
Perhaps it should be done via YAML, but I havenāt got anything to work there either - Iāve tried some variants, but my last try was:
Hello dear expert. Could you help me and give me a hint what I am doing wrong?
I am trying to turn a light on/off through motion. I tried everything, but the automation script never gets triggered. I tried my Entity from my motion sensor of Philips Hueā¦ I tried the entity from an Aqara FP2 Presence Sensor.
If I use the standard homeassistant automation for activating a light on motion it works fine. But this script, with the same entities, never gets triggered. What am I doing wrong?
Hi, nice work, just what I have been looking for! I love the feature with setting up an Ambient Light Sensor for activation in low-light conditions, but ā¦ Not all rooms in my house need light at the same light level from a single sensor. Would it be possible to implement a feature where light in different rooms are triggered from same sensor but with different light levels?
It should still work if you disable the one entity. You could just remove this entity from the automation and then add it back in when it is up and running again.
With 8 entities I would make a group helper and add all the entities in there. Once you created the group I would then just add the group helper as the trigger. The how to do this is in the FAQ, click here.
Although your automation YAML should work I have notice one thing that is not normal. Below is you code cleaned up.