home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.85k stars 30.1k forks source link

SmartThings integration temperature unit assumed celsius, applies erroneous conversion #22009

Closed dgz closed 5 years ago

dgz commented 5 years ago

Home Assistant release with the issue:

0.89.1

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.io on Docker

Component/platform:

https://www.home-assistant.io/components/smartthings/

Description of problem: The Accuweather Device in SmartThings does not declare its unit of measurement for temperature. For example, in the graph api dashboard the temperature state of mine is currently reported as "36.0". This value is correctly displayed in the SmartThings app as 36F (US location).

The SmartThings component seems to be assuming this value is in celsius and applies a celsius to fahrenheit conversion. As a result, the Accuweather temperature measurement reported in Home Assistant is currently showing 96.8F.

Some other temperature sensors in SmartThings report the unit (e.g. "36.0 F" shown on graph api dashboard) and these values carry over into Home Assistant without an erroneous conversion.

My unit_system is defined in configuration.yaml to be imperial and the rest of Home Assistant correctly defaults to degrees fahrenheit where needed.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

Traceback (if applicable):

Additional information:

andrewsayre commented 5 years ago

I assume you're talking about the Sensors platform. It does appear to be defaulting to Celsius when the device isn't defining the unit (which it is required to do for temp related attributes). I'll take out the default, so it just won't show any unit for those sensors. It shouldn't be making an assumption, it's going to be wrong half of the time.

dgz commented 5 years ago

Yes, it looks like you've got it there. The entity customizer can be used to add the missing unit of measure in the cases of improperly reporting devices like this one (and a template sensor if a conversion is really needed). A template sensor could also reverse the conversion without this patch but it seemed more appropriate to avoid the conversion in the first place. Thank you for knocking this one out so quickly.