pyastroweatherio 0.62.0.dev4__tar.gz → 0.62.0.dev6__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.
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/PKG-INFO +1 -1
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/client.py +264 -179
- pyastroweatherio-0.62.0.dev6/pyastroweatherio/dataclasses.py +936 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/helper_functions.py +22 -18
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/models.py +82 -10
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio.egg-info/PKG-INFO +1 -1
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/setup.py +1 -1
- pyastroweatherio-0.62.0.dev4/pyastroweatherio/dataclasses.py +0 -1119
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/LICENSE +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/README.md +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/__init__.py +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/const.py +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio/errors.py +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio.egg-info/SOURCES.txt +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio.egg-info/dependency_links.txt +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio.egg-info/requires.txt +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/pyastroweatherio.egg-info/top_level.txt +0 -0
- {pyastroweatherio-0.62.0.dev4 → pyastroweatherio-0.62.0.dev6}/setup.cfg +0 -0
|
@@ -40,12 +40,16 @@ from pyastroweatherio.const import (
|
|
|
40
40
|
WIND10M_MAX,
|
|
41
41
|
)
|
|
42
42
|
from pyastroweatherio.dataclasses import (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
AtmosphereData,
|
|
44
|
+
TimeData,
|
|
45
|
+
GeoLocationData,
|
|
46
|
+
ConditionData,
|
|
46
47
|
ForecastData,
|
|
47
48
|
LocationData,
|
|
48
49
|
NightlyConditionsData,
|
|
50
|
+
UpTonightDSOData,
|
|
51
|
+
UpTonightBodiesData,
|
|
52
|
+
UpTonightCometsData,
|
|
49
53
|
)
|
|
50
54
|
from pyastroweatherio.errors import RequestError
|
|
51
55
|
from pyastroweatherio.helper_functions import (
|
|
@@ -54,14 +58,20 @@ from pyastroweatherio.helper_functions import (
|
|
|
54
58
|
ConversionFunctions,
|
|
55
59
|
)
|
|
56
60
|
from pyastroweatherio.models import (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
AtmosphereDataModel,
|
|
62
|
+
ConditionDataModel,
|
|
63
|
+
ForecastDataModel,
|
|
64
|
+
GeoLocationDataModel,
|
|
65
|
+
LocationDataModel,
|
|
66
|
+
TimeDataModel,
|
|
67
|
+
NightlyConditionsDataModel,
|
|
68
|
+
UpTonightDSODataModel,
|
|
69
|
+
UpTonightBodiesDataModel,
|
|
70
|
+
UpTonightCometsDataModel,
|
|
63
71
|
)
|
|
64
72
|
|
|
73
|
+
from pprint import pprint as pp
|
|
74
|
+
|
|
65
75
|
_LOGGER = logging.getLogger(__name__)
|
|
66
76
|
_NOT_AVAILABLE = -9999
|
|
67
77
|
|
|
@@ -162,22 +172,26 @@ class AstroWeather:
|
|
|
162
172
|
longitude,
|
|
163
173
|
elevation,
|
|
164
174
|
timezone_info,
|
|
165
|
-
) ->
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
) -> GeoLocationData | None:
|
|
176
|
+
|
|
177
|
+
geolocation = GeoLocationData(
|
|
178
|
+
data={
|
|
179
|
+
"latitude": latitude,
|
|
180
|
+
"longitude": longitude,
|
|
181
|
+
"elevation": elevation,
|
|
182
|
+
"timezone_info": timezone_info,
|
|
183
|
+
}
|
|
184
|
+
)
|
|
172
185
|
|
|
173
186
|
try:
|
|
174
|
-
|
|
187
|
+
GeoLocationDataModel.validate(geolocation)
|
|
188
|
+
return geolocation
|
|
175
189
|
except ValidationError as ve:
|
|
176
|
-
_LOGGER.error(f"Failed to parse location data: {
|
|
190
|
+
_LOGGER.error(f"Failed to parse geo location data: {geolocation}")
|
|
177
191
|
_LOGGER.error(ve)
|
|
178
192
|
return None
|
|
179
193
|
|
|
180
|
-
async def _get_atmosphere(self, details_seventimer, details_metno) ->
|
|
194
|
+
async def _get_atmosphere(self, details_seventimer, details_metno) -> AtmosphereData | None:
|
|
181
195
|
atmosphere = {}
|
|
182
196
|
|
|
183
197
|
seeing = 0
|
|
@@ -219,14 +233,17 @@ class AstroWeather:
|
|
|
219
233
|
else:
|
|
220
234
|
lifted_index = LIFTED_INDEX_7TIMER_MAPPING[details_seventimer["lifted_index"]]
|
|
221
235
|
|
|
222
|
-
atmosphere =
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
atmosphere = AtmosphereData(
|
|
237
|
+
data={
|
|
238
|
+
"seeing": seeing,
|
|
239
|
+
"transparency": transparency,
|
|
240
|
+
"lifted_index": lifted_index,
|
|
241
|
+
}
|
|
242
|
+
)
|
|
227
243
|
|
|
228
244
|
try:
|
|
229
|
-
|
|
245
|
+
AtmosphereDataModel.validate(atmosphere)
|
|
246
|
+
return atmosphere
|
|
230
247
|
except ValidationError as ve:
|
|
231
248
|
_LOGGER.error(f"Failed to parse atmosphere data: {atmosphere}")
|
|
232
249
|
_LOGGER.error(ve)
|
|
@@ -240,39 +257,43 @@ class AstroWeather:
|
|
|
240
257
|
seeing,
|
|
241
258
|
transparency,
|
|
242
259
|
lifted_index,
|
|
243
|
-
) ->
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
260
|
+
) -> ConditionData | None:
|
|
261
|
+
|
|
262
|
+
condition = ConditionData(
|
|
263
|
+
data={
|
|
264
|
+
"cloudcover": details_metno.get("cloud_area_fraction"),
|
|
265
|
+
"cloud_area_fraction": details_metno.get("cloud_area_fraction"),
|
|
266
|
+
"cloud_area_fraction_high": details_metno.get("cloud_area_fraction_high"),
|
|
267
|
+
"cloud_area_fraction_low": details_metno.get("cloud_area_fraction_low"),
|
|
268
|
+
"cloud_area_fraction_medium": details_metno.get("cloud_area_fraction_medium"),
|
|
269
|
+
"fog_area_fraction": details_metno.get("fog_area_fraction"),
|
|
270
|
+
"seeing": seeing,
|
|
271
|
+
"transparency": transparency,
|
|
272
|
+
"lifted_index": lifted_index,
|
|
273
|
+
"condition_percentage": await self._calc_condition_percentage(
|
|
274
|
+
details_metno.get("cloud_area_fraction_high"),
|
|
275
|
+
details_metno.get("cloud_area_fraction_medium"),
|
|
276
|
+
details_metno.get("cloud_area_fraction_low"),
|
|
277
|
+
seeing,
|
|
278
|
+
transparency,
|
|
279
|
+
details_metno.get("wind_speed"),
|
|
280
|
+
details_metno_next_1_hours.get("details", {}).get("precipitation_amount"),
|
|
281
|
+
),
|
|
282
|
+
"rh2m": details_metno.get("relative_humidity"),
|
|
283
|
+
"wind_speed": details_metno.get("wind_speed"),
|
|
284
|
+
"wind_from_direction": details_metno.get("wind_from_direction"),
|
|
285
|
+
"temp2m": details_metno.get("air_temperature"),
|
|
286
|
+
"dewpoint2m": details_metno.get("dew_point_temperature"),
|
|
287
|
+
"weather": details_metno_next_1_hours.get("summary", {}).get("symbol_code"),
|
|
288
|
+
"weather6": details_metno_next_6_hours.get("summary", {}).get("symbol_code"),
|
|
289
|
+
"precipitation_amount": details_metno_next_1_hours.get("details", {}).get("precipitation_amount"),
|
|
290
|
+
"precipitation_amount6": details_metno_next_6_hours.get("details", {}).get("precipitation_amount"),
|
|
291
|
+
}
|
|
292
|
+
)
|
|
273
293
|
|
|
274
294
|
try:
|
|
275
|
-
|
|
295
|
+
ConditionDataModel.validate(condition)
|
|
296
|
+
return condition
|
|
276
297
|
except ValidationError as ve:
|
|
277
298
|
_LOGGER.error(f"Failed to parse condition data: {condition}")
|
|
278
299
|
_LOGGER.error(ve)
|
|
@@ -287,22 +308,22 @@ class AstroWeather:
|
|
|
287
308
|
transparency,
|
|
288
309
|
wind_speed,
|
|
289
310
|
precipitation_amount,
|
|
290
|
-
):
|
|
311
|
+
) -> int:
|
|
291
312
|
"""Return condition based on cloud cover, seeing, transparency, and wind speed."""
|
|
292
313
|
|
|
293
|
-
if not all(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
):
|
|
305
|
-
|
|
314
|
+
# if not all(
|
|
315
|
+
# v is not None
|
|
316
|
+
# for v in [
|
|
317
|
+
# cloudcover_high,
|
|
318
|
+
# cloudcover_medium,
|
|
319
|
+
# cloudcover_low,
|
|
320
|
+
# seeing,
|
|
321
|
+
# transparency,
|
|
322
|
+
# wind_speed,
|
|
323
|
+
# precipitation_amount,
|
|
324
|
+
# ]
|
|
325
|
+
# ):
|
|
326
|
+
# return None
|
|
306
327
|
|
|
307
328
|
# Seeing is something in between 0 and 2.5 arcsecs
|
|
308
329
|
seeing = seeing * 100 / SEEING_MAX # arcsecs up to 2.5
|
|
@@ -414,42 +435,62 @@ class AstroWeather:
|
|
|
414
435
|
|
|
415
436
|
atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
|
|
416
437
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
"
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
438
|
+
time_data = TimeData(
|
|
439
|
+
data={
|
|
440
|
+
# seventimer_init is "init" of 7timer astro data
|
|
441
|
+
"seventimer_init": seventimer_init,
|
|
442
|
+
# seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
|
|
443
|
+
"seventimer_timepoint": details_seventimer["timepoint"],
|
|
444
|
+
# Forecast_time is the actual datetime for the forecast data onwards in UTC
|
|
445
|
+
# Corresponds to "time" in met data
|
|
446
|
+
"forecast_time": forecast_time,
|
|
447
|
+
}
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
try:
|
|
451
|
+
TimeDataModel.validate(time_data)
|
|
452
|
+
except ValidationError as ve:
|
|
453
|
+
_LOGGER.error(f"Failed to parse location data model data: {time_data}")
|
|
454
|
+
_LOGGER.error(ve)
|
|
455
|
+
|
|
456
|
+
item = LocationData(
|
|
457
|
+
data={
|
|
458
|
+
# Time data
|
|
459
|
+
"time_data": time_data,
|
|
460
|
+
# Time shift to UTC
|
|
461
|
+
"time_shift": await self._astro_routines.time_shift(),
|
|
462
|
+
# Remaining forecast data point in met.no data
|
|
463
|
+
"forecast_length": (len(self._weather_data_metno) - metno_index),
|
|
464
|
+
# Location
|
|
465
|
+
"location_data": self._location_data,
|
|
466
|
+
# Astronomical routines
|
|
467
|
+
"sun_data": await self._astro_routines.sun_data(),
|
|
468
|
+
"moon_data": await self._astro_routines.moon_data(),
|
|
469
|
+
"darkness_data": await self._astro_routines.darkness_data(),
|
|
470
|
+
"night_duration_astronomical": await self._astro_routines.night_duration_astronomical(),
|
|
471
|
+
"deepsky_forecast": await self._get_deepsky_forecast(),
|
|
472
|
+
# Met.no
|
|
473
|
+
"condition_data": await self._get_condition(
|
|
474
|
+
details_metno,
|
|
475
|
+
details_metno_next_1_hours,
|
|
476
|
+
details_metno_next_6_hours,
|
|
477
|
+
atmosphere_data.seeing,
|
|
478
|
+
atmosphere_data.transparency,
|
|
479
|
+
atmosphere_data.lifted_index,
|
|
480
|
+
),
|
|
481
|
+
# Uptonight objects
|
|
482
|
+
"uptonight": await self._get_deepsky_objects(),
|
|
483
|
+
"uptonight_bodies": await self._get_bodies(),
|
|
484
|
+
"uptonight_comets": await self._get_comets(),
|
|
485
|
+
}
|
|
486
|
+
)
|
|
487
|
+
|
|
488
|
+
try:
|
|
489
|
+
LocationDataModel.validate(item)
|
|
490
|
+
items.append(item)
|
|
491
|
+
except ValidationError as ve:
|
|
492
|
+
_LOGGER.error(f"Failed to parse location data model data: {item}")
|
|
493
|
+
_LOGGER.error(ve)
|
|
453
494
|
|
|
454
495
|
return items
|
|
455
496
|
|
|
@@ -525,26 +566,55 @@ class AstroWeather:
|
|
|
525
566
|
|
|
526
567
|
atmosphere_data = await self._get_atmosphere(details_seventimer, details_metno)
|
|
527
568
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
569
|
+
time_data = TimeData(
|
|
570
|
+
data={
|
|
571
|
+
# seventimer_init is "init" of 7timer astro data
|
|
572
|
+
"seventimer_init": init_ts,
|
|
573
|
+
# seventimer_timepoint is "timepoint" of 7timer astro data and defines the data for init + timepoint
|
|
574
|
+
"seventimer_timepoint": details_seventimer["timepoint"],
|
|
575
|
+
# Forecast_time is the actual datetime for the forecast data onwards in UTC
|
|
576
|
+
# Corresponds to "time" in met data
|
|
577
|
+
"forecast_time": datetime.strptime(datapoint.get("time"), "%Y-%m-%dT%H:%M:%SZ"), # timestamp
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
|
|
581
|
+
try:
|
|
582
|
+
TimeDataModel.validate(time_data)
|
|
583
|
+
except ValidationError as ve:
|
|
584
|
+
_LOGGER.error(f"Failed to parse location data model data: {time_data}")
|
|
585
|
+
_LOGGER.error(ve)
|
|
586
|
+
|
|
587
|
+
item = ForecastData(
|
|
588
|
+
data={
|
|
589
|
+
# Time data
|
|
590
|
+
"time_data": time_data,
|
|
591
|
+
"hour": datetime.strptime(
|
|
592
|
+
datapoint.get("time"), "%Y-%m-%dT%H:%M:%SZ"
|
|
593
|
+
).hour, # forecast_time.hour % 24,
|
|
594
|
+
"condition_data": await self._get_condition(
|
|
595
|
+
details_metno,
|
|
596
|
+
details_metno_next_1_hours,
|
|
597
|
+
details_metno_next_6_hours,
|
|
598
|
+
atmosphere_data.seeing,
|
|
599
|
+
atmosphere_data.transparency,
|
|
600
|
+
atmosphere_data.lifted_index,
|
|
601
|
+
),
|
|
602
|
+
}
|
|
603
|
+
)
|
|
542
604
|
|
|
543
|
-
|
|
605
|
+
try:
|
|
606
|
+
ForecastDataModel.validate(item)
|
|
607
|
+
items.append(item)
|
|
608
|
+
except ValidationError as ve:
|
|
609
|
+
_LOGGER.error(f"Failed to parse forecast data: {item}")
|
|
610
|
+
_LOGGER.error(ve)
|
|
544
611
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
item["
|
|
612
|
+
# items.append(ForecastData(data=item))
|
|
613
|
+
|
|
614
|
+
# item["seventimer_timepoint"] = item["seventimer_timepoint"] + 1
|
|
615
|
+
# # item.seventimer_timepoint(item["seventimer_timepoint"] + 1)
|
|
616
|
+
# item["forecast_time"] = item["forecast_time"] + timedelta(hours=1)
|
|
617
|
+
# item["hour"] = item["hour"] + 1
|
|
548
618
|
|
|
549
619
|
cnt += 1
|
|
550
620
|
if cnt >= hours_to_show:
|
|
@@ -555,7 +625,7 @@ class AstroWeather:
|
|
|
555
625
|
_LOGGER.debug("Forceast Length: %s", str(len(items)))
|
|
556
626
|
return items
|
|
557
627
|
|
|
558
|
-
async def _get_deepsky_forecast(self):
|
|
628
|
+
async def _get_deepsky_forecast(self) -> list:
|
|
559
629
|
"""Return Deepsky Forecast data."""
|
|
560
630
|
|
|
561
631
|
cnv = ConversionFunctions()
|
|
@@ -634,15 +704,24 @@ class AstroWeather:
|
|
|
634
704
|
)
|
|
635
705
|
|
|
636
706
|
if details_forecast.forecast_time.hour == sun_next_rising.hour or index >= (forecast_data_len - 1):
|
|
637
|
-
item =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
707
|
+
item = NightlyConditionsData(
|
|
708
|
+
data={
|
|
709
|
+
"seventimer_init": init_ts,
|
|
710
|
+
"dayname": forecast_dayname,
|
|
711
|
+
"hour": start_forecast_hour,
|
|
712
|
+
"nightly_conditions": interval_points,
|
|
713
|
+
"weather": start_weather,
|
|
714
|
+
"precipitation_amount6": start_precipitation_amount6,
|
|
715
|
+
}
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
try:
|
|
719
|
+
NightlyConditionsDataModel.validate(item)
|
|
720
|
+
except ValidationError as ve:
|
|
721
|
+
_LOGGER.error(f"Failed to parse nightly conditions model data: {item}")
|
|
722
|
+
_LOGGER.error(ve)
|
|
723
|
+
|
|
724
|
+
items.append(item)
|
|
646
725
|
|
|
647
726
|
conditions_numeric = ""
|
|
648
727
|
for condition in interval_points:
|
|
@@ -666,7 +745,7 @@ class AstroWeather:
|
|
|
666
745
|
# #########################################################################
|
|
667
746
|
# UpTonight
|
|
668
747
|
# #########################################################################
|
|
669
|
-
async def _get_deepsky_objects(self):
|
|
748
|
+
async def _get_deepsky_objects(self) -> list:
|
|
670
749
|
"""Return Deepsky Objects for today."""
|
|
671
750
|
|
|
672
751
|
items = []
|
|
@@ -704,27 +783,29 @@ class AstroWeather:
|
|
|
704
783
|
else:
|
|
705
784
|
dso_meridian_antitransit_utc = ""
|
|
706
785
|
|
|
707
|
-
item =
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
786
|
+
item = UpTonightDSOData(
|
|
787
|
+
data={
|
|
788
|
+
"id": dso_id.get(str(row), ""),
|
|
789
|
+
"target_name": dso_target_name.get(str(row), ""),
|
|
790
|
+
"type": dso_type.get(str(row), ""),
|
|
791
|
+
"constellation": dso_constellation.get(str(row), ""),
|
|
792
|
+
"size": dso_size.get(str(row), ""),
|
|
793
|
+
"visual_magnitude": dso_visual_magnitude.get(str(row), ""),
|
|
794
|
+
"meridian_transit": dso_meridian_transit_utc,
|
|
795
|
+
"meridian_antitransit": dso_meridian_antitransit_utc,
|
|
796
|
+
"foto": dso_foto.get(str(row), 0),
|
|
797
|
+
}
|
|
798
|
+
)
|
|
718
799
|
try:
|
|
719
|
-
|
|
800
|
+
UpTonightDSODataModel.validate(item)
|
|
801
|
+
items.append(item)
|
|
720
802
|
except ValidationError as ve:
|
|
721
803
|
_LOGGER.error(f"Failed to parse deep sky object data: {item}")
|
|
722
804
|
_LOGGER.error(ve)
|
|
723
805
|
|
|
724
|
-
|
|
725
|
-
return None
|
|
806
|
+
return items
|
|
726
807
|
|
|
727
|
-
async def _get_bodies(self):
|
|
808
|
+
async def _get_bodies(self) -> list:
|
|
728
809
|
"""Return Bodies for today."""
|
|
729
810
|
|
|
730
811
|
items = []
|
|
@@ -758,25 +839,27 @@ class AstroWeather:
|
|
|
758
839
|
else:
|
|
759
840
|
body_meridian_transit_utc = ""
|
|
760
841
|
|
|
761
|
-
item =
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
842
|
+
item = UpTonightBodiesData(
|
|
843
|
+
data={
|
|
844
|
+
"target_name": body_target_name.get(str(row), ""),
|
|
845
|
+
"max_altitude": body_max_altitude.get(str(row), ""),
|
|
846
|
+
"azimuth": body_azimuth.get(str(row), ""),
|
|
847
|
+
"max_altitude_time": body_max_altitude_time_utc,
|
|
848
|
+
"visual_magnitude": body_visual_magnitude.get(str(row), ""),
|
|
849
|
+
"meridian_transit": body_meridian_transit_utc,
|
|
850
|
+
"foto": body_foto.get(str(row), 0),
|
|
851
|
+
}
|
|
852
|
+
)
|
|
770
853
|
try:
|
|
771
|
-
|
|
854
|
+
UpTonightBodiesDataModel.validate(item)
|
|
855
|
+
items.append(item)
|
|
772
856
|
except ValidationError as ve:
|
|
773
857
|
_LOGGER.error(f"Failed to parse bodies data: {item}")
|
|
774
858
|
_LOGGER.error(ve)
|
|
775
859
|
|
|
776
|
-
|
|
777
|
-
return None
|
|
860
|
+
return items
|
|
778
861
|
|
|
779
|
-
async def _get_comets(self):
|
|
862
|
+
async def _get_comets(self) -> list:
|
|
780
863
|
"""Return Comets for today."""
|
|
781
864
|
|
|
782
865
|
items = []
|
|
@@ -808,25 +891,27 @@ class AstroWeather:
|
|
|
808
891
|
- timedelta(seconds=await self._astro_routines.time_shift())
|
|
809
892
|
).replace(tzinfo=UTC)
|
|
810
893
|
|
|
811
|
-
item =
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
894
|
+
item = UpTonightCometsData(
|
|
895
|
+
data={
|
|
896
|
+
"designation": comet_target_name.get(str(row), ""),
|
|
897
|
+
"distance_au_earth": distance_au_earth.get(str(row), ""),
|
|
898
|
+
"distance_au_sun": distance_au_sun.get(str(row), ""),
|
|
899
|
+
"absolute_magnitude": absolute_magnitude.get(str(row), ""),
|
|
900
|
+
"visual_magnitude": visual_magnitude.get(str(row), ""),
|
|
901
|
+
"altitude": altitude.get(str(row), ""),
|
|
902
|
+
"azimuth": azimuth.get(str(row), ""),
|
|
903
|
+
"rise_time": rise_time_local_utc,
|
|
904
|
+
"set_time": set_time_local_utc,
|
|
905
|
+
}
|
|
906
|
+
)
|
|
822
907
|
try:
|
|
823
|
-
|
|
908
|
+
UpTonightCometsDataModel.validate(item)
|
|
909
|
+
items.append(item)
|
|
824
910
|
except ValidationError as ve:
|
|
825
911
|
_LOGGER.error(f"Failed to parse comets data: {item}")
|
|
826
912
|
_LOGGER.error(ve)
|
|
827
913
|
|
|
828
|
-
|
|
829
|
-
return None
|
|
914
|
+
return items
|
|
830
915
|
|
|
831
916
|
async def _retrieve_data_uptonight(self):
|
|
832
917
|
"""Retrieves current data from uptonight"""
|
|
@@ -944,9 +1029,9 @@ class AstroWeather:
|
|
|
944
1029
|
url = (
|
|
945
1030
|
str(f"{BASE_URL_SEVENTIMER}")
|
|
946
1031
|
+ "?lon="
|
|
947
|
-
+ str("%.1f" % round(self.
|
|
1032
|
+
+ str("%.1f" % round(self._location_data.longitude, 2))
|
|
948
1033
|
+ "&lat="
|
|
949
|
-
+ str("%.1f" % round(self.
|
|
1034
|
+
+ str("%.1f" % round(self._location_data.latitude, 2))
|
|
950
1035
|
+ "&product="
|
|
951
1036
|
+ str(product)
|
|
952
1037
|
+ "&output=json"
|