Is there someone how can help me out ? The light should turn on if someone is at home and the sun is down but only until it is 23:59 and from 5:30 to sunrise
alias: Flurlicht an
description: ''
trigger:
- type: motion
platform: device
device_id: ae817ea4086f37be22d0fc061b9db293
entity_id: binary_sensor.motion_2_on_off
domain: binary_sensor
condition:
- condition: sun
after: sunset
before: sunrise
- condition: and
conditions:
- condition: time
before: '23:59:00'
after: '05:30:00'
- condition: and
conditions:
- condition: state
entity_id: group.presence_home
state: home
action:
- type: turn_on
device_id: 72cea12b2714e62e250e2dd503ffb25c
entity_id: light.signify_netherlands_b_v_lwb010_level_on_off
domain: light
brightness_pct: 20
- type: turn_on
device_id: fbdf7baad3ac3502106c472016e69204
entity_id: light.signify_netherlands_b_v_lwb010_0cb81e04_level_on_off
domain: light
brightness_pct: 20
mode: single
It is hard to debug on sight, so make sure to look at execution traces to see if the trigger even happens and/or where things fail. Also you did not really describe what you experience.
First of all: are you sure you’re triggering on the right entity? The name sounds like it does something else. I assume you’re meaning to trigger on motion detection?
Second: it is probably not what is going wrong, but you’re using and conditions the wrong way. It looks like you are placing them between conditions, but that is not how they work. And conditions should have at least two conditions below it, each must be true. You have an and with one clause.
Also, and clauses are not needed here - if you put multiple conditions below each other they also must all succeed (unless they’re below an or clause of course). So you can simplyfy by removing both ands and just put the conditions below one another with the same indenting.
To debug build it up step by step: first only trigger and action, if that works start adding in extra conditions.
And some other food for thought: does your motion sensor have a lux sensor too? Your assumtion that it is not dark between sunrise and sunset is not always correct. I prefer the actual test (it is dark) over the expected cause for darkness myself. I never use sunset/sunrise but look at the lux value.
also, you should never use both “after sunset & before sunrise” in same condition ( either or ) use instead
entity_id: sun.sun
state: below_horizon
There are a usefull documentation in regards to Automation, with “Conditions” type etc
PS: as Edwin also pointed out, start with a simple “function” , and if your in total “newbee” state, you would save a-lot time, and hairs, on your head, make 2 simple, 1 for before 23.59 & 1 for after 5.30, as im doubt-full to
- condition: time
before: '23:59:00'
after: '05:30:00'
you might need to squeeze “or” in somewhere … so Make it basic, then “grow as you learn”