I have 2 automations that appear to not play well together. The first uses a motion sensor to turn on and off bathroom lights and the second primarily controls a space heater in the same bathroom. When someone is taking a shower I would like the light to stay on just a little longer than the heater. The heater automation is controlled by an NFC tag. I have that tag enable the heater and the lights for 45 minutes plus a small delay when turning off the heater before the lights turn off and once again become the domain of the motion controller.
What appears to be happening is the the motion sensor turns the lights on when entering, as expected. Then the tag is scanned turning on the heater and the lights for 45 minutes controlled by a delay in that automation. But it appears that the motion sensor delay is shutting the lights off early thus overriding the 45 minute delay in the heater automation.
So, I think that somehow the heater automation needs to interact with the motion sensor automation.
Heater tag scan automation:
- id: nfc bathroom heat
alias: NFC bathroom heat
mode: restart
trigger:
- platform: tag
tag_id: 5c75bdd6-20d2-4d08-a28b-a3944363782c
action:
- choose:
- conditions:
- condition: state
entity_id: switch.bathroom_heater
state: 'off'
sequence:
- service: switch.turn_on
entity_id: switch.bathroom_heater
- service: light.turn_on
entity_id: light.bathroom_1,light.bathroom_2
- delay:
minutes: 45
- service: switch.turn_off
entity_id: switch.bathroom_heater
- conditions:
- condition: state
entity_id: switch.bathroom_heater
state: 'on'
sequence:
- service: switch.turn_off
entity_id: switch.bathroom_heater
- delay:
minutes: 5
- service: light.turn_off
entity_id: light.bathroom_1,light.bathroom_2
Motion automation:
- id: Bathroom motion
alias: Bathroom motion
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_158d0001644ca3
to:
- 'on'
- 'off'
mode: restart
action:
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
- condition: time
after: '08:00:00'
before: '23:00:00'
sequence:
- service: light.turn_on
entity_id: light.bathroom_1,light.bathroom_2,light.toolbox
data:
brightness: 254
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'on' }}"
- condition: time
after: '23:00:00'
before: '05:30:00'
sequence:
- service: light.turn_on
entity_id: light.bathroom_1,light.bathroom_2,light.toolbox,light.sink
data:
brightness: 20
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'off' }}"
- condition: time
after: '07:45:00'
before: '05:15:00'
sequence:
- delay: "00:15"
- service: light.turn_off
entity_id: light.bathroom_1,light.bathroom_2,light.toolbox,light.sink
Would this be as simple as setting the motion sensor to off before triggering the lights? But, if I did that and someone triggered the sensor it would start the whole error over?
I am going to be gone for a few days and may not be able to reply, but will be watching the discussion and will work on it more when I get back.