hamsclientfork 0.2.16__tar.gz → 0.2.17__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.17}/PKG-INFO +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork/client.py +46 -22
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17/hamsclientfork.egg-info}/PKG-INFO +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/setup.py +1 -1
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/.gitignore +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/LICENSE +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/README.md +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/README.rst +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork/__init__.py +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork/__main__.py +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork/py.typed +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork.egg-info/SOURCES.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork.egg-info/dependency_links.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork.egg-info/requires.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/hamsclientfork.egg-info/top_level.txt +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/setup.cfg +0 -0
- {hamsclientfork-0.2.16 → hamsclientfork-0.2.17}/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,33 +160,33 @@ 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
|
|
|
@@ -192,7 +195,7 @@ class ClientResult(TypedDict):
|
|
|
192
195
|
forecast: Forecast
|
|
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
|
|
|
@@ -218,6 +221,8 @@ class meteoSwissClient:
|
|
|
218
221
|
self._allStations: dict[str, Any] | None = None
|
|
219
222
|
self._condition = None
|
|
220
223
|
self._conditions: dict[str, Any] = {}
|
|
224
|
+
self._precipitation = None
|
|
225
|
+
self._precipitations: dict[str, Any] = {}
|
|
221
226
|
self._forecast = None
|
|
222
227
|
_LOGGER.debug(
|
|
223
228
|
"INIT meteoswiss client : name = %s stations = %s postcode = %s"
|
|
@@ -293,11 +298,30 @@ class meteoSwissClient:
|
|
|
293
298
|
lines = response.text.split("\n")
|
|
294
299
|
csv_reader = csv.DictReader(lines, delimiter=";")
|
|
295
300
|
data = [row for row in csv_reader if row]
|
|
301
|
+
with requests.get(CURRENT_PRECIPITATION_URL) as response:
|
|
302
|
+
response.raise_for_status()
|
|
303
|
+
response.encoding = "iso_8859_1"
|
|
304
|
+
lines = response.text.split("\n")
|
|
305
|
+
csv_reader = csv.DictReader(lines, delimiter=";")
|
|
306
|
+
rain_data = [row for row in csv_reader if row]
|
|
296
307
|
conditions = {}
|
|
297
308
|
condition_list = []
|
|
298
309
|
for station in self._stations:
|
|
299
310
|
_LOGGER.debug("Get current condition for : %s" % station)
|
|
300
311
|
stationData = [d for d in data if d["Station/Location"] == station]
|
|
312
|
+
rainData = [d for d in rain_data if d["Station/Location"] == station]
|
|
313
|
+
if rainData and not stationData:
|
|
314
|
+
stationData = rainData
|
|
315
|
+
elif rainData and stationData:
|
|
316
|
+
# Add all values from the rain data to the station data.
|
|
317
|
+
for k, v in rainData.items():
|
|
318
|
+
stationData[k] = v
|
|
319
|
+
else:
|
|
320
|
+
# if
|
|
321
|
+
# (stationData and not rainData)
|
|
322
|
+
# or
|
|
323
|
+
# (not stationData and not rainData)
|
|
324
|
+
pass
|
|
301
325
|
condition_list.extend(stationData)
|
|
302
326
|
if stationData:
|
|
303
327
|
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.17}/hamsclientfork.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|