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.
- {hamsclientfork-0.2.11/hamsclientfork.egg-info → hamsclientfork-0.2.13}/PKG-INFO +1 -1
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork/client.py +29 -13
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13/hamsclientfork.egg-info}/PKG-INFO +1 -1
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/setup.py +1 -1
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/.gitignore +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/LICENSE +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/README.md +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/README.rst +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork/__init__.py +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork/__main__.py +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork/py.typed +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork.egg-info/SOURCES.txt +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork.egg-info/dependency_links.txt +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork.egg-info/requires.txt +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork.egg-info/top_level.txt +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/setup.cfg +0 -0
- {hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/tox.ini +0 -0
|
@@ -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(
|
|
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
|
|
213
|
+
def __init__(self, displayName=None, postcode=None, *station: str):
|
|
204
214
|
_LOGGER.debug("MS Client INIT")
|
|
205
215
|
self._postCode = postcode
|
|
206
|
-
self.
|
|
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
|
|
213
|
-
% (self._name, self.
|
|
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
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hamsclientfork-0.2.11 → hamsclientfork-0.2.13}/hamsclientfork.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|