MQTT Temp Sensor from TuyaMCU hex

I am setting up a temperature sensor for a kettle on Tasmota using the TuyaMCU module.
the kettle spits out hex with MQTT like this:

02:00:03 MQT: Kogan/tele/RESULT = {“TuyaMcuReceived”:“55AA0007001C0101000100050200040000004F650100010066040001006704000100BD”}

The plan is to pull the temperature from the hex, 4F in the example above, and convert it to decimal and display as degrees Celsius with a value_template.

But only if the hex sting begins with “55AA0007001C01” so that I am only pulling the data from dpid1.

I had a try, but the template got complicated fast… i don’t think I am on the right track at all…
any ideas or help would be greatly appreciated!

I can’t promise this is perfect but the following sensor configuration should help you get started:

  - platform: mqtt
    name: "Kogan Temperature"
    state_topic: Kogan/tele/RESULT
    value_template: >
      {% if '55AA0007001C01' in value_json.TuyaMcuReceived %}
        {{ value_json.TuyaMcuReceived[36:38] | int(base=16) }} 
      {% else %}
        {{ states('sensor.kogan_temperature') }}
      {% endif %}
    unit_of_measurement: '°C'

The template’s design assumes the desired temperature value is always in the same position within the string. If it’s not, then you’ll have to enhance the template.

Correction. Added missing braces {{ }} delimiting expression under {% else %}.

It was almost perfect! i just had wrap else statement like this:

Thanks a lot !

I also changed
55AA0007001C01 to 55AA0007000805 so it is based on dpid5 as opposed to dpid1, seems dpid5 updates whenever there is a temperature change and dpid1 is every 5 seconds.
I have added as slightly changed copy as an example for the template I submitted, thank you again!

1 Like