Automating lights with a dynamic timer

Hello all,
I am desperately trying to out a dynamic delay using a helper and am failing.
To some degree, I understand why in one of the cases but in other I just can’t figure it out.

My automation is quite simple and it relays on one of the PIR sensors, so that when the movement is detected and the “night lights” are one, it turns on the car port lights and then turns them off after pre-determined time.

Now this works fine with this automation code:

- id: "00024"
  alias: Car Port Lights ON when there is movement
  description: This automation turns ON car port lights when there is movement
  trigger:
    - platform: mqtt
      topic: paradox/zone/state/25
      payload: "on"
  condition:
    condition: state
    entity_id: switch.backyard_night_lights_switch
    state: "on"
  action:
    - service: switch.turn_on
      entity_id: switch.car_port_lights_switch
    - delay:
        minutes: 1
        seconds: 30
        milliseconds: 0
    - service: switch.turn_off
      entity_id: switch.car_port_lights_switch
  mode: single

However, I then went and created an input number helper, so I tried like this:

- id: "00024"
  alias: Car Port Lights ON when there is movement
  description: This automation turns ON car port lights when there is movement
  trigger:
    - platform: mqtt
      topic: paradox/zone/state/25
      payload: "on"
  condition:
    condition: state
    entity_id: switch.backyard_night_lights_switch
    state: "on"
  action:
    - service: switch.turn_on
      entity_id: switch.car_port_lights_switch
    - delay:
        minutes: "input_number.car_port_lights_delay"
    - service: switch.turn_off
      entity_id: switch.car_port_lights_switch
  mode: single

that did not work, and I assume because the input number does not produce for example 3, but produces 3.0

Then I created another helper with input select, and gave it values from 1 to 60…
Once I did that, the values are now a round number with no decimal but that also did not work

Please can you help me in what am I doing wrong and how can I achieve this?

Thank you kindly in advance :slight_smile:

    - delay:
        minutes: "{{ states('input_number.car_port_lights_delay') | int(0) }}"

Reference: Wait for time to pass (Delay)

1 Like

Thank you, it works as intended. Much much appreciated :slight_smile:

1 Like