Hi, I was able to activate and receive on NR the remote commands on my Orange zero, to do that I'm using node-red-contrib-ir which unfortunately filter the data packet and returns me always "4", I need to edit the script to receive the full message present on /dev/input/event0, someone may please help me? Thanks!
This is the script, you can find it here: node-red-contrib-ir/bpi-ir-node.js at master · 4ib3r/node-red-contrib-ir · GitHub
module.exports = function(RED) {
var IR = require('bpi-ir');
function BpiIrOutNode(config) {
var ir = new IR();
RED.nodes.createNode(this,config);
this.debug = config.debug || false;
this.keyMap = config.keymap || {};
var node = this;
this.on('close', function() {
if (ir !== undefined && ir.stop !== undefined) {
ir.stop();
}
});
ir.start();
var lastKey = null;
var mappKey = function(key) {
var mappedKey = node.keyMap[key];
if (mappedKey == undefined) {
mappedKey = key;
}
return mappedKey;
}
ir.on('down', function(key) {
var mappedKey = mappKey(key);
var msg = { payload: mappedKey };
if (node.debug) {
node.status({fill:"green",shape:"ring",text:"Key: " + mappedKey});
}
node.send([msg, null]);
});
ir.on('up', function(key) {
var mappedKey = mappKey(key);
var msg = { payload: mappedKey };
node.send([null, msg]);
if (node.debug) {
node.status({fill:"red",shape:"ring",text:"Key: " + mappedKey});
}
});
}
RED.nodes.registerType("banana-ir in", BpiIrOutNode);
}
Briefly I would like to share how I activated the IR:
on root access run armbian-config
, under systam/hardware activate IR, save and reboot
after reboot you may verify the driver has been loaded with lsmod | grep -i cir
and dmesg | grep -i ir
commands
At this time you're able to see incoming packets, run on root cat /dev/input/event0 | xxd
and point your remote to theIR receiver and press a buttonm chances are you won't see nothing because the receiving protocol isn't the correct one, for me it worked the nec protocol, to enable it use echo nec > /sys/class/rc/rc0/protocols
, then I was able to receive.
Now install on NR the node-red-contrib-ir and add it on flow with debug node, deply and you will see NR quit with an error, NR hasn't the permission to access the same file, /dev/input/event0, so you need to add access to it with sudo chmod 666 /dev/input/event0.
That's all, but you need to make the changes permanet for the next reboot so I added lines at crontab:
crontab -e
I added lines:
@reboot echo nec | sudo tee /sys/class/rc/rc0/protocols
@reboot sudo chmod 666 /dev/input/event0