Skip to content

Commit

Permalink
Merge pull request #21 from jake1164/bugfix/crash-reading-api
Browse files Browse the repository at this point in the history
Fixed the check for observations
  • Loading branch information
jake1164 authored Feb 21, 2025
2 parents 20bb7f4 + 77a35cf commit 1f0bfa3
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
59 changes: 59 additions & 0 deletions samples_offline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
'precip_probability': 0,
'solar_radiation': 680,
'pressure_trend': 'rising',
'relative_humidity': 51,
'lightning_strike_last_distance_msg': '21 - 23 mi',
'wet_bulb_globe_temperature': 26.0,
'brightness': 81565,
'delta_t': 6.0,
'is_precip_local_yesterday_rain_check': True,
'wind_direction': 324,
'precip_accum_local_day': 0,
'precip_minutes_local_day': 0,
'precip_accum_local_yesterday': 0,
'icon': 'clear-day',
'feels_like': 20.0,
'wind_avg': 8.0,
'wet_bulb_temperature': 22.0,
'time': 1740154205,
'sea_level_pressure': 30.2,
'precip_minutes_local_yesterday': 0,
'uv': 2,
'wind_direction_cardinal': 'NW',
'wind_gust': 11.0,
'is_precip_local_day_rain_check': True,
'air_density': 1.31,
'dew_point': 12.0,
'conditions': 'Clear',
'lightning_strike_last_distance': 22,
'lightning_strike_last_epoch': 1735699735,
'air_temperature': 28.0,
'lightning_strike_count_last_1hr': 0,
'station_pressure': 30.1,
'lightning_strike_count_last_3hr': 0
}
{
'station_pressure': 30.2,
'solar_radiation': 794,
'delta_t': 6.0,
'air_temperature': 28.0,
'precip_probability': 0,
'uv': 6,
'wind_direction': 300,
'wet_bulb_temperature': 22.0,
'conditions': 'Clear',
'time': 1740152700,
'wind_avg': 13.0,
'pressure_trend': 'steady',
'relative_humidity': 47,
'sea_level_pressure': 30.2,
'icon': 'clear-day',
'feels_like': 17.0,
'is_precip_local_day_rain_check': False,
'air_density': 1.31,
'wet_bulb_globe_temperature': 26.0,
'dew_point': 10.0,
'wind_direction_cardinal': 'WNW',
'wind_gust': 31.0
}
12 changes: 10 additions & 2 deletions src/weather/tempest_weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,16 @@ def show_weather(self):
print('unable to get weather', ex)
weather = None

if weather == {} or weather['current_conditions'] == None or len(weather['current_conditions']) == 0:
if self._missed_weather > 5:
if not weather or 'current_conditions' not in weather or len(weather['current_conditions']) == 0:
if self._missed_weather > 10:
import microcontroller
# restart the device
self._weather_display.add_scroll_text("Restarting device")
self._weather_display.show()
microcontroller.reset()
return

if self._missed_weather > 5 and self._missed_weather < 10:
self._weather_display.hide_temperature()
self._weather_display.add_scroll_text("Unable to contact API")
# else if 10 updates then restart the device?
Expand Down

0 comments on commit 1f0bfa3

Please sign in to comment.