Best posts made by uok825
-
RE: Cannot find module "moment"
@sdetweil Hi there! Problem solved. New code:
/* Magic Mirror * Module: MMM-LICE * * By Mykle1 * */ const NodeHelper = require('node_helper'); const request = require('request'); const cheerio = require('cheerio'); module.exports = NodeHelper.create({ start: function() { console.log("Starting node_helper for: " + this.name); }, getLICE: function(url) { request({ url: 'https://kur.altin.in/banka', method: 'GET' }, (error, response, body) => { if (!error && response.statusCode == 200) { const $ = cheerio.load(body); var arr = [] var result = $('.fiyat'); result.each((_id,el) => (arr.push(el.children[0]['data']))) var result = $('h2[id=gfiy]'); result.each((_id,el) => (arr.push(el.children[0]['data']))) this.sendSocketNotification('LICE_RESULT', arr); } }); }, socketNotificationReceived: function(notification, payload) { if (notification === 'GET_LICE') { this.getLICE(payload); } } });
But i have an another problem. Turkish characters in the news seem broken. I think there is a utf-8 error but it doesn’t write anything in the logs.
Edit: The news site is broken, it’s not a mistake about us.
Latest posts made by uok825
-
MMM-PIR js error
Here is error log:
0|run-star | [17.11.2021 14:03.06.696] [ERROR] Whoops! There was an uncaught exception... 0|run-star | [17.11.2021 14:03.06.782] [ERROR] TypeError: Cannot read property 'callbackScripts' of undefined 0|run-star | at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-PIR/node_helper.js:37:45) 0|run-star | at Socket.socket.on (/home/pi/MagicMirror/js/node_helper.js:109:11) 0|run-star | at Socket.emit (events.js:198:13) 0|run-star | at Socket.emitUntyped (/home/pi/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22) 0|run-star | at process.nextTick (/home/pi/MagicMirror/node_modules/socket.io/dist/socket.js:428:39) 0|run-star | at process._tickCallback (internal/process/next_tick.js:61:11)
Here is my node_helper.js
var NodeHelper = require("node_helper"); const exec = require('child_process').exec; const fs = require('fs'); const Gpio = require('onoff').Gpio; var commandDict = { "js": "node", "py": "python", "sh": "sh" }; module.exports = NodeHelper.create({ running: false, socketNotificationReceived: function (notification, payload) { const self = this; if (notification === "CONFIG") { this.config = payload; this.pir = new Gpio(this.config.sensorPin, 'in', 'both'); this.pir.watch(function (err, value) { if (value == 1) { self.sendSocketNotification("USER_PRESENCE", true); if (!self.running) { self.running = true; if (self.config.turnOffDisplay) { execute(buildCommand("/default/ac.py"), function (stdout) { console.log(stdout); }); } } } }); } else if (notification === "TIMER_EXPIRED") { self.running = false; for (var i = 0; i < this.config.callbackScripts.length; i++) { execute(buildCommand(this.config.callbackScripts[i]), function (stdout) { console.log(stdout); }); } if (self.config.turnOffDisplay) { execute(buildCommand("/default/kapat.py"), function (stdout) { console.log(stdout); }); } } }, }); function buildCommand(fileName) { var file = __dirname + "/callbackScripts/" + fileName; var fileExtension = file.split(".").slice(-1).pop(); return commandDict[fileExtension] + " " + file; } function execute(command, callback) { exec(command, function (error, stdout, stderr) { if (error) { console.log(stderr); } else { callback(stdout); } }); }
-
RE: NPM COMMAND NOT FOUND
pi@raspberrypi:~ $ sudo npm uninstall npm -g sudo: npm: komut bulunamadı pi@raspberrypi:~ $ npm -bash: npm: komut yok pi@raspberrypi:~ $ npm install -bash: npm: komut yok pi@raspberrypi:~ $ npm unstall
npm command not founded. thats strange right?
-
RE: NPM COMMAND NOT FOUND
@sdetweil I didn’t install the MagicMirror with sudo. I accidently update the npm with sudo command and than this error shows up. Do I still need to reinstall?
-
RE: NPM COMMAND NOT FOUND
@sdetweil Help me more please. How can i reinstall
-
NPM COMMAND NOT FOUND
0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok 0|MagicMir | /home/pi/MagicMirror/installers/mm.sh: satır 3: npm: komut yok
pm2 got errored and here its the logs
-
RE: Cannot find module "moment"
@sdetweil Hi there! Problem solved. New code:
/* Magic Mirror * Module: MMM-LICE * * By Mykle1 * */ const NodeHelper = require('node_helper'); const request = require('request'); const cheerio = require('cheerio'); module.exports = NodeHelper.create({ start: function() { console.log("Starting node_helper for: " + this.name); }, getLICE: function(url) { request({ url: 'https://kur.altin.in/banka', method: 'GET' }, (error, response, body) => { if (!error && response.statusCode == 200) { const $ = cheerio.load(body); var arr = [] var result = $('.fiyat'); result.each((_id,el) => (arr.push(el.children[0]['data']))) var result = $('h2[id=gfiy]'); result.each((_id,el) => (arr.push(el.children[0]['data']))) this.sendSocketNotification('LICE_RESULT', arr); } }); }, socketNotificationReceived: function(notification, payload) { if (notification === 'GET_LICE') { this.getLICE(payload); } } });
But i have an another problem. Turkish characters in the news seem broken. I think there is a utf-8 error but it doesn’t write anything in the logs.
Edit: The news site is broken, it’s not a mistake about us. -
RE: Cannot find module "moment"
@sdetweil I just rebuild the module without using request.