Changing a decimal value into a hex value (jinja)

Hi there

I have a similar issue - I am trying to create a RESTful sensor to give me a temperature sensor.

  • platform: rest
    resource: http://192.168.1.109:1234/@*****?/
    name: Temperature
    value_template: ‘{{ “%+0x” | format(value_json.data[4:6] | int }}’
    unit_of_measurement: “°C”

The device returns the temperature in hexadecimal format. I then need to convert it to a decimal number.

I tried the above but it seems the json data is returned as a string and so the conversion fails. Typical data that is returned from the sensor is “1D” for 29 degrees Celcius. Would appreciate your assistance!

1 Like