Add translation for Trafikverket Weatherstation sensor (#87315)
* Trafikverket weatherstation translate sensor * Fix enumspull/93841/head
parent
6736ed67ba
commit
ac8d8dccd2
|
@ -30,6 +30,45 @@ from homeassistant.util.dt import as_utc
|
|||
from .const import ATTRIBUTION, CONF_STATION, DOMAIN, NONE_IS_ZERO_SENSORS
|
||||
from .coordinator import TVDataUpdateCoordinator
|
||||
|
||||
WIND_DIRECTIONS = [
|
||||
"east",
|
||||
"north_east",
|
||||
"east_south_east",
|
||||
"north",
|
||||
"north_north_east",
|
||||
"north_north_west",
|
||||
"north_west",
|
||||
"south",
|
||||
"south_east",
|
||||
"south_south_west",
|
||||
"south_west",
|
||||
"west",
|
||||
]
|
||||
PRECIPITATION_AMOUNTNAME = [
|
||||
"error",
|
||||
"mild_rain",
|
||||
"moderate_rain",
|
||||
"heavy_rain",
|
||||
"mild_snow_rain",
|
||||
"moderate_snow_rain",
|
||||
"heavy_snow_rain",
|
||||
"mild_snow",
|
||||
"moderate_snow",
|
||||
"heavy_snow",
|
||||
"other",
|
||||
"none",
|
||||
"error",
|
||||
]
|
||||
PRECIPITATION_TYPE = [
|
||||
"drizzle",
|
||||
"hail",
|
||||
"none",
|
||||
"rain",
|
||||
"snow",
|
||||
"rain_snow_mixed",
|
||||
"freezing_rain",
|
||||
]
|
||||
|
||||
|
||||
@dataclass
|
||||
class TrafikverketRequiredKeysMixin:
|
||||
|
@ -64,10 +103,13 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
|
|||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="precipitation",
|
||||
api_key="precipitationtype",
|
||||
api_key="precipitationtype_translated",
|
||||
name="Precipitation type",
|
||||
icon="mdi:weather-snowy-rainy",
|
||||
entity_registry_enabled_default=False,
|
||||
translation_key="precipitation",
|
||||
options=PRECIPITATION_TYPE,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="wind_direction",
|
||||
|
@ -79,9 +121,12 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
|
|||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="wind_direction_text",
|
||||
api_key="winddirectiontext",
|
||||
api_key="winddirectiontext_translated",
|
||||
name="Wind direction text",
|
||||
icon="mdi:flag-triangle",
|
||||
translation_key="wind_direction_text",
|
||||
options=WIND_DIRECTIONS,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="wind_speed",
|
||||
|
@ -121,10 +166,13 @@ SENSOR_TYPES: tuple[TrafikverketSensorEntityDescription, ...] = (
|
|||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="precipitation_amountname",
|
||||
api_key="precipitation_amountname",
|
||||
api_key="precipitation_amountname_translated",
|
||||
name="Precipitation name",
|
||||
icon="mdi:weather-pouring",
|
||||
entity_registry_enabled_default=False,
|
||||
translation_key="precipitation_amountname",
|
||||
options=PRECIPITATION_AMOUNTNAME,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
),
|
||||
TrafikverketSensorEntityDescription(
|
||||
key="measure_time",
|
||||
|
|
|
@ -17,5 +17,53 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"wind_direction_text": {
|
||||
"state": {
|
||||
"east": "East",
|
||||
"north_east": "North east",
|
||||
"east_south_east": "East-south east",
|
||||
"north": "North",
|
||||
"north_north_east": "North-north east",
|
||||
"north_north_west": "North-north west",
|
||||
"north_west": "North west",
|
||||
"south": "South",
|
||||
"south_east": "South east",
|
||||
"south_south_west": "South-south west",
|
||||
"south_west": "South west",
|
||||
"west": "West"
|
||||
}
|
||||
},
|
||||
"precipitation_amountname": {
|
||||
"state": {
|
||||
"error": "Error",
|
||||
"mild_rain": "Mild rain",
|
||||
"moderate_rain": "Moderate rain",
|
||||
"heavy_rain": "Heavy rain",
|
||||
"mild_snow_rain": "Mild rain and snow mixed",
|
||||
"moderate_snow_rain": "Moderate rain and snow mixed",
|
||||
"heavy_snow_rain": "Heavy rain and snow mixed",
|
||||
"mild_snow": "Mild snow",
|
||||
"moderate_snow": "Moderate snow",
|
||||
"heavy_snow": "Heavy snow",
|
||||
"other": "Other",
|
||||
"none": "None",
|
||||
"unknown": "Unknown"
|
||||
}
|
||||
},
|
||||
"precipitation": {
|
||||
"state": {
|
||||
"drizzle": "Drizzle",
|
||||
"hail": "Hail",
|
||||
"none": "None",
|
||||
"rain": "Rain",
|
||||
"snow": "Snow",
|
||||
"rain_snow_mixed": "Rain and snow mixed",
|
||||
"freezing_rain": "Freezing rain"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue