Need help >>looking out LIRC intrigration with Mqtt

1,460 views
Skip to first unread message

bidyut das

unread,
Jun 7, 2017, 5:45:34 AM6/7/17
to Node-RED
Any one have idea how to implement this..trying to build Mqtt-IR receiver and Mqtt-IR Receiver along with esp8266 chip...UI update via Node red+REST API for mobile App


IR Receiver ............. Remote command for key sense by IR receiver record it to>> LIRC by defining key>>IR code defined by REST API for mobile 

IR Blaster................REST API for mobile >>Node red>>LIRC>>Mqtt payload publish>> esp8266 IR blaster.

Walter Kraembring

unread,
Jun 7, 2017, 7:23:05 AM6/7/17
to Node-RED
Actually yes, I have managed to get IR receiving and transmission to work in Node-RED, I run it under Linux in a Raspberry pi

First step is you need to make Lirc work with your specific ir device and the remote controls you want to have support for. In my case, I am using a USB-UIRT device. This step may take a while and is a bit complex in the beginning, I struggled a little while until I had it function well

Next you can install lirc_node contribution by Alex Bain found here: https://github.com/alexbain/lirc_node

cd lirc_node
npm install

In my case, I installed it to /home/pi/lirc_node

Then in your Node-RED settings.js you add

    functionGlobalContext: {
        lirc_node:require('/home/pi/lirc_node')
        // os:require('os'),
        // octalbonescript:require('octalbonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },

Save and restart Node-RED

Depending on your supported remotes & buttons you have added to Lirc, you can create a flow in Node-RED for receiving and sending IR codes

My example below is very simple, I use a Samsung remote.


[{"id":"85a45963.6b54c8","type":"function","z":"a15019c7.f0c418","name":"IR receiver","func":"flow.set('lirc_node', global.get('lirc_node'));\nflow.get('lirc_node').init();\n\n// Listening for commands\nvar listenerId = flow.get('lirc_node').addListener(function(data) {\n  node.warn(\"Received IR keypress '\" + data.key + \"'' from remote '\" + data.remote +\"'\");\n});\n","outputs":"0","noerr":0,"x":630,"y":160,"wires":[]},{"id":"c14837a4.053978","type":"inject","z":"a15019c7.f0c418","name":"","topic":"","payload":"Init","payloadType":"str","repeat":"","crontab":"","once":true,"x":230,"y":160,"wires":[["85a45963.6b54c8"]]},{"id":"bd707658.96a358","type":"function","z":"a15019c7.f0c418","name":"IR transmitter","func":"var command = msg.payload.split(',');\n\nflow.get('lirc_node').irsend.send_once(command[0], command[1], function() {\n  node.warn(\"Sent command!\");\n});\n\nreturn msg;\n","outputs":1,"noerr":0,"x":640,"y":240,"wires":[["a3a1d8a1.0af988"]]},{"id":"a3a1d8a1.0af988","type":"debug","z":"a15019c7.f0c418","name":"","active":true,"console":"false","complete":"false","x":910,"y":240,"wires":[]},{"id":"1a891ca1.ade613","type":"inject","z":"a15019c7.f0c418","name":"","topic":"","payload":"SAMSUNG,KEY_VOLUMEUP","payloadType":"str","repeat":"","crontab":"","once":false,"x":300,"y":240,"wires":[["bd707658.96a358"]]},{"id":"7ddc5214.f9649c","type":"inject","z":"a15019c7.f0c418","name":"","topic":"","payload":"SAMSUNG,KEY_VOLUMEDOWN","payloadType":"str","repeat":"","crontab":"","once":false,"x":320,"y":300,"wires":[["bd707658.96a358"]]}]



Walter Kraembring

unread,
Jun 7, 2017, 7:25:22 AM6/7/17
to Node-RED
Obviously you can then go ahead and introduce MQTT and other stuff depending on your requirements & needs

Anthony Di Giovanni

unread,
Aug 8, 2017, 9:57:56 PM8/8/17
to Node-RED
Thanks for posting this! Just solved an issue I'd been having. Great POST Walter!

Piekacz Geoffrey

unread,
Oct 12, 2017, 5:49:44 AM10/12/17
to Node-RED
Hello, 

I tried to use this node but without success. I did every step in your message but i get the message :  [function:IR receiver] ReferenceError: lirc_node is not defined 
Have I something to put in the config.json file? 

thanks,

Geoffrey

Zenofmud

unread,
Oct 12, 2017, 6:08:14 AM10/12/17
to node...@googlegroups.com
Have you installed LIRC as Walter pointed out in this post on June 17th at 7:23 AM?

-- 
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
--- 
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
To view this discussion on the web, visit https://groups.google.com/d/msgid/node-red/d67e29b0-81b1-4937-bfcb-d0f1b2beeb41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Piekacz Geoffrey

unread,
Oct 12, 2017, 7:40:37 AM10/12/17
to Node-RED
I think yes, I have installed lirc and liblircclient_dev, configured modules, config.txt, hardware.conf test it (and it works) with mode2, configured my remote's buttons with irrecords and re-test it with irw command. 
My device is on /dev/lirc0 interface. My guess is something missing in the config.json file. It's like lirc isn't recognize on node-red when I call functions.

Piekacz Geoffrey

unread,
Oct 12, 2017, 8:11:58 AM10/12/17
to Node-RED
Done, I tried something and now it works!

Thanks guys!
Reply all
Reply to author
Forward
0 new messages