Darnit, that makes total sense! Thank you!
Read the statement by Michael Teeuw here.
Latest posts made by seeshaughnessy
-
RE: Stuck trying to sendSocketNotification from my node_helper
-
RE: Can I scale down the entire mirror?
Argh, I can’t believe it was that easy. I feel silly, but thank you so much!
-
Can I scale down the entire mirror?
I have a 21" monitor to use for my magic mirror. My raspberry pi settings show that the highest resolution that I can have is 1280 x 720. I’m not sure how to tell if that’s the monitor’s highest resolution, but either way my mirror modules show up pretty large. Most of the time the modules overlap, since they go past the halfway point. Is there any way to universally scale down everything so that my modules show up smaller? Or, is there a way to check my monitor resolution and override my pi settings?
-
Stuck trying to sendSocketNotification from my node_helper
I must be doing missing something obvious, but I’ve been at this forever. Sorry if the code looks rough, but I’m new to coding and still have some learning to do…
I was able to get my requests just fine when I used axios and async/await (I’m most familiar with this library). I’m trying to convert the code to use the request library that’s built into Magic Mirror, but I can’t figure out what I’m doing wrong.
I’m able to get the array I need with the request.get, but none of the code after my
console.log('Result: ', result); // check
seems to be working. I can’t log my filteredParcels, and the notification is not being sent.Am I missing something silly? Or is my whole concept incorrect?
getOneTracker: function () { // Authenticate and get token var options = { uri: 'https://api.onetracker.app/auth/token', method: 'POST', json: { email: this.config.username, password: this.config.password, }, }; request(options, function (error, response, body) { if (!error && response.statusCode == 200) { const authToken = body.session.token; const options = { uri: 'https://api.onetracker.app/parcels', json: true, headers: { 'x-api-token': authToken, }, }; request.get(options, function (error, response, body) { if (!error && response.statusCode == 200) { let result = body.parcels; console.log('Result: ', result); // check const filteredParcels = result.filter((parcel) => { this.getDaysToReceive(parcel); }); this.sendSocketNotification('ONETRACKER_RESULT', filteredParcels); } }); } }); }, // Returns days left until delivery, null if delivered 1+ days ago, and ? if delivery is unknown getDaysToReceive: function (parcel) { const parcelStatus = parcel.tracking_status; const parcelDate = parcel.tracking_time_estimated; const parcelDay = parcelDate.substr(8, 2); //Get day from tracking data var today = new Date().toString().substr(8, 2); //Get todays date const daysToDelivery = parcelDay - today; if (parcelStatus != 'delivered' && daysToDelivery < 0) return '?'; if (parcelStatus != 'delivered' && daysToDelivery >= 0) return daysToDelivery; if (parcelStatus == 'delivered' && daysToDelivery == 0) return '0'; return; },