Use device class ENUM for Accuweather pressure tendency sensor (#86887)

* Use device class ENUM for pressure tendency sensor

* Format
This commit is contained in:
Maciej Bieniek 2023-01-30 12:03:23 +01:00 committed by GitHub
parent a4fa0925b7
commit d485630ce9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -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(),
),

View file

@ -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