#Automation turns on 2 lights, but turn one of them off again

1 messages · Page 1 of 1 (latest)

oak ginkgo
#

As you can see on the picture, i have an automation blueprint that turns on 2 lights in my kitchen when motion is detected, but one of the lights tends to turn off again right away. I have no clue why.

id: '1729173428057'
alias: Bevægelsesaktiveret lys Køkken
description: ''
use_blueprint:
  path: Blackshome/sensor-light.yaml
  input:
    motion_trigger:
      - binary_sensor.kokken_sensor_bevaegelse_aqara_occupancy
    light_switch:
      entity_id:
        - light.kokken_controller_ledstrip_miboxer
        - light.kokken_lampe_loft_shelly
    time_delay: 1
    include_light_control:
      - use_brightness
      - use_transition
      - use_colour_temperature
    light_transition_on: 3
    light_transition_off: 10
    light_colour_temperature: 3500
    night_lights:
      entity_id: light.kokken_controller_ledstrip_miboxer
    include_night_light_control:
      - use_brightness
      - use_transition
    night_light_transition_on: 3
    night_light_transition_off: 3
    night_lights_after_time: '23:00:00'
    night_lights_before_time: '05:00:00'```
severe maple
#

You're gonna need to share the blueprint you're using as well

oak ginkgo
#
#

Its this one

severe maple
#

and what does the trace of your binary_sensor.kokken_sensor_bevaegelse_aqara_occupancy look like during this time? because if it's turning on and then off again immediately that would explain this behaviour

oak ginkgo
#

How can i show you the trace? But it's not and the other light is not behaving like that, so it doesn't make sense

severe maple
#

click on the sensor and going into history

#

a trace for the automation when it was turning itself off would also be helpful (e.g. at 15:01:54)

oak ginkgo
#

Something like this?

severe maple
#

yup

#

so at 15:02ish it definitely turned on and didn't immediately turn off again, that is good

oak ginkgo
#

yes

#

it only happens sometimes

severe maple
#

ok, well a trace for one of the times it turned itself off would be useful to look at

oak ginkgo
#

how do i find that?

severe maple
#

click on the automation, and in the top right corner there should be TRACES

#

that will have a representation of what was going on when it ran, so you'll have to find one that happened when the light turned itself off wrong

oak ginkgo
#

Apparently i don't have one where it went wrong

#

But i have this

severe maple
#

idk man, this thing is huge - i would go ask the person who wrote it as they'll have a much better idea of what's going on

oak ginkgo
#

Already did, waiting for input from him as well

severe maple
#

ok then, well other than recommending you dig a bit further into it and get a hold of the trace when it next immediately turns off there's not much i can do to help without devoting an entire evening to reading this 6,000 line automation

oak ginkgo
#

okay, i get that. Can i write you on this post, when/if i get a trace?

severe maple
#

even with that, I don't think I can face looking through all of this. as soon as there are waits in an automation (4 minutes later) it gets so much harder working out why things are happening. This whole thing feels like it is about a thousand times too complicated to just turn lights on when a motion sensor goes off...

oak ginkgo
#

i got it! If that gives you anything obvious

iron sleet
#

There has got to be an easier way to accomplish what you want. This is madness.

iron sleet
#

Which is absurd

#

@oak ginkgo can you detail what you’re trying to do end to end and maybe we can get you to a better solution?

waxen sierra
#

All in one blueprints like this get out of control really easily. 5700+ lines of code is insane.

oak ginkgo
#

Sorry guys. Lack of knowledge drives you into getting these all-in-one's. I use them for all my motion-activated lights. I kinda like them, but i get they must be a nightmare to troubleshoot.
@iron sleet when motion is detected, i want both lights to turn on with a transition of 3 seconds, at a specified (and easy changed) brightness and color (chese can change temperature/glow, not color) and after 3 minutes of no detection, they should transition off over 5 seconds.
At night (23:00-06:00) only the light under the cabinets should turn on and at another brightness level.

iron sleet
#

This is easily done with a standard automation using ‘choose’ logic. I can write up
Something for you tomorrow afternoon.

severe maple
#

something like this should work

triggers:
  - trigger: state
    entity_id:
      - input_boolean.away_from_house
    from: "off"
    to: "on"
    id: turn_on
  - trigger: state
    entity_id:
      - input_boolean.away_from_house
    to: "off"
    for:
      hours: 0
      minutes: 3
      seconds: 0
    id: turn_off
conditions: []
actions:
  - variables:
      is_night: "{{ not (today_at('06:00') < now() < today_at('23:00')) }}"
      all_lights:
        - light.cabinets
        - light.other_lights
      night_lights:
        - light.cabinets
      turn_on_lights: "{{ night_lights if is_night else all_lights }}"
      set_brightness: "{{ 40 if is_night else 100 }}"
      set_color_temp: 3000
  - choose:
      - conditions:
          - condition: trigger
            id:
              - turn_on
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              brightness_pct: set_brightness
              color_temp_kelvin: set_color_temp
              transition: 3
            target:
              entity_id: turn_on_lights
      - conditions:
          - condition: trigger
            id:
              - turn_off
        sequence:
          - action: light.turn_off
            data:
              transition: 5
            target:
              entity_id: all_lights

But I don't actually have any lights hooked up to test with

oak ginkgo
# severe maple something like this should work ```yaml triggers: - trigger: state entity_...

Sorry, didn't see your answer. Got some questions for you:
Where should i put this? In an automation? In configuration.yaml?

triggers: < whats going on from here...
  - trigger: state
    entity_id:
      - input_boolean.away_from_house < Is this the motion detection?
    from: "off"
    to: "on"
    id: turn_on
  - trigger: state
    entity_id:
      - input_boolean.away_from_house 
    to: "off"
    for:
      hours: 0
      minutes: 3
      seconds: 0
    id: turn_off < to here??
conditions: []
actions:
  - variables:
      is_night: "{{ not (today_at('06:00') < now() < today_at('23:00')) }}" 
< can you tell me the logic of the line above this? ^^
      all_lights:
        - light.cabinets
        - light.other_lights
      night_lights:
        - light.cabinets
      turn_on_lights: "{{ night_lights if is_night else all_lights }}"
      set_brightness: "{{ 40 if is_night else 100 }}"
      set_color_temp: 3000
  - choose:
      - conditions:
          - condition: trigger
            id:
              - turn_on
        sequence:
          - action: light.turn_on
            metadata: {}
            data:
              brightness_pct: set_brightness
              color_temp_kelvin: set_color_temp
              transition: 3
            target:
              entity_id: turn_on_lights
      - conditions:
          - condition: trigger
            id:
              - turn_off
        sequence:
          - action: light.turn_off
            data:
              transition: 5
            target:
              entity_id: all_lights```
If i want to learn more about HA, coding and YAML, can you recommend me some (specific) videos, a playlist or a channel to watch?
For every question i've had about HA, regardless of me writing it here on Discord, in the HA community or even on Github, you have been there, helping me. Thank you so much for all your help recently.
severe maple
#

So there are 2 triggers, one when a boolean (should be changed to your motion detection) turns on that goes immediately with an id of "turn_on", and another one that triggers when it goes off for 3 minutes - in the actions we can then use these as conditions in the choose block to make sure the right trigger activates the right bit of code. you could split it out into 2 separate automations but imo that's messy.

#

the is_night variable is a template - "today_at(X)" gives you a datetime for well... today at X, so the format of A < now() < B basically checks if now() is between today at A and B (between 6am and 11pm. then put the whole thing in brackets and use the keyword "not" to flip it because we care about night - where A < now() < B would not be true, rather than day, when it is

#

you could also check now() < today_at(06:00) or now() > today_at(23:00) but I don't think that's as tidy

#

the reason i used all lights in the turn_off section is that if your lights turned on during daytime (just before 2300) and then it was after that when they wanted to turn off, it would just try to turn off the cabinet lights - and it doesn't cost anything to turn off a light that's already off