t0bst4r / home-assistant-matter-hub

Publish your Home-Assistant Instance using Matter.
Apache License 2.0
189 stars 13 forks source link

[Bug] Thermostat using Fahrenheit unit of measurement appears to be exposed as Celsius resulting in inaccurate temperatures in Alexa #64

Open kevin-meyer opened 4 weeks ago

kevin-meyer commented 4 weeks ago

Thermostat set to Fahrenheit. Correctly shows degrees F in Home Assistant. When exposed to Alexa, it appears Alexa gets the correct raw values but thinks it's Celsius. For example, the actual temperature is 70F but Alexa says it's 158F (or 70C).

3.0.0-alpha.17

t0bst4r commented 3 weeks ago

That is interesting. Matter.js seems to require temperature to be Celsius. Therefore I convert temperature to celsius based on the unit of measurement.

Can you provide the entity attributes of your sensor (Home Assistant -> Developer Tools -> State -> search for your entity).

kevin-meyer commented 3 weeks ago

It looks like the main thermostat entity doesn't have unit_of_measurement, like the sensor entity does.

hvac_modes:
  - "off"
  - heat
  - cool
  - heat_cool
min_temp: 32
max_temp: 122
fan_modes:
  - Auto low
  - Low
current_temperature: 68.5
temperature: 72
target_temp_high: null
target_temp_low: null
current_humidity: 58
fan_mode: Auto low
hvac_action: idle
fan_state: Idle / off
icon: mdi:home-thermometer-outline
friendly_name: "Downstairs AC "
supported_features: 395

Possibly related, there is an issue from 5 years ago in Home Assistant that looks like they resulted in removing unit_of_measurement from climate entities because the state is non-numeric. The discussion implies the core temperature units should be used (core.unit_system.temperature).

https://github.com/home-assistant/architecture/issues/48

Also, I at first glance I see TemperatureMeasurementServer adjusting for unit_of_measurement, but I don't see that happening in the Thermostat Servers (default, cooling, or heating), but I'll admit I have not gotten familiar with this code base.

Apollon77 commented 3 weeks ago

@t0bst4rMatter defined the Temperature datatype as

7.18.2.11. Temperature This type, derived from int16, represents a temperature on the Celsius scale with a resolution of 0.01°C.

... so in fact it is Celsius by definition of the standard. ALso Thermostat defines that all values used there are degrees celsius

t0bst4r commented 3 weeks ago

@kevin-meyer oh I see. So I need to consider the ha core settings as well ☹️

@Apollon77 alright, thank you

nekorevend commented 3 weeks ago

I see a similar issue but it's not 1:1 (not 70F -> 70C). As far as I can tell, the actual conversion happening is (temp - 0.32) * 5 / 9. For example, 71.1F -> 39.32C. The code looks correct though at doing - 32 so I'm not sure what the actual issue is.

FWIW, I have the physical sensors reporting C to HA and then in HA it's set to F where HA is converting it to F for me.

t0bst4r commented 3 weeks ago

No, you pointed me to a thing. Matter requires to multiply with 100. So instead of returning 20.00 i need to return 2000. But i am doing the multiplication at the wrong time (before converting instead of after converting).

I will fix that in a second. But unfortunately this will only fix temperature sensors, not climates.

t0bst4r commented 3 weeks ago

Temperature conversion is fixed now for temperature sensors. Still thinking about, how I'd do that with climates.

I'd kindly ask for some patience here until i finally fixed climates (#73) - those are driving me crazy 😀

AnUrbanLegend commented 1 week ago

Using Current version: 3.0.0-alpha.36. I have a temperature sensor that shows the temp as 70F in Alexa but shows up as 21C in Google Home.

sensor.bedroom_temperature_temperature Bedroom Temperature Temperature 70.0 state_class: measurement unit_of_measurement: °F device_class: temperature friendly_name: Bedroom Temperature Temperature

nekorevend commented 1 week ago

@AnUrbanLegend I'm in the same boat with being stuck with C in Google Home.

Google provides no UI to set the display unit, so maybe the Matter protocol includes the display unit as an optional field?

t0bst4r commented 1 week ago

Matter specifies the temperature in Celsius. No way to change it. It‘s an issue of google home not being able to change the display unit.