Home Information - Your home, your data, organized.
Python
Fix weather errors crashing page rendering and NWS null safety bug
Anthony Cassandrae515c6075e55
diff --git a/src/hi/apps/console/console_side.py b/src/hi/apps/console/console_side.pyindex f1255fe2..304dd0dd 100644--- a/src/hi/apps/console/console_side.py+++ b/src/hi/apps/console/console_side.py@@ -1,16 +1,28 @@+import logging+from hi.apps.security.security_mixins import SecurityMixinfrom hi.apps.weather.weather_mixins import WeatherMixinfrom .console_mixins import ConsoleMixin+logger = logging.getLogger(__name__)+class ConsoleSideHelper( ConsoleMixin, SecurityMixin, WeatherMixin ):-+def get_side_template_name_and_context( self, request, *args, **kwargs ):- weather_manager = self.weather_manager()+ weather_overview_data = None+ weather_alert_list = []+ try:+ weather_manager = self.weather_manager()+ weather_overview_data = weather_manager.get_weather_overview_data()+ weather_alert_list = weather_manager.get_weather_alerts()+ except Exception as e:+ logger.error( f'Weather data unavailable: {e}' )+context = {- 'weather_overview_data': weather_manager.get_weather_overview_data(),- 'weather_alert_list': weather_manager.get_weather_alerts(),+ 'weather_overview_data': weather_overview_data,+ 'weather_alert_list': weather_alert_list,'security_status_data': self.security_manager().get_security_status_data(),'camera_control_display_list': self.console_manager().get_camera_control_display_list(),}diff --git a/src/hi/apps/weather/weather_sources/nws.py b/src/hi/apps/weather/weather_sources/nws.pyindex 6279fa9c..67b00bcc 100644--- a/src/hi/apps/weather/weather_sources/nws.py+++ b/src/hi/apps/weather/weather_sources/nws.py@@ -334,7 +334,7 @@ class NationalWeatherService( WeatherDataSource, WeatherMixin ):source_datetime = source_datetime,station = station,)- if wind_gust_data_point is not None:+ if wind_gust_data_point is not None and weather_conditions_data.windspeed is not None:weather_conditions_data.windspeed.quantity_max = wind_gust_data_point.quantitydescription_short = properties_data.get( 'textDescription' )