Hi everyone,
I’m trying to set up an automation in Home Assistant to control the lighting in my hallway. I want the light to:
- Turn on automatically when motion is detected in the hallway between 6:00 PM and 6:00 AM on all weekdays.
- Stay on as long as motion is detected in the hallway.
- Turn off automatically 45 seconds after motion was last detected.
Problem:
- The light turns off after 45 seconds, even if I continue to move in the hallway.
What I’ve tried:
- I have added a condition to check if the sensor is detecting “on” (motion).
- I have adjusted the time delay to different values.
Automation code:
alias: "Gang- Nattmodus - 45s forsinkelse "
description: >-
Nattmodus - Gangbelysning: Automatiseringen slår på lyset i gangen ved
deteksjon av bevegelse etter kl. 20:00 og før kl. 06:00 på hverdager
(mandag-fredag). Lyset vil forbli på i 45 sekunder før det slås av automatisk.
trigger:
- platform: state
entity_id:
- binary_sensor.gangen
from: "off"
to: "on"
condition:
- condition: time
after: "18:00:00"
before: "06:00:00"
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
- condition: state
entity_id: binary_sensor.gangen
state: "on"
action:
- service: light.turn_on
metadata: {}
data:
brightness_pct: 20
target:
area_id: gang
- delay: "00:00:45"
- service: light.turn_off
metadata: {}
data: {}
target:
area_id: gang
mode: restart
Questions:
- How can I get the automation to keep the light on as long as motion is detected in the hallway?
- Is there anything else I can improve in my automation?
Additional information:
- Home Assistant Core: 2024.3.0
- Home Assistant Supervisor: 2024.03.0
- Home Assistant Operating System: 12.1.rc1
- Frontend: 20240306.0
- Device: Raspberry Pi 5 8 gb
- Motion sensor: Ikea Trådfri motion sensor
- Lights: Various Ikea Trådfri lights
Thank you for your help