Scaling temperture value before sending via MQTT

This is my first post here, although I have been spending lots of time here reading.

I just rolled out my own modified Tasmota to allow a stand-alone thermostat where the Sonoff device will check temperature and decide to turn the relay on or off by itself.

I want to be able to set the temperature setpoint and preferably two other variable from Home Assistant via MQTT. The best component I can find is climate.mqtt.

I have my confirmation working with the mode selection of off, cooling and heating. The setpoint temperature is also working as in communicating but not correctly.

To save memory in the Tasmota firmware, the variables are 16 bit signed integers. To allow for decimal places, 20C needs to be transmitted as 2000.

I cannot find any way to perform math on the command value. I see on the received values math can be performed as discussed here:

Is there any way to accomplish this without rolling my own component?


Ping… Pong…

Can you share the specifics of the data you’re trying to scale and exactly how you’re sending it? I.e., a clip of your script or automation would be helpful. I suspect you can use a template for this, too, but without specifics, it’s kind of hard to say.

Try this :

{% set my_test_json = {
  "temperature": 25,
  "unit": "°C"
} %}

The temperature is {{ my_test_json.temperature |int*100}} {{ my_test_json.unit }}.

You can use int or float, multiply with 100.0 if using with float.

Thank you for your replies.

I am using climate.mqtt with the details here:


(template)(Optional)Default template to render the payloads on all *_state_topics with."

As it shows, only state_topics can have templates. When I add them to control it gives errors.


When setting the target temperature, I need to multiple this value by 100 before sending it via MQTT to the device.

When reading the value, I need to device the value received from MQTT by 100.