Timer duration template with input_select

Hi guys, I need help please.
I would like to set the duration of a timer from one input_select. It’s possible?
I have manually set 15 minutes (00:15:00) to my timer, but I wanted to be able to choose the time the switch stays on

Captura de ecrã 2021-06-30, às 18.35.23

Like this.

Captura de ecrã 2021-06-30, às 18.35.34

  - alias: garden
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.buttonwater
        to: 'on'
        for: "{{ states('input_select.temporiza') | int }}"
    action:
      - service: switch.turn_off
        entity_id: switch.rega_jardim
- alias: Timer stop 
  description: ''
  trigger:
  - platform: state
    entity_id: switch.rega_jardim
    from: 'on'
    to: 'off'
  condition: []
  action:
  - service: timer.finish
    target:
      entity_id: timer.tempo_rega

I’m doing something wrong but I don’t know what.
Many thanks from help :pray:

2 Likes

try this

- id: 'garden'
  alias: garden
  initial_state: true
  trigger:
  - platform: state
    entity_id: switch.rega_jardim
    to: 'on'
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.tempo_rega
  action:
  - choose:
      - conditions:
          - "{{ trigger.platform == 'state' }}"
        sequence:
          - data:
              entity_id: timer.tempo_rega
              duration: "{{ states('input_select.temporiza') }}"
            service: timer.start
      - conditions:
          - "{{ trigger.platform == 'event' }}"
        sequence:
          - data:
              entity_id: switch.rega_jardim
            service: switch.turn_off
2 Likes