Allow a temperature sensor to be in K (#86073)
This commit is contained in:
parent
a2fb6fbaa8
commit
f327a247a0
3 changed files with 5 additions and 11 deletions
|
@ -289,7 +289,7 @@ class NumberDeviceClass(StrEnum):
|
||||||
TEMPERATURE = "temperature"
|
TEMPERATURE = "temperature"
|
||||||
"""Temperature.
|
"""Temperature.
|
||||||
|
|
||||||
Unit of measurement: `°C`, `°F`
|
Unit of measurement: `°C`, `°F`, `K`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
||||||
|
@ -384,10 +384,7 @@ DEVICE_CLASS_UNITS: dict[NumberDeviceClass, set[type[StrEnum] | str | None]] = {
|
||||||
NumberDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
|
NumberDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
|
||||||
NumberDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
|
NumberDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
|
||||||
NumberDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
|
NumberDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
|
||||||
NumberDeviceClass.TEMPERATURE: {
|
NumberDeviceClass.TEMPERATURE: set(UnitOfTemperature),
|
||||||
UnitOfTemperature.CELSIUS,
|
|
||||||
UnitOfTemperature.FAHRENHEIT,
|
|
||||||
},
|
|
||||||
NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
|
NumberDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
},
|
},
|
||||||
|
|
|
@ -326,7 +326,7 @@ class SensorDeviceClass(StrEnum):
|
||||||
TEMPERATURE = "temperature"
|
TEMPERATURE = "temperature"
|
||||||
"""Temperature.
|
"""Temperature.
|
||||||
|
|
||||||
Unit of measurement: `°C`, `°F`
|
Unit of measurement: `°C`, `°F`, `K`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
||||||
|
@ -484,10 +484,7 @@ DEVICE_CLASS_UNITS: dict[SensorDeviceClass, set[type[StrEnum] | str | None]] = {
|
||||||
SensorDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
|
SensorDeviceClass.SOUND_PRESSURE: set(UnitOfSoundPressure),
|
||||||
SensorDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
|
SensorDeviceClass.SPEED: set(UnitOfSpeed).union(set(UnitOfVolumetricFlux)),
|
||||||
SensorDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
|
SensorDeviceClass.SULPHUR_DIOXIDE: {CONCENTRATION_MICROGRAMS_PER_CUBIC_METER},
|
||||||
SensorDeviceClass.TEMPERATURE: {
|
SensorDeviceClass.TEMPERATURE: set(UnitOfTemperature),
|
||||||
UnitOfTemperature.CELSIUS,
|
|
||||||
UnitOfTemperature.FAHRENHEIT,
|
|
||||||
},
|
|
||||||
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
|
SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS: {
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@ async def test_device_class_units(hass: HomeAssistant, hass_ws_client) -> None:
|
||||||
)
|
)
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
assert msg["result"] == {"units": unordered(["°F", "°C"])}
|
assert msg["result"] == {"units": unordered(["°F", "°C", "K"])}
|
||||||
|
|
||||||
# Device class with units which number doesn't allow customizing & converting
|
# Device class with units which number doesn't allow customizing & converting
|
||||||
await client.send_json(
|
await client.send_json(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue