Add Celsius and Fahrenheit to Smartthings UNITS mapping#169686
Add Celsius and Fahrenheit to Smartthings UNITS mapping#169686kernelpanic85 wants to merge 1 commit intohome-assistant:devfrom
Conversation
Added mappings for "Celsius" and "Fahrenheit" to the `UNITS` dictionary in `sensor.py`, ensuring all temperature unit variants from the SmartThings API are correctly normalized to Home Assistant's `UnitOfTemperature` constants.
|
Hey there @joostlek, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR fixes SmartThings temperature sensors emitting validation warnings when the SmartThings API reports temperature units as full words instead of short forms, by normalizing those units to Home Assistant’s UnitOfTemperature constants.
Changes:
- Extend the SmartThings sensor unit normalization map to handle
"Celsius"and"Fahrenheit"in addition to"C"and"F".
| "F": UnitOfTemperature.FAHRENHEIT, | ||
| "Celsius": UnitOfTemperature.CELSIUS, | ||
| "Fahrenheit": UnitOfTemperature.FAHRENHEIT, |
|
Do you have device diagnostics for this device? Curious how that works |
Does this help? |
|
Yes, I think it's weird because those values are not permitted values according to their spec iirc. You can check the spec at https://github.com/pySmartThings/capabilities/ |
I'm not sure, maybe something changed? The log messages stopped after implementing this. If I look in the Smartthings app, it shows °F. If I look in the developer portal it's there with both, though the C is not right.
|
|
I mean more like, yes the fix would fix this, but this means that the SmartThings server doesn't respond like it promises to do, let me check this with them as well. I have a meeting with them tomorrow, we still have time until the release on wedensday |

Proposed change
The SmartThings integration was logging a warning about invalid temperature units:
The SmartThings API can return temperature units as either short form ("C", "F") or full words ("Celsius", "Fahrenheit"). The
UNITSmapping insensor.pyonly handled the short forms, causing the full word variants to pass through unmapped and trigger validation warnings.Added mappings for "Celsius" and "Fahrenheit" to the
UNITSdictionary insensor.py, ensuring all temperature unit variants from the SmartThings API are correctly normalized to Home Assistant'sUnitOfTemperatureconstants.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: