Set delay from input_select

I am writing a script that should pause based on the numeric value of an input_select helper. The MWE looks as follows:

sequence:
  - delay:
      hours: 0
      minutes: {{ float(states("input_select.music_duration")) }}
      seconds: 0
      milliseconds: 0

However, this yields an error:

Message malformed: expected float for dictionary value @ data[‘sequence’][0][‘delay’][‘minutes’]

I do not understand the problem since the input_select value is in fact a float and the template editor returns true for

{{ float(states("input_select.music_duration")) is float }}

:thinking:

sequence:
  - delay:
      hours: 0
      minutes: "{{ states('input_select.music_duration') | float }}"
      seconds: 0
      milliseconds: 0

Thank you, that did it.

If I understand correctly, using a template here requires quotes around the {{ … }}, hence I need another type of quotes inside the states(…).

I tested:

  • Double and single quotes and interchangeable here, but two different types need to be used.
  • “float()” and “| float” are interchangeable as well.