mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Meteo france "next_rain" attributes rework (#39092)
* Improve next_rain sensor attributes * Add log message to identify missing condition * Add a condtion * Set the coordinator for 1 hour rain forecast in English * Attribut dict keys shorten * reverse transalate the API results for next rain * Use f string for the keys in the dict * Remove Logging from state property * Remove other logging from state property
This commit is contained in:
parent
4e39a00b3d
commit
90ac426a54
@ -24,6 +24,7 @@ FORECAST_MODE_DAILY = "daily"
|
|||||||
FORECAST_MODE = [FORECAST_MODE_HOURLY, FORECAST_MODE_DAILY]
|
FORECAST_MODE = [FORECAST_MODE_HOURLY, FORECAST_MODE_DAILY]
|
||||||
|
|
||||||
ATTR_NEXT_RAIN_1_HOUR_FORECAST = "1_hour_forecast"
|
ATTR_NEXT_RAIN_1_HOUR_FORECAST = "1_hour_forecast"
|
||||||
|
ATTR_NEXT_RAIN_DT_REF = "forecast_time_ref"
|
||||||
|
|
||||||
ENTITY_NAME = "name"
|
ENTITY_NAME = "name"
|
||||||
ENTITY_UNIT = "unit"
|
ENTITY_UNIT = "unit"
|
||||||
@ -150,6 +151,7 @@ CONDITION_CLASSES = {
|
|||||||
"Pluies éparses / Rares averses",
|
"Pluies éparses / Rares averses",
|
||||||
"Pluies éparses",
|
"Pluies éparses",
|
||||||
"Rares averses",
|
"Rares averses",
|
||||||
|
"Pluie modérée",
|
||||||
"Pluie / Averses",
|
"Pluie / Averses",
|
||||||
"Averses",
|
"Averses",
|
||||||
"Pluie",
|
"Pluie",
|
||||||
|
@ -15,6 +15,7 @@ from homeassistant.util import dt as dt_util
|
|||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
ATTR_NEXT_RAIN_1_HOUR_FORECAST,
|
ATTR_NEXT_RAIN_1_HOUR_FORECAST,
|
||||||
|
ATTR_NEXT_RAIN_DT_REF,
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
COORDINATOR_ALERT,
|
COORDINATOR_ALERT,
|
||||||
COORDINATOR_FORECAST,
|
COORDINATOR_FORECAST,
|
||||||
@ -185,11 +186,13 @@ class MeteoFranceRainSensor(MeteoFranceSensor):
|
|||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
reference_dt = self.coordinator.data.forecast[0]["dt"]
|
||||||
return {
|
return {
|
||||||
ATTR_NEXT_RAIN_1_HOUR_FORECAST: [
|
ATTR_NEXT_RAIN_DT_REF: dt_util.utc_from_timestamp(reference_dt).isoformat(),
|
||||||
{dt_util.utc_from_timestamp(item["dt"]).isoformat(): item["desc"]}
|
ATTR_NEXT_RAIN_1_HOUR_FORECAST: {
|
||||||
|
f"{int((item['dt'] - reference_dt) / 60)} min": item["desc"]
|
||||||
for item in self.coordinator.data.forecast
|
for item in self.coordinator.data.forecast
|
||||||
],
|
},
|
||||||
ATTR_ATTRIBUTION: ATTRIBUTION,
|
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +130,6 @@ class MeteoFranceWeather(WeatherEntity):
|
|||||||
for forecast in self.coordinator.data.forecast:
|
for forecast in self.coordinator.data.forecast:
|
||||||
# Can have data in the past
|
# Can have data in the past
|
||||||
if forecast["dt"] < today:
|
if forecast["dt"] < today:
|
||||||
_LOGGER.debug(
|
|
||||||
"remove forecast in the past: %s %s", self._mode, forecast
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
forecast_data.append(
|
forecast_data.append(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user