I have a small problem with some of my automations, regarding my outdoor light.
Currently my Outdoor Light turns on at sunset which seems to work as it should.
The problem occurs when I want to setup conditions with my Xiaomi Motion Sensors and the behaviour of the light when it gets triggered.
The main goal here is:
At sunset my spotlight gets turned on and set to 25%
When motion gets triggered, the light should boost to 100% and some extra light turns on.
The light should stay this way until motion detection changes state from on --> off (+5 minutes)
The above function is only valid during the weekdays from sunset to ‘00:15:00’.
Because at 00:15:00, the light will be switched off (That automation also works)
From ‘00:15:00’ to sunrise, the light will be OFF, but if the motion sensors get triggered, then the light should behave like this:
Turn all light on and set brightness to 100%
When Motion trigger changes state from ON --> OFF (add 5 minutes) turn off all light.
Here are some of the automations I’m working with:
- id: Turn Light OFF in Garden when Motion is OFF at night
alias: '[Outdoor] Baghave Motion Trigger OFF - Night'
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_1xxxxxxxxxxxxxxxxxxx
from: 'on'
to: 'off'
for:
minutes: 5
condition:
condition: time
after: '00:15:00'
weekday:
- mon
- tue
- wed
- thu
- fri
condition:
condition: sun
before: sunrise
action:
- service: light.turn_off
entity_id:
- light.led_path
- light.led_terrace
- light.baghave_bed_v
- light.backyard_bed_h
- light.backyard_spot
What am I doing wrong?
I need to have duplicate automations for the weekends, because the timing will be different.
Can I somehow do this even smarter or am I doing it correctly with different set of automations?
That’s valid yaml, (except on your second condition you have 2 condition lines, the top one needs to go) but there you have 2 conditions that both must be true for the automation to trigger, and it’s only before 0015 but between midnight and 0015 so that will only fire from midnight to 0015.
So - still a few issues here, so lets start with this one.
Can anyone see why this fails? The lights didn’t turn on, but if I manually run the rule the light do turn on:
But I seem to got it fixed (it worked last night. Had to stay up to test it :sleeping):
The first one takes care of the light from sunset until 01:30:00 next morning.
The second takes care of the light between 01:30:00 and sunrise.
Here is my two working codes:
- id: Backyard Motion Sensor Dim Light
alias: '[Udelys] Baghave Motion Sensor Dim Light'
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_1xxxxxxxxxxxxxxxxxxxx
from: 'on'
to: 'off'
for:
minutes: 5
condition:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: or
conditions:
- condition: sun
after: sunset
- condition: time
before: '01:30:00'
action:
- service: light.turn_off
entity_id:
- light.baghave_bed_v
- light.baghave_bed_h
- light.led_legehussti
- light.led_terrasse
- id: Backyard Motion Sensor Dim Light - Night
alias: '[Udelys] Baghave Motion Sensor Dim Light - Night'
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_1xxxxxxxxxxxxxxxxxxxxxxxxxx
from: 'on'
to: 'off'
for:
minutes: 5
condition:
- condition: and
conditions:
- condition: sun
before: sunrise
- condition: time
after: '01:30:00'
action:
- service: light.turn_off
entity_id:
- light.baghave_spot
- light.baghave_bed_v
- light.baghave_bed_h
- light.led_legehussti
- light.led_terrasse
So I was having my fingers crossed today, but unfortunately, my light didn’t turn on when the sunset was triggered. Does anyone have an idea why?
Should I try to put in an offset to see if that could do the trick?