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.
To me without seeing your YAML of the automation it looks like you are using a device in lights. You need to expand it down. The FAQ shows you how to do this click here
If this is not the case then could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on “</>” and paste code in there.
You can do this already. You just need to create another automation using the same blueprint for the other rooms and adjust the light level you would like.
TIP: If you are creating the same automation with just a few changes (different lights and light level) you can use the Duplicate button. You will find this when you are in automations, click on the 3 dots on the automation and select Duplicate. You then can make some minor adjustments saving you time.
I think we’re misunderstanding each other I’m not trying to alter the blueprint itself, but rather my automation based upon it.
Also… you’re right about the brightness, it’s redundant. Originally it was because the script had more responsibility than now.
But brightness wasn’t the issue… it’s the light field. You’re “hardcoding” the light entity in your example here - and in my version it’s an input/variable/field to the script to avoid having identical scripts for every light group I have.
This part of the script:
fields:
light:
selector:
entity:
multiple: false
required: true
name: Light
description: The light group you want to control with the script. Only one entity.
So instead of having 10+ identical scripts with only the light entity as difference, I have one script where I’m able to input the light entity. However… I’m just not aware of how I should do that with your blueprint?
I’m sorry… I don’t know how I shall explain further
Here is an example of my script being called from elsewhere in my ecosystem:
- id: entrance-smart-switch-2
alias: entrance/smart_switch_2
description: Switch closest to dining room
use_blueprint:
path: smartkontakten.yaml
input:
controller: entrance/smart_switch_2
button_1_pressed:
- choose:
- conditions:
- condition: state
entity_id: light.entrance
state: 'off'
sequence:
- action: script.light_time_of_day <--- | This is what
metadata: {} <--- | I'm trying to
data: <--- | accomplish.
light: light.entrance <--- |
alias: Turn on if lights are off, with brightness determined by time of
day
The blueprint wont work like that. It will run a script but you will need to tell it what to do, so you would need to create a script for every automation stating what lights to turn ON.
Sorry for the late reply!
I ensured that both of the conditions are true, however they still come on at 100% instead of the 10% that I have it set for. I even just tested it now with just having the do not disturb condition as the only one, and it came out at 100%
Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on “</>” and paste code in there.
Question. I can’t get night light to work.
I selected 2 entities ( helpers) and a time frame in which the night lights if one of those conditions are met should turn on.
But the lights still go to the normal lowest dynamic light setting.
How should I troubleshoot this?
Your lighting experience, your way – take control and customize it to perfection!
Maintenance
From time to time, Home Assistant updates their YAML standards and coding practices. To align with their roadmap, we’ve updated the code accordingly. We will continue to apply these updates across all our blueprints as they are revised.
Update some conditions.
Update night light UI conditions text.
If you like this blueprint? Consider hitting the button in the top post
If you like my blueprints, and would like to show your support or just say thank you? Click Here