|
1 | 1 | """The module parses incoming weather data from various sources into a common format.""" |
2 | 2 |
|
3 | 3 | from dataclasses import dataclass, field, fields |
| 4 | +from enum import Enum |
4 | 5 | import logging |
5 | 6 | from typing import Final |
6 | 7 |
|
|
32 | 33 | _LOGGER = logging.getLogger(__name__) |
33 | 34 |
|
34 | 35 |
|
| 36 | +class WeatherstationVendor(Enum): |
| 37 | + """The weather station cloud vendor.""" |
| 38 | + |
| 39 | + WUNDERGROUND = "wunderground" |
| 40 | + WEATHERCLOUD = "weathercloud" |
| 41 | + |
| 42 | + |
35 | 43 | @dataclass |
36 | 44 | class WundergroundRawSensor: |
37 | 45 | """Wunderground sensor parsed from query string.""" |
@@ -197,6 +205,8 @@ class WeatherStation: |
197 | 205 |
|
198 | 206 | station_id: str |
199 | 207 | station_key: str |
| 208 | + vendor: WeatherstationVendor |
| 209 | + |
200 | 210 | station_sw_version: str = field(default=None) |
201 | 211 | station_client_ip: str = field(default=None) |
202 | 212 | update_time: float = field(default=None) |
@@ -289,7 +299,10 @@ def from_wunderground(data: WundergroundRawSensor) -> "WeatherStation": |
289 | 299 | imperial_unit=unit, |
290 | 300 | ) |
291 | 301 | return WeatherStation( |
292 | | - station_id=data.station_id, station_key=data.station_key, **sensor_data |
| 302 | + station_id=data.station_id, |
| 303 | + station_key=data.station_key, |
| 304 | + vendor=WeatherstationVendor.WUNDERGROUND, |
| 305 | + **sensor_data, |
293 | 306 | ) |
294 | 307 |
|
295 | 308 | @staticmethod |
@@ -353,5 +366,6 @@ def from_weathercloud(data: WeathercloudRawSensor) -> "WeatherStation": |
353 | 366 | return WeatherStation( |
354 | 367 | station_id=str(data.station_id), |
355 | 368 | station_key=str(data.station_key), |
| 369 | + vendor=WeatherstationVendor.WEATHERCLOUD, |
356 | 370 | **sensor_data, |
357 | 371 | ) |
0 commit comments