Units Confusion

My units system is set to imperial, but MQTT devices seem to keep values in °C still. I thought this might be related to the soon deprication of the old way I had my custom MQTT devices setup, but updating to the new format doesn’t seem to have helped. Here is my current setup for this sensor:

mqtt:
  sensor:
    # AC Coil Sensor
    - name: "coil_temp"
      unique_id: "mqtt_ac_coil_temp_c"
      state_topic: "ac_status/coil_temp"
      state_class: measurement
      unit_of_measurement: "°C"
      value_template: "{{ (value | round(2)) | float }}"

When I make a history graph of coil_temp it displays in units of °C. More importantly, my automation that previously worked has stopped working. It was set to trigger when below 36 °F for more than 2 minutes, but now the (I’m trying to prevent frezing, yes I know this is not the correct solution to an HVAC problem, but I’m trying to limp along until the tech can fix it). I’ve thought of just changing my automation to assume things are in °C, but that makes me nervous without knowing why things changed.

Here is the node red event state trigger that my automation uses:

[{"id":"4f80d6b1.97c0a8","type":"server-state-changed","z":"c7cff565.07ca28","name":"AC Coils Freezing","server":"a727b8dc.148068","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.coil_temp","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"36","halt_if_type":"num","halt_if_compare":"lt","outputs":2,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":780,"wires":[["edc8e094.159df"],[]]},{"id":"a727b8dc.148068","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

You need the device_class temperature. But why not adjust the template to convert the value? You yourself supply both the unit of measurement and the value. You can do the conversion in the value template and adjust the unit of measurement.

Maybe also take a look at this:

Thank you, this fixed it for me. I suspect your idea of converting it myself in the value template would also have worked, but it seems to me like bringing the value in using it’s native units and letting the software control units might be more flexible in the future. Let me know if I’m wrong there.

For future me and any others who run into this, here’s my new working code:

mqtt:
  sensor:
    # AC Coil Sensor
    - name: "coil_temp"
      unique_id: "mqtt_ac_coil_temp_c"
      state_topic: "ac_status/coil_temp"
      state_class: measurement
      unit_of_measurement: "°C"
      device_class: temperature
      value_template: "{{ (value | round(2)) | float }}"