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

Ok, maybe it’s easier if I provide my script :slight_smile: 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:

- id: '1731869443083'
  alias: entrance/motion
  description: Turn on lights on motion
  use_blueprint:
    path: Blackshome/sensor-light.yaml
    input:
      light_switch:
        entity_id: script.light_time_of_day
        data:
          light: light.entrance
      motion_trigger:
      - binary_sensor.entrance_motion_sensor_occupancy

… but can’t figure out :slight_smile:

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?

(In the json trace file there is written

"trace": { "last_step": null, "run_id": "8c7576d62e128ffa411a4baf7d9e1ef2", "state": "stopped", "script_execution": null, "timestamp": { "start": "2024-11-19T19:34:53.756218+00:00", "finish": "2024-11-19T19:34:53.759120+00:00" }, "domain": "automation", "item_id": "1732044013135", "error": "UndefinedError: 'dict object' has no attribute 'entity_id'", "trigger": null, "trace": {},

and more…

Please help me. Thanks

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?

@ajd_ht

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.

alias: Entry - Light - Automation
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.entry_frontdoor_contact
      - binary_sensor.entry_secondarydoor_contact
      - binary_sensor.garage_door_contact_closed
      - binary_sensor.entry_motion_sensor_1
      - binary_sensor.stairway_up_motion
      - binary_sensor.driveway_motion_sensor
      - binary_sensor.entry_occupancy_sensor
      - binary_sensor.entry_frontdoor_nukilock_locked
    time_delay: 4
    light_switch:
      entity_id: light.entry_lights_main
    include_light_control:
      - use_brightness

Blacky :smiley:

@croon8483

You cant edit the YAML code of the blueprint, it will not work as these are just inputs.

Regarding your script, why don’t you just put in the brightness in rather than use a variable and then just select your light group as shown below.

alias: Turn on light with brightness determined by time of day
sequence:
  - 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: 90
            target:
              entity_id: light.ensuite_led_s
      - 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: 50
            target:
              entity_id:
                - light.ensuite_led_s
      - 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: 10
            target:
              entity_id:
                - light.ensuite_led_s

Blacky :smiley:

@Blacky : Many thanks. :pray:

1 Like

@Sibi1337

Welcome to the community.

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.

Hope this helps.

Blacky :smiley:

@Krolykke

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.

Blacky :smiley:

1 Like

I think we’re misunderstanding each other :smiley: 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.

is used here:

sequence:
  - action: light.turn_on
    metadata: {}
    data:
      transition: 0.5
      kelvin: 2202
      brightness_pct: 90
    target:
    entity_id: "{{ light }}"

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 :smiley: :smiley:

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.

You probably best to do a custom automation.

Blacky :smiley:

Okay, that’s unfortunate. Think I need to dismiss your beautiful blueprint :frowning: Thank you for support though, top class :clap:

1 Like

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%

@Yaksha

Hi John,

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.

Blacky :smiley:

Hi,

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?

Cheers

@victoroos

If you have selected a night light state and a night light time condition then both need to be met for night lights to be active.

Blacky :smiley:

New update 7.2

Your lighting experience, your way – take control and customize it to perfection! :bulb::sparkles:

Maintenance :toolbox:

  • 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 :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

3 Likes

Oooh that makes sense. Thanks!
Then I have to find a solution for my "problem

Regarding the entity, is that also an" and" expression or is that an or?

Oh… And. First time blue print user. Does it update automatically? Cheers.
Again. Thanks for taking time to reply and support!!!

@victoroos

All the night light conditions are “and”

No you have to do it manually. You can do this in the UI or you just click the import blue button at the top again follow along and it will update it.

Blacky :smiley:

So it is better to combine them in one group if I want it to be or?
Thanks! I see I should read your FAQs waay better!

Yes you can do that.

EDIT: Sorry I didn’t read it correctly. If you use entity state you can have multiple entities and only one needs to be true so it is an OR.

Blacky :smiley:

1 Like