added rain, updated graph styles
This commit is contained in:
+13
-2
@@ -15,7 +15,7 @@ def _dashboard(item: dict[str, Any]) -> dict[str, Any]:
|
||||
|
||||
|
||||
def extract_samples(payload: dict, names: dict[str, str]) -> dict[str, Sample]:
|
||||
"""Translate a getstationsdata response into the service's five RRD samples."""
|
||||
"""Translate a getstationsdata response into the service's RRD samples."""
|
||||
devices = payload.get("body", {}).get("devices", [])
|
||||
if not devices:
|
||||
raise ValueError("Netatmo response contains no weather station")
|
||||
@@ -39,6 +39,18 @@ def extract_samples(payload: dict, names: dict[str, str]) -> dict[str, Sample]:
|
||||
sample("study", {"temperature": "Temperature", "co2": "CO2", "humidity": "Humidity"})
|
||||
sample("living", {"temperature": "Temperature", "co2": "CO2", "humidity": "Humidity"})
|
||||
sample("wind", {"gust": "GustStrength", "average": "WindStrength", "angle": "WindAngle"})
|
||||
# Netatmo resets this cumulative millimetre total at local midnight. Store
|
||||
# it unchanged so historical graphs show the total accumulated each day.
|
||||
sample("rain", {"sum_rain_24": "sum_rain_24"})
|
||||
|
||||
# Pressure belongs to the main indoor station rather than a separate
|
||||
# module, so give it its own sample and use that station's timestamp.
|
||||
station_data = _dashboard(device)
|
||||
if station_data:
|
||||
result["pressure"] = Sample(
|
||||
int(station_data["time_utc"]),
|
||||
{"pressure": _number(station_data.get("Pressure"))},
|
||||
)
|
||||
|
||||
outdoor = by_name.get(names["outdoor"])
|
||||
if outdoor and _dashboard(outdoor):
|
||||
@@ -62,4 +74,3 @@ def _number(value: Any) -> float | None:
|
||||
if value is None:
|
||||
return None
|
||||
return float(value)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user