hamsclientfork 0.2.16__tar.gz → 0.2.18__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.16/hamsclientfork.egg-info → hamsclientfork-0.2.18}/PKG-INFO +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork/client.py +52 -24
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18/hamsclientfork.egg-info}/PKG-INFO +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/setup.py +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/.gitignore +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/LICENSE +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/README.md +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/README.rst +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork/__init__.py +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork/__main__.py +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork/py.typed +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork.egg-info/SOURCES.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork.egg-info/dependency_links.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork.egg-info/requires.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/hamsclientfork.egg-info/top_level.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/setup.cfg +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.18}/tox.ini +0 -0
|
@@ -34,6 +34,9 @@ MS_SEARCH_URL = "https://www.meteosuisse.admin.ch/home/actualite/infos.html?ort=
|
|
|
34
34
|
CURRENT_CONDITION_URL = (
|
|
35
35
|
"https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/VQHA80.csv"
|
|
36
36
|
)
|
|
37
|
+
CURRENT_PRECIPITATION_URL = (
|
|
38
|
+
"https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/VQHA98.csv"
|
|
39
|
+
)
|
|
37
40
|
STATION_URL = "https://data.geo.admin.ch/ch.meteoschweiz.messnetz-automatisch/ch.meteoschweiz.messnetz-automatisch_fr.csv"
|
|
38
41
|
STATION_TYPE_PRECIPITATION = "Précipitation"
|
|
39
42
|
STATION_TYPE_WEATHER = "Station météo"
|
|
@@ -157,50 +160,54 @@ class CurrentCondition(TypedDict):
|
|
|
157
160
|
|
|
158
161
|
def CurrentCondition_from_meteoswiss_data(data: dict[str, Any]) -> CurrentCondition:
|
|
159
162
|
def floatornone(val: Any) -> float | None:
|
|
160
|
-
if val == "" or val == "-":
|
|
163
|
+
if val == "" or val == "-" or val is None:
|
|
161
164
|
return None
|
|
162
165
|
return float(val)
|
|
163
166
|
|
|
164
167
|
return CurrentCondition(
|
|
165
168
|
station=data["Station/Location"],
|
|
166
169
|
date=int(data["Date"]),
|
|
167
|
-
tre200s0=floatornone(data
|
|
168
|
-
rre150z0=floatornone(data
|
|
169
|
-
sre000z0=floatornone(data
|
|
170
|
-
gre000z0=floatornone(data
|
|
171
|
-
ure200s0=floatornone(data
|
|
172
|
-
tde200s0=floatornone(data
|
|
173
|
-
dkl010z0=floatornone(data
|
|
174
|
-
fu3010z0=floatornone(data
|
|
175
|
-
fu3010z1=floatornone(data
|
|
176
|
-
prestas0=floatornone(data
|
|
177
|
-
pp0qffs0=floatornone(data
|
|
178
|
-
pp0qnhs0=floatornone(data
|
|
179
|
-
ppz850s0=floatornone(data
|
|
180
|
-
ppz700s0=floatornone(data
|
|
181
|
-
dv1towz0=floatornone(data
|
|
182
|
-
fu3towz0=floatornone(data
|
|
183
|
-
fu3towz1=floatornone(data
|
|
184
|
-
ta1tows0=floatornone(data
|
|
185
|
-
uretows0=floatornone(data
|
|
186
|
-
tdetows0=floatornone(data
|
|
170
|
+
tre200s0=floatornone(data.get("tre200s0")),
|
|
171
|
+
rre150z0=floatornone(data.get("rre150z0")),
|
|
172
|
+
sre000z0=floatornone(data.get("sre000z0")),
|
|
173
|
+
gre000z0=floatornone(data.get("gre000z0")),
|
|
174
|
+
ure200s0=floatornone(data.get("ure200s0")),
|
|
175
|
+
tde200s0=floatornone(data.get("tde200s0")),
|
|
176
|
+
dkl010z0=floatornone(data.get("dkl010z0")),
|
|
177
|
+
fu3010z0=floatornone(data.get("fu3010z0")),
|
|
178
|
+
fu3010z1=floatornone(data.get("fu3010z1")),
|
|
179
|
+
prestas0=floatornone(data.get("prestas0")),
|
|
180
|
+
pp0qffs0=floatornone(data.get("pp0qffs0")),
|
|
181
|
+
pp0qnhs0=floatornone(data.get("pp0qnhs0")),
|
|
182
|
+
ppz850s0=floatornone(data.get("ppz850s0")),
|
|
183
|
+
ppz700s0=floatornone(data.get("ppz700s0")),
|
|
184
|
+
dv1towz0=floatornone(data.get("dv1towz0")),
|
|
185
|
+
fu3towz0=floatornone(data.get("fu3towz0")),
|
|
186
|
+
fu3towz1=floatornone(data.get("fu3towz1")),
|
|
187
|
+
ta1tows0=floatornone(data.get("ta1tows0")),
|
|
188
|
+
uretows0=floatornone(data.get("uretows0")),
|
|
189
|
+
tdetows0=floatornone(data.get("tdetows0")),
|
|
187
190
|
)
|
|
188
191
|
|
|
189
192
|
|
|
190
193
|
class ClientResult(TypedDict):
|
|
191
194
|
name: str
|
|
192
|
-
forecast: Forecast
|
|
195
|
+
forecast: Forecast | None
|
|
193
196
|
# A list of current conditions for the first station passed.
|
|
194
197
|
condition: list[CurrentCondition]
|
|
195
|
-
# A dictionary of station -> list of the current
|
|
198
|
+
# A dictionary of station -> list of the current precipitation
|
|
196
199
|
# returned by the corresponding station.
|
|
197
200
|
condition_by_station: dict[str, CurrentCondition]
|
|
198
201
|
|
|
199
202
|
|
|
200
203
|
def ClientResult_from_meteoswiss_data(data: dict[str, Any]) -> ClientResult:
|
|
204
|
+
if not data["forecast"].get("plz"): # PLZ came back as zero or None, no forecast
|
|
205
|
+
forecast = None
|
|
206
|
+
else:
|
|
207
|
+
forecast = Forecast_from_meteoswiss_data(data["forecast"])
|
|
201
208
|
return ClientResult(
|
|
202
209
|
name=data["name"],
|
|
203
|
-
forecast=
|
|
210
|
+
forecast=forecast,
|
|
204
211
|
condition=[CurrentCondition_from_meteoswiss_data(x) for x in data["condition"]],
|
|
205
212
|
condition_by_station={
|
|
206
213
|
station: CurrentCondition_from_meteoswiss_data(condition)
|
|
@@ -218,6 +225,8 @@ class meteoSwissClient:
|
|
|
218
225
|
self._allStations: dict[str, Any] | None = None
|
|
219
226
|
self._condition = None
|
|
220
227
|
self._conditions: dict[str, Any] = {}
|
|
228
|
+
self._precipitation = None
|
|
229
|
+
self._precipitations: dict[str, Any] = {}
|
|
221
230
|
self._forecast = None
|
|
222
231
|
_LOGGER.debug(
|
|
223
232
|
"INIT meteoswiss client : name = %s stations = %s postcode = %s"
|
|
@@ -293,11 +302,30 @@ class meteoSwissClient:
|
|
|
293
302
|
lines = response.text.split("\n")
|
|
294
303
|
csv_reader = csv.DictReader(lines, delimiter=";")
|
|
295
304
|
data = [row for row in csv_reader if row]
|
|
305
|
+
with requests.get(CURRENT_PRECIPITATION_URL) as response:
|
|
306
|
+
response.raise_for_status()
|
|
307
|
+
response.encoding = "iso_8859_1"
|
|
308
|
+
lines = response.text.split("\n")
|
|
309
|
+
csv_reader = csv.DictReader(lines, delimiter=";")
|
|
310
|
+
rain_data = [row for row in csv_reader if row]
|
|
296
311
|
conditions = {}
|
|
297
312
|
condition_list = []
|
|
298
313
|
for station in self._stations:
|
|
299
314
|
_LOGGER.debug("Get current condition for : %s" % station)
|
|
300
315
|
stationData = [d for d in data if d["Station/Location"] == station]
|
|
316
|
+
rainData = [d for d in rain_data if d["Station/Location"] == station]
|
|
317
|
+
if rainData and not stationData:
|
|
318
|
+
stationData = rainData
|
|
319
|
+
elif rainData and stationData:
|
|
320
|
+
# Add all values from the rain data to the station data.
|
|
321
|
+
for k, v in rainData.items():
|
|
322
|
+
stationData[k] = v
|
|
323
|
+
else:
|
|
324
|
+
# if
|
|
325
|
+
# (stationData and not rainData)
|
|
326
|
+
# or
|
|
327
|
+
# (not stationData and not rainData)
|
|
328
|
+
pass
|
|
301
329
|
condition_list.extend(stationData)
|
|
302
330
|
if stationData:
|
|
303
331
|
conditions[station] = stationData[0]
|
|
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.16 → hamsclientfork-0.2.18}/hamsclientfork.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|