MQTT Dash Commands (json) to Jinja2

I am having a hard time inputting my sauna controller json commands into HA. Any easier way to do this?

MQTT_DASH_with_newlines.json

[SAUNA.ino]
(HarviaWiFi/SAUNA.ino at d40ca850474f663d39eeffa7981f63035e9ce88a · SwiCago/HarviaWiFi · GitHub)

Have you got some examples of the mqtt published.

1 Like

This is the info published to sonoff/sauna:
‘{
“celcius”: 19,
“fahrenheit”: 66.2,
“state”: 0,
“active”: 0,
“setpoint”: 100,
“autooff”: 0
}’

And this is the message published by sonoff/sauna/set:
‘{
“state”: true
}’

Power ($.state), Active ($.active), Temp Celcius ($.celcius), Temp Fahrenheit ($.fahrenheit), and AutoOff ($.autooff) all subscribe to sonoff/sauna and extract from JSON path with $.value format (i.e. $.value).

Power and Active are set as buttons on MQTT Dash with ‘enablepub’: ‘false’. Temps and AutoOff are text tiles with ‘enablepub’: ‘false’.

SetPoint is a multi-choice tile with options ranging from 60 to 110 (degrees F) in format ({“setpoint”:65}) labeled 65. SetPoint is subscribed to sonoff/sauna and publishes to sonoff/sauna/ set.

I have gotten the On/Off button, Temp fahrenheit and AutoOff to work by inserting this into yaml:
'switch:

  • platform: mqtt
    unique_id: sauna_switch
    name: “On/Off”
    command_topic: “sonoff/sauna/set”
    payload_on: ‘{“state”: true}’
    payload_off: ‘{“state”: false}’
    state_on: ‘{“state”: true}’
    state_off: ‘{“state”: false}’
    optimistic: false
    qos: 0
    retain: false

sensor:

  • platform: mqtt
    unique_id: sauna_temp_f
    name: ‘Fahrenheit’
    state_topic: ‘sonoff/sauna’
    qos: 0
    value_template: ‘{{value_json.fahrenheit}}’
    unit_of_measurement: ‘°F’

  • platform: mqtt
    unique_id: sauna_autooff
    name: ‘AutoOff’
    state_topic: ‘sonoff/sauna’
    qos: 0
    value_template: ‘{{value_json.autooff}}’
    unit_of_measurement: ‘m’’

Stangely, Celsius ‘{{value_json.celciust}}’ outputs Fahrenheit value with " unit_of_measurement: ‘°F’ ", and Active/Power:

'switch

  • platform: mqtt
    unique_id: sauna_power
    name: “Power”
    state_topic: ‘sonoff/sauna’
    command_topic: “sonoff/sauna”
    payload_on: ‘ON’
    payload_off: ‘OFF’
    state_on: ‘ON’
    state_off: ‘OFF’
    qos: 0
    retain: true
    value_template: ‘{{value_json.state}}’’

Does not update when ‘On/Off’ changes state (I figure it has to do with the ‘command_topic’ HA requires for ‘switch’ since it has no ‘enablepub’ option.

Please please read this and quote your code properly How to help us help you - or How to ask a good question