Using Templates in Intents with Assist?

I have an intent which switches on my water heater. I’d like to make it more flexible using an input_number {{ boosttime }} to allow the heater to be switched on for a variable time between 15 and 45 minutes. I want to manage instances when the boosttime might be set outside the 15-45 minute range.

{{ boosttime }} is set from the sentence in the conversations.yaml

I have set the following in my intents.yaml file

BoostHotWater:
  action:
    - service: input_number.set_value
      value_template: >
        {% if boosttime > 45 %}
        {{boosttime}} = 45
        {% elif boosttime < 15 %}
        {{boosttime}} = 15
        {% else %}
        {{boosttime}} = {{boosttime}}
        {% endif %}
      data:
        value: "{{boosttime}}"
      target:
        entity_id: input_number.heater_boost

The above BoostHotWater intent throws an error

If I remove the value_template section and allow {{ boosttime }} to be any given value, the BoostHotWater intent works

Can anyone suggest where I am going wrong

Where in Input Number’s documentation does it indicate that the input_number.set_value service call supports a value_template option?

Try this version. It uses boosttime to set value. If boosttime is less than 15, the reported value will be 15. Similarly, if it’s greater than 45, it will report 45.

BoostHotWater:
  action:
    - service: input_number.set_value
      data:
        value: "{{ ([15, boosttime, 45]|sort)[1] }}"
      target:
        entity_id: input_number.heater_boost
1 Like

Thank you Taras. Easy when you know?

1 Like

Simple solution.