When the response from HA is missing some forecasted values, the script will throw an error in the Kodi log. In my case the weather provider does not have humidity in the forecast:
2024-07-28 18:49:54.978 T:1592 error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <class 'ValueError'>
Error Contents: invalid literal for int() with base 10: ''
Traceback (most recent call last):
File "/home/fry//.kodi/addons/weather.ha/default.py", line 8, in <module>
ha_weather.MAIN(mode=sys.argv[1],w=WINDOW)
File "/home/fry//.kodi/addons/weather.ha/lib/ha_weather.py", line 85, in __init__
self.getForecasts()
File "/home/fry//.kodi/addons/weather.ha/lib/ha_weather.py", line 248, in getForecasts
set_property('Daily.'+str(i+1)+'.DewPoint' , convert_temp(dewpoint(int(convert_temp(forecast['day'+count+'_temperature'], temperature_unit,'C')), int(forecast['day'+count+'_humidity'])), 'C',None), WND)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
-->End of Python script error report<--
One solution would be to provide bogus values in the HA template sensor, but it would be cleaner if the script handled it correctly and skipped the missing values.
When the response from HA is missing some forecasted values, the script will throw an error in the Kodi log. In my case the weather provider does not have humidity in the forecast:
One solution would be to provide bogus values in the HA template sensor, but it would be cleaner if the script handled it correctly and skipped the missing values.
For now I removed the humidity and the dew point from the forecast in
ha_weather.py
here https://github.com/Eugeniusz-Gienek/kodi_weather_ha/blob/8ae89ce934d670b69681289b6caf70f94d37b5e5/lib/ha_weather.py#L243 and here https://github.com/Eugeniusz-Gienek/kodi_weather_ha/blob/8ae89ce934d670b69681289b6caf70f94d37b5e5/lib/ha_weather.py#L248