To follow up… I got it to work by comparing parsed.feed.entries.length to the number of parsed entries, and when all entries were passed I called a callback that sent the notifications.
I’m new to javascript so there’s still a lot to learn.
To follow up… I got it to work by comparing parsed.feed.entries.length to the number of parsed entries, and when all entries were passed I called a callback that sent the notifications.
I’m new to javascript so there’s still a lot to learn.
@Sean Thanks! Logging shows your suspicions were correct:
MYMODULE Thu Nov 23 2017 09:43:15 GMT+0100 (CET): start of method
MYMODULE Thu Nov 23 2017 09:43:15 GMT+0100 (CET): end of method
MYMODULE Thu Nov 23 2017 09:43:16 GMT+0100 (CET): parsed an rss entry
MYMODULE Thu Nov 23 2017 09:43:16 GMT+0100 (CET): parsed an rss entry
MYMODULE Thu Nov 23 2017 09:43:16 GMT+0100 (CET): parsed an rss entry
...
Now I will try to find out if the rss parsers have a finished callback and put the sendSocketNotifications in there…
This is my first attempt at a module using a node_helper.js. My goal is to get an rss and output all rss items on the mirror. I have got the basics working, which is a function in node_helper.js which sends items over to the module js file:
loadFeed: function(url) {
var items = [];
items.push( { title: 'test title', description: 'test description' } );
this.sendSocketNotification('ITEMS', {
items: items
});
},
Output:
But when I try to read and parse an rss, I get nothing… Code:
const FeedMe = require('feedme');
const http = require('http');
...
loadFeed: function(url) {
var items = [];
items.push( { title: 'before', description: 'before' } );
http.get('http://www.npr.org/rss/rss.php?id=1001', (res) => {
var parser = new FeedMe();
parser.on('title', (title) => {
items.push( { title: 'feedtitle', description: 'feedtitle' } );
});
parser.on('item', (item) => {
items.push( { title: 'feeditem', description: 'feeditem' } );
});
res.pipe(parser);
});
items.push( { title: 'after', description: 'after' } );
this.sendSocketNotification('ITEMS', {
items: items
});
},
Output:
“ls node_modules” show that both feedme and http is installed. No relevant errors in .pm2/logs/mm-error-0.log or mm-out-0.log.
So I tried with another rss parser:
const parser = require('rss-parser');
...
loadFeed: function(url) {
var items = [];
items.push( { title: 'before', description: 'before' } );
parser.parseURL('http://www.npr.org/rss/rss.php?id=1001', function(err, parsed) {
parsed.feed.entries.forEach(function(entry) {
items.push( { title: 'entrytitle', description: entry.title } );
});
});
items.push( { title: 'after', description: 'after' } );
this.sendSocketNotification('ITEMS', {
items: items
});
},
Same output as above. No log errors. And rss-parser is installed in node_modules. Also this last code works fine in npm RunKit:
https://runkit.com/embed/q4ucjhbbzpw3
Any ideas what is failing? Or how to debug?
@Sean Thanks a lot! I guess I should have read the readme a bit better :) I will try it out.
I would like to have different symbols in my calendar based on the entries’ text. E.g. if the entry says “***'s birthday” (“birthday” anywhere in the string) I would like to have a cake icon. And for “football training” I would like a football icon etc. And for all other the default icon.
Anyone done this already? I’m currently using the default calendar. Maybe it can be done in MMM-CalendarExt?
@Lange but the ping module is updated along with the clock module, so a crash seems unlikely. But what can I do to debug this?
I have a pi3 powered mirror that works great when first powering up. A few times a day I can see via the ping module that I loose network. I guess that is normal since the pi is behind the frame, using wifi and is placed some distance from the router.
But after wifi has dropped once, the modules (calendar and MMM-ResRobot) are never updated again. The calendar is stuck in time. Even though network comes back. It seems the ping module is updated though.
If I restart the mirror, the modules will update. And if I access the mirror remotely (with MMM-RemoteControl) it shows correctly remotely.
Any ideas what to do?