naofireblade / homebridge-weather-plus

A comprehensive weather plugin for homebridge.
MIT License
314 stars 63 forks source link

error in updateWeather hangs homebridge #12

Closed sejmann closed 6 years ago

sejmann commented 6 years ago

looks like wunderground returned incomplete data, and it hung homebridge, requiring a restart. Maybe the whole thing should be wrapped in a try catch?

/opt/local/lib/node_modules/homebridge-weather-station-extended/index.js:323
                        service.setCharacteristic(CustomCharacteristic.ForecastDay, forecast[day]['date']['weekday']);
                                                                                                 ^

TypeError: Cannot read property 'date' of undefined
    at Wunderground.<anonymous> (/opt/local/lib/node_modules/homebridge-weather-station-extended/index.js:323:80)
    at Request._callback (/opt/local/lib/node_modules/homebridge-weather-station-extended/node_modules/wundergroundnode/lib/wundergroundnode.js:148:22)
    at Request.self.callback (/opt/local/lib/node_modules/homebridge-weather-station-extended/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/opt/local/lib/node_modules/homebridge-weather-station-extended/node_modules/request/request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/opt/local/lib/node_modules/homebridge-weather-station-extended/node_modules/request/request.js:1085:12)
    at IncomingMessage.g (events.js:291:16)
naofireblade commented 6 years ago

Good find. I will look into making this more robust but I don't have much time at the moment. If you feel comfortable enough with js you can submit a pull request if you want :) .

naofireblade commented 6 years ago

13 reported the same problems later on. Because it occurs more often I will fix it asap.