@strawberry-3.141 Yes, pasted below are the two files. I am new to JS modules and node.js servers so I was not aware you had to log if you’re receiving a notification. What are you notifying and where do you declare the notification? Do you know of any good documentation on this? I pasted in the code ianperrin suggested to see if it would work but it still displays this.temp as undefined. I must be missing something basic. Thanks for the help!
/* global Module */
/* Magic Mirror
* Module: Bike
* MIT Licensed.
*/
Module.register("bike",{
// Default module config.
defaults: {
text: "Hello good!"
},
start: function() {
this.temp = "This should change";
},
notificationReceived:function(notification, payload, sender) {
if (notification === 'Temperature' && sender.name === 'currentweather') {
var currentweather = payload;
if ( currentweather && currentweather.hasOwnProperty('temperature') ) {
this.temp = currentweather.temperature;
Log.log('The current temperature is ' + currentweather.temperature);
}
}
},
// Override dom generator.
getDom: function() {
var wrapper = document.createElement("div");
var myTemp = document.createElement("div");
myTemp.innerHTML=this.temp;
wrapper.innerHTML = this.config.text;
wrapper.appendChild(myTemp);
return wrapper;
}
});
Here is the current weather function that contains the submission.
processWeather: function(data) {
this.temperature = this.roundValue(data.main.temp);
if (this.config.useBeaufort){
this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed));
}else {
this.windSpeed = parseFloat(data.wind.speed).toFixed(0);
}
this.windDirection = this.deg2Cardinal(data.wind.deg);
this.weatherType = this.config.iconTable[data.weather[0].icon];
var now = new Date();
var sunrise = new Date(data.sys.sunrise * 1000);
var sunset = new Date(data.sys.sunset * 1000);
// The moment().format('h') method has a bug on the Raspberry Pi.
// So we need to generate the timestring manually.
// See issue: https://github.com/MichMich/MagicMirror/issues/181
var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise;
var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
if (this.config.timeFormat !== 24) {
//var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
if (this.config.showPeriod) {
if (this.config.showPeriodUpper) {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
timeString = moment(sunriseSunsetDateObject).format('h:mm A');
} else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
timeString = moment(sunriseSunsetDateObject).format('h:mm a');
}
} else {
//timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
timeString = moment(sunriseSunsetDateObject).format('h:mm');
}
}
this.sunriseSunsetTime = timeString;
this.sunriseSunsetIcon = (sunrise < now && sunset > now) ? "wi-sunset" : "wi-sunrise";
this.sendNotification('Temperature', {temperature:this.temperature});
this.loaded = true;
this.updateDom(this.config.animationSpeed);
},