- id: '1590253197249'
alias: BATHROOM EXTRACTOR RESTART TIMER
description: ''
trigger:
- entity_id: binary_sensor.motion_detector_bathroom
platform: state
to: 'on'
condition:
- condition: state
entity_id: timer.bathroom_extractor_fan_on_time
state: active
action:
- service: script.turn_off
entity_id: script.1590247487069
- data: {}
service: script.1590247487069
EDIT: Wait a second…
Why doesn’t it work? It should. Given that the script does not have any delays or wait_templates, you shouldn’t have to do what I just showed above. It should have worked the way you had it.
It works fine as is, must of forgotten to reload scripts and automation.
When I re trigger the P.I.R. input timer resets to the predetermined value and begins to count down again, relay status remains as is (ON) until timer reaches 0 .
Full code as is of now.
/config/configuration.yaml
- id: '1590242331904'
alias: BATHROOM EXTRACTOR FAN ON DELAY
description: ''
trigger:
- entity_id: binary_sensor.motion_detector_bathroom
platform: state
to: 'on'
condition:
- condition: not
conditions:
- condition: state
entity_id: timer.bathroom_extractor_fan_on_time
state: active
action:
- data_template:
duration: 00:00:{{ states.input_number.extractor_fan_delay.state | int }}
entity_id: timer.bathroom_extractor_fan_delay
service: timer.start
- id: '1590248302612'
alias: BATHROOM EXTRACTOR FAN RUN TIME
description: ''
trigger:
- entity_id: timer.bathroom_extractor_fan_delay
platform: state
to: idle
condition: []
action:
- data: {}
service: script.1590247487069
- id: '1590248678506'
alias: BATHROOM EXTRACTOR FAN OFF
description: ''
trigger:
- entity_id: timer.bathroom_extractor_fan_on_time
platform: state
to: idle
condition: []
action:
- data: {}
entity_id: switch.extractor_fan_relay
service: switch.turn_off
- id: '1590253197249'
alias: BATHROOM EXTRACTOR RESTART TIMER
description: ''
trigger:
- entity_id: binary_sensor.motion_detector_bathroom
platform: state
to: 'on'
condition:
- condition: and
conditions:
- condition: state
entity_id: timer.bathroom_extractor_fan_on_time
state: active
action:
- data: {}
service: script.1590247487069
/config/scripts.yaml
'1590247487069':
alias: Bathroom Extractor Run Time
sequence:
- data_template:
duration: 00:{{ states.input_number.extractor_fan_run_time.state | int }}
entity_id: timer.bathroom_extractor_fan_on_time
service: timer.start
- data: {}
entity_id: switch.extractor_fan_relay
service: switch.turn_on
All that remains for now is to add the humidity control as trigger but that should not be a problem.
Regards,