Hi all,
I have a bedroom lighting automation that turns on lights when motion is detected and turns them off after a timer expires. The problem is that subsequent motion doesn’t reliably restart the timer - sometimes it works, sometimes it doesn’t, even though the automation trace shows the correct branch was executed.
The strange part: When I test this manually in Developer Tools (calling timer.start on a running timer), it always restarts correctly. But in real-world usage, the timer often doesn’t restart.
Setup
- Home Assistant version: 2025.12.3
- PIR sensors: 2x Philips Hue Motion Sensors connected via Zigbee2MQTT
- PIR settings: Occupancy timeout = 5 seconds, Motion sensitivity = max
- Binary sensor group:
binary_sensor.bedroom_pirs(Group helper with “All entities” = OFF, so it triggers when ANY sensor detects motion) - Timer:
timer.bedroom_lightwith 60 second duration (morning is 5 mins)
Automation Logic
The automation should:
- When motion detected + lights are off + media not playing → turn on lights + start 60s timer
- When motion detected again (while lights are on) → restart timer
- When timer finishes → turn off lights
Current Behavior
First motion → lights turn on, timer starts (60s)
Subsequent motion → sometimes restarts timer, sometimes doesn’t- Timer expires → lights turn off (even though I’m still in the room, andi can see sensor see me)
It worked before! after some upgrade it stopped and i am not able to find out why and what is the cause.
What I’ve Checked
- Entity states: All conditions appear to be met (other lights off, media off, darkness on)
- PIR behavior: Logbook shows the PIRs are detecting motion (off→on and on→off transitions)
- Timer behavior: Works correctly when tested manually in Developer Tools using actions
- Automation mode:
single(also triedrestartwith same results)
Here is a part of automation code. (there are more lights at the room code is not complete. Important part is mentioned here (motion and timer finish)
alias: Bedroom Light
description: ''
triggers:
- alias: Motion Detected
trigger: state
entity_id:
- binary_sensor.bedroom_pirs
from: 'off'
to: 'on'
id: motion
- alias: Lamps
trigger: state
entity_id:
- light.bedroom_lamps
to:
id: lamps
- trigger: state
entity_id:
- light.bedroom_dimmer_ceiling
to:
id: ceiling
alias: Ceiling Light
- alias: Kodi-Bedroom
trigger: state
entity_id:
- media_player.kodi_bedroom
to:
id: kodi
- trigger: state
entity_id:
- media_player.lg_webos_tv_bedroom
to:
id: lgtv
alias: LGTV
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.bedroom_light
id: timer.finished
alias: Timer
conditions:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.smart_darkness
state: 'on'
- condition: state
entity_id: input_boolean.automatic_lights
state: 'on'
- condition: trigger
id:
- timer.finished
actions:
- choose:
- conditions:
- condition: and
conditions:
- condition: trigger
id:
- motion
- condition: state
entity_id: light.bedroom_dimmer_ceiling
state: 'off'
- condition: state
entity_id: light.bedroom_lamps
state: 'off'
- condition: state
entity_id: sensor.media_status_bedroom
state:
- 'off'
sequence:
- action: timer.cancel
target:
entity_id: timer.bedroom_light
- if:
- condition: state
entity_id: sensor.time_of_day
state: morning
then:
- action: timer.start
target:
entity_id: timer.bedroom_light
data:
duration: '00:05:00'
else:
- action: timer.start
target:
entity_id: timer.bedroom_light
data:
duration: '00:00:60'
- action: scene.turn_on
target:
entity_id: scene.bedroom_motion
alias: Motion
# ... other branches for lamps, ceiling, kodi, etc.
- conditions:
- condition: trigger
id:
- timer.finished
- condition: or
conditions:
- condition: state
entity_id: media_player.lg_webos_tv_bedroom
state: 'off'
- condition: state
entity_id: media_player.lg_webos_tv_bedroom
state:
- unavailable
sequence:
- type: turn_off
device_id: 4748e927444d894569caf861b2e50b1e
entity_id: ca5472cdc9d904cf1e05d527e5aeea3f
domain: light
alias: Time Finished
mode: single
Current work i am trying to make is reliable and more simple using sensor for media. LGTV, KODI sometimes return unexpected state (unavailable).
Helper Sensor for Media Status
- name: "Media Status Bedroom"
unique_id: "media_status_bedroom"
state: |
{% if is_state('media_player.kodi_bedroom', 'playing') %}
playing
{% elif is_state('media_player.kodi_bedroom', 'paused') %}
paused
{% elif is_state('media_player.lg_webos_tv_bedroom', 'on') %}
on
{% else %}
off
{% endif %}
Binary Sensor Group
Created via UI Helper:
- Type: Binary sensor group
- Members:
binary_sensor.bedroom_pir_bed_1_occupancy,binary_sensor.bedroom_pir_bed_2_occupancy - “All entities” option: OFF (triggers when ANY member is on)
Questions
- Could the Binary Sensor Group helper be causing timing issues with the state transitions?
- Is there a known issue with Philips Hue PIRs via Zigbee2MQTT and occupancy detection?
- Should I use a different approach for motion detection (e.g., template sensor instead of group)?
- Any ideas why
timer.startwould work in Developer Tools but not reliably in automation?
What I’ve Already Tried
- Changed occupancy timeout from 0 to 5 seconds
- Verified all condition entities have correct states
- Checked automation traces
- Tested timer.start manually (works fine)
Any help would be appreciated!
