Use device class ENUM for Accuweather pressure tendency sensor (#86887)
* Use device class ENUM for pressure tendency sensor * Format
This commit is contained in:
parent
a4fa0925b7
commit
d485630ce9
2 changed files with 5 additions and 1 deletions
|
@ -300,8 +300,10 @@ SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = (
|
|||
),
|
||||
AccuWeatherSensorDescription(
|
||||
key="PressureTendency",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
icon="mdi:gauge",
|
||||
name="Pressure tendency",
|
||||
options=["falling", "rising", "steady"],
|
||||
translation_key="pressure_tendency",
|
||||
value_fn=lambda data, _: cast(str, data["LocalizedText"]).lower(),
|
||||
),
|
||||
|
|
|
@ -5,6 +5,7 @@ from unittest.mock import PropertyMock, patch
|
|||
|
||||
from homeassistant.components.accuweather.const import ATTRIBUTION, DOMAIN
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_OPTIONS,
|
||||
ATTR_STATE_CLASS,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
SensorDeviceClass,
|
||||
|
@ -79,8 +80,9 @@ async def test_sensor_without_forecast(hass):
|
|||
assert state.state == "falling"
|
||||
assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:gauge"
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
|
||||
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.ENUM
|
||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
||||
assert state.attributes.get(ATTR_OPTIONS) == ["falling", "rising", "steady"]
|
||||
|
||||
entry = registry.async_get("sensor.home_pressure_tendency")
|
||||
assert entry
|
||||
|
|
Loading…
Add table
Reference in a new issue