trying this with a timer and I cant seem to get the light to turn off after no motion…guessing my condition in the second automation is the issue, but why?
############Office Motion Day ##################
- id: office_day_motion
alias: Office Motion
trigger:
platform: state
entity_id: binary_sensor.office_sensor
to: 'on'
condition:
condition: state
entity_id: sun.sun
state: 'above_horizon'
action:
- service: timer.start
entity_id: timer.office_motion
- service: light.turn_on
entity_id: light.officedesk
data:
kelvin: 2700
brightness: 254
transition: 10
#############Office No Motion ###################
- id: office_timer
alias: Turn off office after no motion (10 mins)
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.office_timer
condition:
condition: state
entity_id: binary_sensor.office_sensor
state: 'off'
action:
service: light.turn_off
entity_id: light.officedesk
data:
transition: 10
In my experience the timer will just run out instead of restarting when the trigger cycles. Adding a cancel before a start command will restart the timer every time the binary sensor is turned on. You would not need the condition on your second automation.
############Office Motion Day ##################
- id: office_day_motion
alias: Office Motion
trigger:
platform: state
entity_id: binary_sensor.office_sensor
to: 'on'
condition:
condition: state
entity_id: sun.sun
state: 'above_horizon'
action:
- service: timer.cancel
entity_id: timer.office_motion
- service: timer.start
entity_id: timer.office_motion
- service: light.turn_on
entity_id: light.officedesk
data:
kelvin: 2700
brightness: 254
transition: 10
#############Office No Motion ###################
- id: office_timer
alias: Turn off office after no motion (10 mins)
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.office_timer
action:
service: light.turn_off
entity_id: light.officedesk
data:
transition: 10