How to do an 'intelligent' timer switch?

Done, works perfect! :slight_smile:

script:
  - id: timer_schody
    then:
      - switch.turn_on: Out_4
      - delay: 100s
      - switch.turn_off: Out_4     

switch:
  - platform: gpio 
      id: In5
      on_click:
      - min_length: 50ms
        max_length: 1000ms
        then:
          - if:
              condition:
                  lambda: 'return id(Out_4).state;'
              then:
                  - switch.turn_off: Out_4
                  - script.stop: timer_schody
              else:
                  - script.execute: timer_schody
      - min_length: 1000ms
        max_length: 5000ms
        then:
          - script.stop: timer_schody
          - switch.turn_on: Out_4      

Thank you both for good hint!

4 Likes