Prevent currentweather module from crashing.

This commit is contained in:
Michael Teeuw 2016-07-31 17:13:49 +02:00
parent 89917c1582
commit 3d3c4ba02f
2 changed files with 8 additions and 0 deletions

View File

@ -16,6 +16,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Append endpoints of weather modules with `/` to retreive the correct data. (Issue [#337](https://github.com/MichMich/MagicMirror/issues/337)) - Append endpoints of weather modules with `/` to retreive the correct data. (Issue [#337](https://github.com/MichMich/MagicMirror/issues/337))
- Corrected grammer in `module.js` from 'suspend' to 'suspended'. - Corrected grammer in `module.js` from 'suspend' to 'suspended'.
- Fixed openweathermap.org URL in config sample. - Fixed openweathermap.org URL in config sample.
- Prevent currentweather module from crashing when received data object is incorrect.
### Updated ### Updated
- Updated package.json to fix possible vulnerabilities. (Using snyk) - Updated package.json to fix possible vulnerabilities. (Using snyk)

View File

@ -217,6 +217,13 @@ Module.register("currentweather",{
* argument data object - Weather information received form openweather.org. * argument data object - Weather information received form openweather.org.
*/ */
processWeather: function(data) { processWeather: function(data) {
if (!data || !data.main || !data.main.temp) {
// Did not receive usable new data.
// Maybe this needs a better check?
return;
}
this.temperature = this.roundValue(data.main.temp); this.temperature = this.roundValue(data.main.temp);
if (this.config.useBeaufort){ if (this.config.useBeaufort){