input_number: mins_count: name: mins_count initial: 0 min: 0 max: 60 step: 2 automation: alias: Notify every 2 mins while door open trigger: - entity_id: binary_sensor.your_door platform: state to: 'on' for: minutes: 2 mode: single action: #reset count - service: input_number.set_value target: entity_id: input_number.mins_count data: value: 0 - repeat: while: - condition: state entity_id: binary_sensor.your_door state: 'on' # Don't do it too many times - condition: template value_template: "{{ repeat.index <= 30 }}" sequence: #mins + 2 - service: input_number.increment target: entity_id: input_number.mins_count - service: notify.line_notify data: message: 門已開了{{ states.input_number.mins_count.state|int }}分鐘了,趕快關! # Wait for sensor to change to 'off' up to 2 minutes before continuing to execute - wait_template: "{{ is_state('binary_sensor.your_door', 'off') }}" timeout: "00:02:00" #if repeat>30 make sure notify won't send - condition: state entity_id: binary_sensor.your_door state: 'off' - service: notify.line_notify data: message: 門已關