mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Add state translations for OpenUV UV Level sensor (#101978)
This commit is contained in:
parent
76083a0b4c
commit
2d1afc1c7d
@ -6,6 +6,7 @@ from dataclasses import dataclass
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
@ -54,11 +55,11 @@ class UvLabel:
|
|||||||
|
|
||||||
|
|
||||||
UV_LABEL_DEFINITIONS = (
|
UV_LABEL_DEFINITIONS = (
|
||||||
UvLabel(value="Extreme", minimum_index=11),
|
UvLabel(value="extreme", minimum_index=11),
|
||||||
UvLabel(value="Very High", minimum_index=8),
|
UvLabel(value="very_high", minimum_index=8),
|
||||||
UvLabel(value="High", minimum_index=6),
|
UvLabel(value="high", minimum_index=6),
|
||||||
UvLabel(value="Moderate", minimum_index=3),
|
UvLabel(value="moderate", minimum_index=3),
|
||||||
UvLabel(value="Low", minimum_index=0),
|
UvLabel(value="low", minimum_index=0),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +105,8 @@ SENSOR_DESCRIPTIONS = (
|
|||||||
key=TYPE_CURRENT_UV_LEVEL,
|
key=TYPE_CURRENT_UV_LEVEL,
|
||||||
translation_key="current_uv_level",
|
translation_key="current_uv_level",
|
||||||
icon="mdi:weather-sunny",
|
icon="mdi:weather-sunny",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=[label.value for label in UV_LABEL_DEFINITIONS],
|
||||||
value_fn=lambda data: get_uv_label(data["uv"]),
|
value_fn=lambda data: get_uv_label(data["uv"]),
|
||||||
),
|
),
|
||||||
OpenUvSensorEntityDescription(
|
OpenUvSensorEntityDescription(
|
||||||
|
@ -51,7 +51,14 @@
|
|||||||
"name": "Current UV index"
|
"name": "Current UV index"
|
||||||
},
|
},
|
||||||
"current_uv_level": {
|
"current_uv_level": {
|
||||||
"name": "Current UV level"
|
"name": "Current UV level",
|
||||||
|
"state": {
|
||||||
|
"extreme": "Extreme",
|
||||||
|
"high": "High",
|
||||||
|
"low": "Low",
|
||||||
|
"moderate": "Moderate",
|
||||||
|
"very_high": "Very high"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"max_uv_index": {
|
"max_uv_index": {
|
||||||
"name": "Max UV index"
|
"name": "Max UV index"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user