Not entirely sure if this is the correct place to post the request.
Fairly new (and by that i mean a matter of weeks) to using Home Assistant and trying to make what feels like a complicated automation for some lights/motion.
The idea is to create an automation that when it’s sunset and motion is detected for a light it comes on, when motion is no longer detected after a set time the light turns off.
If motion is detected between 22:00 and 7:00 it turns on at a low brightness for a set time before motion is no longer detected and then turning the light off.
I’ve probably completely made this more complicated that it needs to be but this is the general idea of what im trying to create… Hopefully it makes sense.
Based on what I can see in your unformatted automation, the following automation should effectively do the same thing. It turns on the light whenever motion is detected. The light is normally set to 100% brightness except during the night when it will be set to 20%. It turns off the light when there’s no motion for at least 1 minute.
The only difference is that, unlike your version, the period of “no motion” is fixed at 1 minute. Your version seems to reduce it to 30 seconds during the night. In order to simplify the automation, I set it to 1 minute regardless of the time of day.
alias: Landing Motion
description: ""
trigger:
- platform: state
target:
entity_id: binary_sensor.landing_motion_iaszone_2
from: 'off'
to: 'on'
- platform: state
target:
entity_id: binary_sensor.landing_motion_iaszone_2
from: 'on'
to: 'off'
for: '00:01:00'
condition: []
action:
- service: light.turn_on
target:
entity_id: light.landing_light_light
data:
brightness_pct: >
{% set is_dark = now().hour >= 22 or now().hour < 7 %}
{{ 0 if trigger.to_state.state == 'off' else 20 if is_dark else 100 }}"