Temperature conversion from F to C with sensor with Value_template not working

Try creating a template sensor that converts the numbers instead of using customize.yaml. That’s what I did and it works for me:

sensor:
  - platform: template
    sensors:

      den_temp_c:
        friendly_name: "Den Temperature C"
        unit_of_measurement: 'C'
        device_class: temperature
        value_template: "{{ (((states('sensor.den_temp') | float) - 32) * 5.0/9.0) | round(1)}}"

I’ve been using unit_of_measurement: 'C' in my customize.yaml for 6 months now and it’s worked perfectly… until this week. Now my printers are showing a temperature of “392 C” which is obviously wrong (it’s the F temp with a C label).

MQTT sends octoPrint/temperature/tool0 as { "actual": 200.89, "target": 200.0 }. The MQTT plugin for Octoprint doesn’t send any units, but that’s what the code in customize.yaml was previously fixing. The HASS developer tools lists sensor.octoprint2_tool_0_temperature with state of 392.0 and unit_of_measurement: C. So… the temperature is once again being converted to imperial, and only the unit is being set.

I’m guessing an update somewhere broke this, but I haven’t dug into recent changes to see what it could be. Looks like the last HASS Core update included a “Fix handling of imperial units in long term statistics” checkin but I have no idea if that changed the behavior.

I may just switch to the template sensor solution…