Embed number helper in MQTT message for heating control

Hi,
I am writing some automations to trigger a my hive thermostat to boost the hot water. I have an automation triggered by a button helper and the following MQTT payload works fine:

{
   "system_mode_water":"emergency_heating",
   "temperature_setpoint_hold_duration_water":"30", 
   "temperature_setpoint_hold_water":"1"
}

This behaves as I would expect but rather than hard code the temperature_setpoint_hold_duration_water to 30 I would like to get the value from a number helper I have (input_number.hot_water_boost_time). I don’t appear to be able to get this to work, i’m sure i’m missing something obvious. Here is my full automation:

- id: "1696679145506"
  alias: Boost Hot Water
  description: ""
  trigger:
    - platform: state
      entity_id:
        - input_button.boost_hotwater_button
  condition: []
  action:
    - service: mqtt.publish
      data:
        qos: 0
        retain: false
        topic: zigbee2mqtt/Boiler Control/set
        payload: '{{"system_mode_water":"emergency_heating","temperature_setpoint_hold_duration_water":states("input_number.hot_water_boost_time"),  "temperature_setpoint_hold_water":"1"}}'
  mode: single

Any help would be much appreciated. Thanks!

- id: "1696679145506"
  alias: Boost Hot Water
  description: ""
  trigger:
    - platform: state
      entity_id:
        - input_button.boost_hotwater_button
  condition: []
  action:
    - service: mqtt.publish
      data:
        qos: 0
        retain: false
        topic: zigbee2mqtt/Boiler Control/set
        payload_template: >
          { "system_mode_water": "emergency_heating",
            "temperature_setpoint_hold_duration_water": {{ states("input_number.hot_water_boost_time") }},
            "temperature_setpoint_hold_water": 1 }

NOTE

For the values of a JSON payload, you don’t need to wrap numbers in quotes unless there’s a special reason obliging you to convert them to strings. Therefore I have removed them from the two number values. If your application requires numeric string values, simply add the quotes back.

That’s great, thanks very much!

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.