mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +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 homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
SensorStateClass,
|
||||
@ -54,11 +55,11 @@ class UvLabel:
|
||||
|
||||
|
||||
UV_LABEL_DEFINITIONS = (
|
||||
UvLabel(value="Extreme", minimum_index=11),
|
||||
UvLabel(value="Very High", minimum_index=8),
|
||||
UvLabel(value="High", minimum_index=6),
|
||||
UvLabel(value="Moderate", minimum_index=3),
|
||||
UvLabel(value="Low", minimum_index=0),
|
||||
UvLabel(value="extreme", minimum_index=11),
|
||||
UvLabel(value="very_high", minimum_index=8),
|
||||
UvLabel(value="high", minimum_index=6),
|
||||
UvLabel(value="moderate", minimum_index=3),
|
||||
UvLabel(value="low", minimum_index=0),
|
||||
)
|
||||
|
||||
|
||||
@ -104,6 +105,8 @@ SENSOR_DESCRIPTIONS = (
|
||||
key=TYPE_CURRENT_UV_LEVEL,
|
||||
translation_key="current_uv_level",
|
||||
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"]),
|
||||
),
|
||||
OpenUvSensorEntityDescription(
|
||||
|
@ -51,7 +51,14 @@
|
||||
"name": "Current UV index"
|
||||
},
|
||||
"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": {
|
||||
"name": "Max UV index"
|
||||
|
Loading…
x
Reference in New Issue
Block a user