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

Thank you – I will try this too. Wanted to share that I was in the meantime able to solve like this (below the answer that Chat GPT gave me including the code (!), which actually works:

Yes, it is possible to make your REST API service show up as an entity in Home Assistant so that it can be controlled by blueprints and automations. To achieve this, you can use the rest_command integration and create a template switch or light that is linked to your REST API service.

Here’s an example configuration that demonstrates how to set up a template switch that controls your REST API service:


switch:
  - platform: template
    switches:
      light23:
        value_template: "{{ is_state('switch.light23', 'on') }}"
        turn_on:
          service: rest_command.light23on
        turn_off:
          service: rest_command.light23off

In this configuration, we define a template switch named “light23” that uses the is_state function to determine its current state based on the state of the switch.light23 entity. The turn_on and turn_off actions are set to call your REST API service using the rest_command.light23on and rest_command.light23off services, respectively.

Once you have set up the template switch, it will appear as a controllable entity in Home Assistant, and you can use it in blueprints and automations like any other switch or light entity.

Remember to replace switch.light23, rest_command.light23on, and rest_command.light23off with the actual names of your entities and services.

1 Like

@Blacky Any person can have several trackers, such as an application, router data or a BLE device. Changing the tracking settings will not result in the need to reconfigure the automation.

@gamba69 I was thinking to use device tracking as it can be more customised if you would like to use one device tracker on the person that could have 2 or more. Maybe I should allow it to have both so the user can decide.

Edit: I have already done all the code so I am good there.

Thanks

Blacky :smiley:

New update 3.8

:warning: Some work is required in this upgrade. Please see below on the steps required when upgrading. It is easy and not a breaking change.

New Feature :new:

Device Tracker - “People”

We have updated “Zone - Device Tracker” to include a new selection “People”. This will now allow you to select a zone and the people you would like to track in that zone. You still have the option to just select a zone if you prefer. Thanks to @gamba69 for the help with the code. See below the changes

What can this now do? :thinking:

If you use device tracker, you could track your cars, pets, people etc. In some cases you could all go out for the night in one car and leave the other car behind. You could go for a walk and leave your car behind. This will show one device in the zone (your car), and your lights would still turn ON when your pets run around the house. With the new option having the ability to also include people, you can now exclude the items you don’t want to track (the car) and include the people you would like to track. So now your lights can remain OFF until one person arrives home.

The title description has also changed to “Device Tracker”. Hopefully this will make it clearer in your selection.

:warning: :stethoscope: STEPS REQUIRED WHEN UPGRADING :white_check_mark:

If you have never selected to use device tracker then most likely you won’t need to do anything but you may want to check just encase you have selected device tracker in the past.

1 - Upgrade your blueprint.
2 - Then go into your automation (the ones using this blueprint) and click the 3 dots top right and “Edit in YAML”

3 - We are looking for the words or input called “include_zone: ???” If you don’t see this then you have never selected it and your all good to go, your done. If you see it then continue on.

4 - Delete this line,(“include_zone: ???”) then click save, click 3 dots and select “Edit in visual editor”

5 - Update your selection if you would like to use the device tracker.

6 - Click save, you’re done. Now just do the same in your other automations using this blueprint.

TIP
If you would like to easily find all the automation that are using this blueprint so you can check your YAML. Go into blueprints and click on the 3 dots next to the sensor light blueprint and select “show automations using this blueprint” You then can easily edit them all. See below.

Enjoy

Blacky :grinning:

Back to FAQ: Click Here

3 Likes

hey love the blueprints you make. very easy and precise. Only I’m having an issue that they are just not working.No matter what i do the automation is just not triggering or in the best case scenario the lights will flash on n off n done.am at my wits end any help is appreciated. Am a newbie to ha so my apologies in advanced if the solution is obvious

@Peoples204

Hi, firstly welcome to the community :wave:

What I think may be happening is you are using Areas and or devices. Please expand them buy using the “<>” down to entities. It should all be green as shown below. You then will find that your automation triggers and your lights will turn on.

Areas :x:

Devices :x:

Entities :white_check_mark: :+1:

Let us know how you go.

Blacky :smiley:

Thanks for the quick reply. as for what im using its all as instructed by ur instructions. so i am using entities and still no luck. just to try out i created a basic automation with the same sensor and lights and it worked without an issue. Usually i would just keep it to the basics but the idea of the light changing temp depending on the time of day is so appealing i cant let it go. Plez help

I just had exactly this happen. Couldn’t figure out why it wasn’t triggering. It was a device (blue) that I had chosen not the Entity (green). I wasn’t even thinking that could be a problem because to me the trigger was what mattered. Still learning.

2 Likes

@Peoples204

We will need to go through a few things. We know the blueprint works. There are a few things that can stop the automation running (conditions). In order for me to see what is happening I will need to see the YAML of your automation. This YAML is the code of your selections in the automation.

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.

Another thing you could try is to delete the automation (not the blueprint) and create a new automaton. The reason why I asked to delete the existing automation is we don’t want that automation stopping or doing anything. You could disable it if you like as this will do the same thing and then you can enable it latter, but we need to make sure the light we are controlling only has one automation controlling it.

When you create a new automation, only enter in, the trigger and a light entity, nothing else and test if the automation works.

For more information on this automation that may also help you is to read “The Settings & Best Practice Guidelines” Click Here.

Let us know how you go.

Blacky :smiley:

talias: Dinning Room Sensor Light
description: ""
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.dinning_room_sensor_occupancy
    light_switch:
      entity_id:
        - light.dinning_room_light_left
        - light.dinning_room_light_right
    include_light_control:
      - use_brightness
      - use_colour_temperature
    include_time: time_enabled
    after_time: "17:00:00"
    before_time: "08:00:00"
    include_night_lights: night_lights_enabled
    night_lights:
      entity_id:
        - light.dinning_room_light_right
        - light.dinning_room_light_left
    include_night_light_control:
      - use_brightness
      - use_colour_temperature
    night_light_colour_temperature: 3500
    night_lights_after_time: "22:30:00"
    night_lights_before_time: "08:00:00"

@Peoples204

All your setting are good. The only thing that will stop the automation running is “Time”. This automation will run between 5 pm and 8 am. Could you “disable the time options” and test it please. I am thinking your HA could have the wrong time. When testing your binary_sensor.dinning_room_sensor_occupancy has to go from OFF, clear etc to ON, detected ect.

To check your time go into developer tools / templates and paste this code below. It will show you the time of HA.

{{ now() }}
{{ now().astimezone() }}
{{ utcnow().astimezone() }}
{{ now().now() }}
{{ now().today() }}
{{ now() }}
{{ now().tzinfo }}
{{ now().astimezone().tzinfo }}
{{ now().weekday() }}
{{ now().date() }}
{{ now().time() }}
{{ now().strftime('%d-%m-%Y') }}
{{ now().strftime('%d-%h-%Y') }}
{{ now().strftime('Your HA time is %H:%M:%S and the Date is %d-%h-%Y ') }}

If this is what I am thinking (HA has the wrong time) then you will have to set up your time in - settings / systems / general and set your time zone.

If still no luck please provide your trace line screen shot.

Let us know how you go.

Blacky :smiley:

Hi!

Thanks you so much for your blueprint! Is the most reliable and customizable one that I have found. I would like to suggest only one additional option, the use of a blocker entity. I have a shower cabin in my bathroom, and it is impossible for the motion sensor to see somebody through the glass, so I have a door contact sensor on the shower doors and I would love to use this so when the cabin is closed, the lights would not go off. Please let me know if this is possible and if I can help in any way to make it happen.

Thanks in advance.

1 Like

i did as told and yes when just having the night light option on it works but as soon as i add somewhere else it doesn’t work. Wonder Why PS my time is correct

@DaniCristobal

Hi Daniel, firstly welcome to the community :+1:

Thank you for your kind words :smiling_face_with_three_hearts:

Yes it is possible in the current blueprint :+1:

What you would need to do is use the by-pass and select ether option 1 or 3. Because your door sensor will probably be OFF when the door is closed and ON when it is open we will need to reverse this sensor state. To do this you can create a template sensor in your “configuration.yaml” file. Below is the code you will need to use in your “configuration.yaml” file and you will need to replace the “binary_sensor.your_shower_door_sensor_here” to your actual entity name.

binary_sensor:
  - platform: template
    sensors:
      shower_door:
        friendly_name: "Shower Doors"
        device_class: door
        icon_template: mdi:door
        value_template: >-
          {{ is_state('binary_sensor.your_shower_door_sensor_here', 'off') }}

The "friendly_name: “Shower Doors” change “Shower Doors” to your liking, the text “shower_door:” change the text to you liking and you can also change the icon if you like.

Once done you will then need to restart HA for the sensor to take affect. Then add your new sensor into the by-pass with enable option 1 or 3 :tada:

Hope this help, and if you have any question please ask.

Let us know how you go.

Blacky :smiley:

1 Like

Ok, if your time is correct then it should work. We know the blueprint works so I must be something on your end. Please go into your automation and on the top right there is “Traces”. Trigger the sensor and then look at the traces. If you can, please do a screen shot of this and paste it into this post so we can see what is happening. Also note in the traces it will indicate the time to, so triple check this.

First of all, thanks for publishing this automation! It looks like it will do exactly what I want, if I can get it to work.

However, I am having problems just getting it to trigger in the simplest configuration (just adding a sensor and a switch). This is what I see when I edit it in yaml:

 alias: lights
 description: ""
 use_blueprint:
   path: Blackshome/sensor-light.yaml
   input:
     motion_trigger:
       - binary_sensor.garage_motion_sensor_occupancy
     light_switch:
       device_id: 24a111edd2c57f37d3ed2cdaa01cddfe

In my dashboard I can see the sensor goes from “clear” to “detected” when I move, and can get other simpler light automations (that don’t have as many features as this one) to trigger off of it. Seems like I am missing something basic, but can’t figure out what.

I set homeassistant up a few years ago, but didn’t do anything beyond connect my thermostat till now. I just updated everything with an update button, but maybe there is something stale somewhere?

You can ignore my question. I found the answer by reading this post a few posts up:

I just had exactly this happen. Couldn’t figure out why it wasn’t triggering. It was a device (blue) that I had chosen not the Entity (green). I wasn’t even thinking that could be a problem because to me the trigger was what mattered. Still learning.

I did look through the FAQ and didn’t find this answer, so may be worth adding a note there or something.

firstly, awesome automation @Blacky !
I just started using this blueprint with 3 automations (for now) and I think there may be a bug. Note, I have not used a previous version and recently started on HAss - former Smartthings users for many years including using Edge drivers…

Seems like the transition object is mandatory, it needs to be checked and anything < 0. I started debugging my automation with 1 second for both on and off transistions, graduated to 0.1 for both on and off and transition enabled. If I uncheck the transition, the automation doesnt fire.
Here is the trace timeline (not sure what else would help you).

Triggered by the state of binary_sensor.motion_living_room_3 at June 28, 2023 at 9:52:36 PM

Test if any of 12 conditions matches

Test if any of 6 conditions matches

Test if any of 3 conditions matches

Test if any of 6 conditions matches

Test if any of 3 conditions matches

Test if any of 3 conditions matches

Choose: Default action executed

Stopped because an error was encountered at June 28, 2023 at 9:52:36 PM (runtime: 0.07 seconds)

Transition value 0 is not valid.

For now, as a workaround I have transitions enabled and 0.1 for on and off values.
Hope to hear back from you. This community seems to be great!

choose:

  • alias: Check if the night lights are enabled and within the time
    conditions:
    • condition: time
      after: ‘22:30:00’
      before: ‘08:00:00’
    • ‘{{ include_night_lights == ‘‘night_lights_enabled’’ }}’
      sequence:
    • choose:
      • alias: By-pass is turned on & check by-pass option - turn lights off
        conditions:
        • condition: trigger
          id: t6
        • condition: template
          value_template: ‘{{ include_bypass == ‘‘bypass_enabled’’ }}’
          sequence:
        • alias: Wait the number of minutes set in the by-pass time delay
          delay:
          minutes: 0
        • alias: Turn off the lights
          service: light.turn_off
          target:
          entity_id: ‘{{ night_light_entities }}’
          data:
          transition: ‘{{ night_transition_off_value }}’
        • alias: Turn off the switches
          service: switch.turn_off
          target:
          entity_id: ‘{{ night_switch_entities }}’
        • alias: Turn off the scenes
          service: scene.turn_on
          entity_id: []
          data:
          transition: ‘{{ night_transition_off_value }}’
        • stop: Stop the automation
      • alias: By-pass is turned on & check by-pass option - leave lights on
        conditions:
        • condition: trigger
          id: t6
        • condition: template
          value_template: ‘{{ include_bypass == ‘‘bypass_enabled_stop’’ }}’
          sequence:
        • stop: Stop the automation
      • alias: By-pass is turned off & check if the motion trigger is off
        conditions:
        • condition: trigger
          id: t7
        • condition: state
          entity_id:
          • binary_sensor.dinning_room_sensor_occupancy
            match: all
            state: ‘off’
            sequence:
        • alias: Wait the number of minutes set in the by-pass time delay
          delay:
          minutes: 0
        • alias: Turn off the lights
          service: light.turn_off
          target:
          entity_id: ‘{{ night_light_entities }}’
          data:
          transition: ‘{{ night_transition_off_value }}’
        • alias: Turn off the switches
          service: switch.turn_off
          target:
          entity_id: ‘{{ night_switch_entities }}’
        • alias: Turn off the scenes
          service: scene.turn_on
          entity_id: []
          data:
          transition: ‘{{ night_transition_off_value }}’
        • stop: Stop the automation
      • alias: Reset the lights when trigger by night start time
        conditions:
        • condition: trigger
          id: t5
          sequence:
        • alias: Turn off the lights
          service: light.turn_off
          target:
          entity_id: ‘{{ crossover_lights_light }}’
          data:
          transition: ‘{{ transition_off_value }}’
        • alias: Turn off the switches
          service: switch.turn_off
          target:
          entity_id: ‘{{ crossover_lights_switch }}’
        • alias: Turn off the scenes
          service: scene.turn_on
          entity_id: []
          data:
          transition: ‘{{ transition_off_value }}’
      • alias: Sun, Ambient Light Sensor & time above setting to turn off
        conditions:
        • condition: trigger
          id:
          • t8
          • t9
          • t10
            sequence:
        • alias: Wait the number of minutes set in the by-pass time delay
          delay:
          minutes: 0
        • alias: Turn off the lights
          service: light.turn_off
          target:
          entity_id: ‘{{ night_light_entities }}’
          data:
          transition: ‘{{ night_transition_off_value }}’
        • alias: Turn off the switches
          service: switch.turn_off
          target:
          entity_id: ‘{{ night_switch_entities }}’
        • alias: Turn off the scenes
          service: scene.turn_on
          entity_id: []
          data:
          transition: ‘{{ night_transition_off_value }}’
        • stop: Stop the automation
      • alias: Safe Guard when HA restarts
        conditions:
        • condition: trigger
          id: t12
          sequence:
        • alias: Check automation and preform the correct action
          if:
          • alias: Check if the motion trigger is on
            condition: state
            entity_id:
            • binary_sensor.dinning_room_sensor_occupancy
              state: ‘on’
              match: any
              then:
          • alias: We need something here for the IF to continue
            delay:
            seconds: 1
            else:
          • alias: >-
            Wait the number of minutes set in the night lights time
            delay
            delay:
            minutes: 5
          • alias: Turn off the lights
            service: light.turn_off
            target:
            entity_id: ‘{{ night_light_entities }}’
            data:
            transition: ‘{{ night_transition_off_value }}’
          • alias: Turn off the switches
            service: switch.turn_off
            target:
            entity_id: ‘{{ night_switch_entities }}’
          • alias: Turn off the scenes
            service: scene.turn_on
            entity_id: []
            data:
            transition: ‘{{ night_transition_off_value }}’
          • stop: Stop the automation
    • choose:
      • alias: Set the brightness and transition for the night lights switch
        conditions:
        • condition: template
          value_template: >-
          {{ (‘use_brightness’ in include_night_light_control) and not
          (‘use_colour_temperature’ in include_night_light_control) }}
          sequence:
        • service: light.turn_on
          target:
          entity_id: ‘{{ night_light_entities_off }}’
          data:
          brightness_pct: ‘{{ night_brightness_value }}’
          transition: ‘{{ night_transition_on_value }}’
    • choose:
      • alias: Set the brightness and transition for the night lights switch
        conditions:
        • condition: template
          value_template: >-
          {{ (‘use_brightness’ in include_night_light_control) and
          (‘use_colour_temperature’ in include_night_light_control) }}
          sequence:
        • service: light.turn_on
          target:
          entity_id: ‘{{ night_light_entities_off }}’
          data:
          brightness_pct: ‘{{ night_brightness_value }}’
          kelvin: ‘{{night_temperature_value}}’
          transition: ‘{{ night_transition_on_value }}’
    • choose:
      • alias: Set the brightness and transition for the night lights switch
        conditions:
        • condition: template
          value_template: >-
          {{ (‘use_colour_temperature’ in include_night_light_control)
          and not (‘use_brightness’ in include_night_light_control) }}
          sequence:
        • service: light.turn_on
          target:
          entity_id: ‘{{ night_light_entities_off }}’
          data:
          kelvin: ‘{{night_temperature_value}}’
          transition: ‘{{ night_transition_on_value }}’
    • choose:
      • alias: Set the transition for the night lights switch - Default
        conditions:
        • condition: template
          value_template: >-
          {{ (‘use_brightness’ not in include_night_light_control) and
          (‘use_colour_temperature’ not in include_night_light_control)
          }}
          sequence:
        • service: light.turn_on
          target:
          entity_id: ‘{{ night_light_entities_off }}’
          data:
          transition: ‘{{ night_transition_on_value }}’
    • alias: Turn on the switches
      service: switch.turn_on
      target:
      entity_id: ‘{{ night_switch_entities_off }}’
    • alias: Turn on the scenes
      service: scene.turn_on
      target:
      entity_id: ‘{{ night_scene_entities }}’
      data:
      transition: ‘{{ night_transition_on_value }}’
    • choose:
      • alias: By-pass is enabled & check by-pass option - turn lights on
        conditions:
        • condition: trigger
          id: t6
        • condition: template
          value_template: ‘{{ include_bypass == ‘‘bypass_enabled_turn_on’’ }}’
          sequence:
        • stop: Stop the automation
      • alias: Check if the trigger is on and wait for it to go off
        conditions:
        • condition: state
          entity_id:
          • binary_sensor.dinning_room_sensor_occupancy
            state: ‘on’
            match: any
            sequence:
        • alias: Wait until motion sensor is off
          wait_for_trigger:
          platform: state
          entity_id:
          - binary_sensor.dinning_room_sensor_occupancy
          from: ‘on’
          to: ‘off’
    • alias: Wait the number of minutes set in the night lights time delay
      delay:
      minutes: 5
    • alias: Turn off the lights
      service: light.turn_off
      target:
      entity_id: ‘{{ night_light_entities }}’
      data:
      transition: ‘{{ night_transition_off_value }}’
    • alias: Turn off the switches
      service: switch.turn_off
      target:
      entity_id: ‘{{ night_switch_entities }}’
    • alias: Turn off the scenes
      service: scene.turn_on
      entity_id: []
      data:
      transition: ‘{{ night_transition_off_value }}’
      default:
  • choose:
    • alias: By-pass is turned on & check by-pass option - turn lights off
      conditions:
      • condition: trigger
        id: t6
      • condition: template
        value_template: ‘{{ include_bypass == ‘‘bypass_enabled’’ }}’
        sequence:
      • alias: Wait the number of minutes set in the by-pass time delay
        delay:
        minutes: 0
      • alias: Turn off the lights
        service: light.turn_off
        target:
        entity_id: ‘{{ light_entities }}’
        data:
        transition: ‘{{ transition_off_value }}’
      • alias: Turn off the switches
        service: switch.turn_off
        target:
        entity_id: ‘{{ switch_entities }}’
      • alias: Turn off the scenes
        service: scene.turn_on
        entity_id: []
        data:
        transition: ‘{{ transition_off_value }}’
      • stop: Stop the automation
    • alias: By-pass is turned on & check by-pass option - leave lights on
      conditions:
      • condition: trigger
        id: t6
      • condition: template
        value_template: ‘{{ include_bypass == ‘‘bypass_enabled_stop’’ }}’
        sequence:
      • stop: Stop the automation
    • alias: By-pass is turned off & check if the motion trigger is off
      conditions:
      • condition: trigger
        id: t7
      • condition: state
        entity_id:
        • binary_sensor.dinning_room_sensor_occupancy
          match: all
          state: ‘off’
          sequence:
      • alias: Wait the number of minutes set in the by-pass time delay
        delay:
        minutes: 0
      • alias: Turn off the lights
        service: light.turn_off
        target:
        entity_id: ‘{{ light_entities }}’
        data:
        transition: ‘{{ transition_off_value }}’
      • alias: Turn off the switches
        service: switch.turn_off
        target:
        entity_id: ‘{{ switch_entities }}’
      • alias: Turn off the scenes
        service: scene.turn_on
        entity_id: []
        data:
        transition: ‘{{ transition_off_value }}’
      • stop: Stop the automation
    • alias: Sun, Ambient Light Sensor & time above setting to turn off
      conditions:
      • condition: trigger
        id:
        • t8
        • t9
        • t10
          sequence:
      • alias: Wait the number of minutes set in the normal lights time delay
        delay:
        minutes: 5
      • alias: Turn off the lights
        service: light.turn_off
        target:
        entity_id: ‘{{ light_entities }}’
        data:
        transition: ‘{{ transition_off_value }}’
      • alias: Turn off the switches
        service: switch.turn_off
        target:
        entity_id: ‘{{ switch_entities }}’
      • alias: Turn off the scenes
        service: scene.turn_on
        entity_id: []
        data:
        transition: ‘{{ transition_off_value }}’
      • stop: Stop the automation
    • alias: Reset lights when trigger by night end time
      conditions:
      • condition: trigger
        id: t11
      • ‘{{ include_night_lights == ‘‘night_lights_enabled’’ }}’
        sequence:
      • alias: Turn off the lights
        service: light.turn_off
        target:
        entity_id: ‘{{ crossover_night_lights_light }}’
        data:
        transition: ‘{{ night_transition_off_value }}’
      • alias: Turn off the switches
        service: switch.turn_off
        target:
        entity_id: ‘{{ crossover_night_lights_switch }}’
      • alias: Turn off the scenes
        service: scene.turn_on
        entity_id: []
        data:
        transition: ‘{{ night_transition_off_value }}’
    • alias: Safe Guard when HA restarts
      conditions:
      • condition: trigger
        id: t12
        sequence:
      • alias: Check automation and preform the correct action
        if:
        • alias: Check if the motion trigger is on
          condition: state
          entity_id:
          • binary_sensor.dinning_room_sensor_occupancy
            state: ‘on’
            match: any
            then:
        • alias: We need something here for the IF to continue
          delay:
          seconds: 1
          else:
        • alias: Wait the number of minutes set in the normal lights time delay
          delay:
          minutes: 5
        • alias: Turn off the lights
          service: light.turn_off
          target:
          entity_id: ‘{{ light_entities }}’
          data:
          transition: ‘{{ transition_off_value }}’
        • alias: Turn off the switches
          service: switch.turn_off
          target:
          entity_id: ‘{{ switch_entities }}’
        • alias: Turn off the scenes
          service: scene.turn_on
          entity_id: []
          data:
          transition: ‘{{ transition_off_value }}’
        • stop: Stop the automation
  • choose:
    • alias: Set the brightness and transition for the normal lights switch
      conditions:
      • condition: template
        value_template: >-
        {{ (‘use_brightness’ in include_light_control) and not
        (‘use_colour_temperature’ in include_light_control) }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: ‘{{ light_entities_off }}’
        data:
        brightness_pct: ‘{{ brightness_value }}’
        transition: ‘{{ transition_on_value }}’
  • choose:
    • alias: Set the brightness and transition for the normal lights switch
      conditions:
      • condition: template
        value_template: >-
        {{ (‘use_brightness’ in include_light_control) and
        (‘use_colour_temperature’ in include_light_control) }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: ‘{{ light_entities_off }}’
        data:
        brightness_pct: ‘{{ brightness_value }}’
        kelvin: ‘{{temperature_value}}’
        transition: ‘{{ transition_on_value }}’
  • choose:
    • alias: Set the brightness and transition for the normal lights switch
      conditions:
      • condition: template
        value_template: >-
        {{ (‘use_colour_temperature’ in include_light_control) and not
        (‘use_brightness’ in include_light_control) }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: ‘{{ light_entities_off }}’
        data:
        kelvin: ‘{{temperature_value}}’
        transition: ‘{{ transition_on_value }}’
  • choose:
    • alias: Set the transition for the normal lights switch - Default
      conditions:
      • condition: template
        value_template: >-
        {{ (‘use_brightness’ not in include_light_control) and
        (‘use_colour_temperature’ not in include_light_control) }}
        sequence:
      • service: light.turn_on
        target:
        entity_id: ‘{{ light_entities_off }}’
        data:
        transition: ‘{{ transition_on_value }}’
  • alias: Turn on the switches
    service: switch.turn_on
    target:
    entity_id: ‘{{ switch_entities_off }}’
  • alias: Turn on the scenes
    service: scene.turn_on
    target:
    entity_id: ‘{{ scene_entities }}’
    data:
    transition: ‘{{ transition_on_value }}’
  • choose:
    • alias: By-pass is enabled & check by-pass option - turn lights on
      conditions:
      • condition: trigger
        id: t6
      • condition: template
        value_template: ‘{{ include_bypass == ‘‘bypass_enabled_turn_on’’ }}’
        sequence:
      • stop: Stop the automation
    • alias: Check if the trigger is on and wait for it to go off
      conditions:
      • condition: state
        entity_id:
        • binary_sensor.dinning_room_sensor_occupancy
          state: ‘on’
          match: any
          sequence:
      • alias: Wait until motion sensor is off
        wait_for_trigger:
        platform: state
        entity_id:
        - binary_sensor.dinning_room_sensor_occupancy
        from: ‘on’
        to: ‘off’
  • alias: Wait the number of minutes set in the normal lights time delay
    delay:
    minutes: 5
  • alias: Turn off the lights
    service: light.turn_off
    target:
    entity_id: ‘{{ light_entities }}’
    data:
    transition: ‘{{ transition_off_value }}’
  • alias: Turn off the switches
    service: switch.turn_off
    target:
    entity_id: ‘{{ switch_entities }}’
  • alias: Turn off the scenes
    service: scene.turn_on
    entity_id: []
    data:
    transition: ‘{{ transition_off_value }}’

sorry for the huge unload but hope that helps pinpoint the issue