Sensor reporting Celsius instead of Fahrenheit but only in condition

I ran into a problem last night that I thought I’d share. Maybe I can alleviate the frustrations I went through for someone else.

I’ve got an automation to turn on a window fan when in the bedroom when the temperature outside is colder than inside the room. But the room temperature needs to be above 62 degrees Fahrenheit. To do this, I was using this condition;

ONLY READS AS °C:

- condition: numeric_state
  entity_id: sensor.bedroom_temperature
  above: "62"
  attribute: temperature

While this sensor shows in Fahrenheit everywhere else in my configuration, the condition statement above always reverted back to the original Celsius (the sensor itself reports in °C). It was driving me FREAKING MAD!

However, I figured out that by removing the “attribute: temperature” line, it went back to comparing Fahrenheit!

READS CORRECTLY AS °F:

- condition: numeric_state
  entity_id: sensor.bedroom_temperature
  above: "62"

I’ve never used the “attribute” method of a numeric_state condition before. I think I copied the yaml code after what the GUI started putting together for me. Not that it really matters here.

The big takeaway for anyone who finds this in the future is that if you run into this situation and have that “attribute” line in the condition, try removing it. It may just save you a lot of extra frustration.

Shane

If you go to developer tools → states, and then filter for, or scroll down to find, your sensor.bedroom_temperature entity, you will be able to see its state (in the middle column) and also all of the attributes (in the right column).

Based on your explanation, the state of the entity should be in °F and it should have an attribute called temperature that is in °C.

When you use the attribute key in your automation you are instructing the automation to ignore the state and instead look at the attribute that you’ve specified.

1 Like

That’s a great explanation of why it’s happening. But nonetheless, it does happen. And I’m guessing that I’m not the only person that has been flummoxed by it happening.

Thus, the note shared for everyone else in the future who may have this headache.