Skip to content

Commit

Permalink
fix: add vendor identifier to weatherstation (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhw authored Jul 8, 2024
1 parent 6905325 commit 33f7bae
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion aiocloudweather/station.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""The module parses incoming weather data from various sources into a common format."""

from dataclasses import dataclass, field, fields
from enum import Enum
import logging
from typing import Final

Expand Down Expand Up @@ -32,6 +33,13 @@
_LOGGER = logging.getLogger(__name__)


class WeatherstationVendor(Enum):
"""The weather station cloud vendor."""

WUNDERGROUND = "wunderground"
WEATHERCLOUD = "weathercloud"


@dataclass
class WundergroundRawSensor:
"""Wunderground sensor parsed from query string."""
Expand Down Expand Up @@ -197,6 +205,8 @@ class WeatherStation:

station_id: str
station_key: str
vendor: WeatherstationVendor

station_sw_version: str = field(default=None)
station_client_ip: str = field(default=None)
update_time: float = field(default=None)
Expand Down Expand Up @@ -289,7 +299,10 @@ def from_wunderground(data: WundergroundRawSensor) -> "WeatherStation":
imperial_unit=unit,
)
return WeatherStation(
station_id=data.station_id, station_key=data.station_key, **sensor_data
station_id=data.station_id,
station_key=data.station_key,
vendor=WeatherstationVendor.WUNDERGROUND,
**sensor_data,
)

@staticmethod
Expand Down Expand Up @@ -353,5 +366,6 @@ def from_weathercloud(data: WeathercloudRawSensor) -> "WeatherStation":
return WeatherStation(
station_id=str(data.station_id),
station_key=str(data.station_key),
vendor=WeatherstationVendor.WEATHERCLOUD,
**sensor_data,
)

0 comments on commit 33f7bae

Please sign in to comment.