MQTT payload from Input Select: Templating Issues

I am trying to set a “SetPoint” dropdown for my sauna controller over MQTT. I am able to set up the input select and send a payload but I cant format it right.

- id: set_sauna_setpoint
  alias: Set Point
  trigger:
  - platform: state
    entity_id: input_select.setpoint
  action:
  - service: mqtt.publish
    data_template:
      topic: "sonoff/sauna/set"
      payload: "{{ states('input_select.setpoint') }}"

I need {setpoint":input_select #} but I only get input_select #. Example: need {“setpoint”:65}, get 65.

input_select:
  setpoint:
    name: Set Point
    options:
    - "65"
    - "70"
    - "75"
    - "80"
    - "85"
    - "90"
    - "95"
    - "100"
    - "105"
    - "110"
    - "115"
    - "120"

Try this:

payload: '"setpoint":{{ states('input_select.setpoint') }}'

(Updated to account for the double quotes around setpoint)

1 Like
- id: set_sauna_setpoint
  alias: Set Point
  trigger:
  - platform: state
    entity_id: input_select.setpoint
  action:
  - service: mqtt.publish
    data:
      topic: "sonoff/sauna/set"
      payload: >
        { "setpoint": {{trigger.to_state.state}} }
2 Likes