hamsclientfork 0.2.11__tar.gz → 0.2.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -82,7 +82,9 @@ class HourlyForecast(TypedDict):
82
82
 
83
83
 
84
84
  def HourlyForecast_from_meteoswiss_data(data: dict[str, Any]) -> list[HourlyForecast]:
85
- time = datetime.datetime.fromtimestamp(data["start"] / 1000)
85
+ time = datetime.datetime.fromtimestamp(
86
+ data["start"] / 1000, tz=datetime.timezone.utc
87
+ )
86
88
  results: list[HourlyForecast] = []
87
89
  for idx in range(
88
90
  min(
@@ -188,7 +190,11 @@ def CurrentCondition_from_meteoswiss_data(data: dict[str, Any]) -> CurrentCondit
188
190
  class ClientResult(TypedDict):
189
191
  name: str
190
192
  forecast: Forecast
193
+ # A list of current conditions for the first station passed.
191
194
  condition: list[CurrentCondition]
195
+ # A dictionary of station -> list of the current condition
196
+ # returned by the corresponding station.
197
+ condition_by_station: dict[str, CurrentCondition]
192
198
 
193
199
 
194
200
  def ClientResult_from_meteoswiss_data(data: dict[str, Any]) -> ClientResult:
@@ -196,21 +202,26 @@ def ClientResult_from_meteoswiss_data(data: dict[str, Any]) -> ClientResult:
196
202
  name=data["name"],
197
203
  forecast=Forecast_from_meteoswiss_data(data["forecast"]),
198
204
  condition=[CurrentCondition_from_meteoswiss_data(x) for x in data["condition"]],
205
+ condition_by_station={
206
+ station: CurrentCondition_from_meteoswiss_data(condition)
207
+ for (station, condition) in data["condition_by_station"].items()
208
+ },
199
209
  )
200
210
 
201
211
 
202
212
  class meteoSwissClient:
203
- def __init__(self, displayName=None, postcode=None, station=None):
213
+ def __init__(self, displayName=None, postcode=None, *station: str):
204
214
  _LOGGER.debug("MS Client INIT")
205
215
  self._postCode = postcode
206
- self._station = station
216
+ self._stations = station
207
217
  self._name = displayName
208
- self._allStations = None
218
+ self._allStations: dict[str, Any] | None = None
209
219
  self._condition = None
220
+ self._conditions: dict[str, Any] = {}
210
221
  self._forecast = None
211
222
  _LOGGER.debug(
212
- "INIT meteoswiss client : name = %s station = %s postcode = %s"
213
- % (self._name, self._station, self._postCode)
223
+ "INIT meteoswiss client : name = %s stations = %s postcode = %s"
224
+ % (self._name, self._stations, self._postCode)
214
225
  )
215
226
 
216
227
  def get_data(self):
@@ -220,6 +231,7 @@ class meteoSwissClient:
220
231
  "name": self._name,
221
232
  "forecast": self._forecast,
222
233
  "condition": self._condition,
234
+ "condition_by_station": self._conditions,
223
235
  }
224
236
 
225
237
  def get_typed_data(self) -> ClientResult:
@@ -275,19 +287,23 @@ class meteoSwissClient:
275
287
 
276
288
  def get_current_condition(self):
277
289
  _LOGGER.debug("Update current condition")
278
-
279
290
  data = pd.read_csv(CURRENT_CONDITION_URL, sep=";", header=0)
280
-
281
- _LOGGER.debug("Get current condition for : %s" % self._station)
282
- stationData = data.loc[data["Station/Location"].str.contains(self._station)]
283
- stationData = stationData.to_dict("records")
284
- self._condition = stationData
291
+ conditions = {}
292
+ condition_list = []
293
+ for station in self._stations:
294
+ _LOGGER.debug("Get current condition for : %s" % station)
295
+ stationData = data.loc[data["Station/Location"].str.contains(station)]
296
+ stationData = stationData.to_dict("records")
297
+ condition_list.extend(stationData)
298
+ conditions[station] = stationData[0]
299
+ self._condition = condition_list
300
+ self._conditions = conditions
285
301
 
286
302
  def update(self):
287
303
  self.get_forecast()
288
304
  self.get_current_condition()
289
305
 
290
- def __get_all_stations(self):
306
+ def __get_all_stations(self) -> dict[str, Any]:
291
307
  _LOGGER.debug("Getting all stations from : %s" % (STATION_URL))
292
308
  data = pd.read_csv(
293
309
  STATION_URL,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.11
3
+ Version: 0.2.13
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -15,7 +15,7 @@ def read(filename):
15
15
 
16
16
  setup(
17
17
  name="hamsclientfork",
18
- version="0.2.11",
18
+ version="0.2.13",
19
19
  url="https://github.com/Rudd-O/hamsclientfork",
20
20
  license="MIT",
21
21
  author="websylv",
File without changes
File without changes