# Anyone here every played with IR commands?

**URL:** <https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860>\
**Category:** General\
**Created:** [29 March 2020 21:44 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860 "2020-03-29T21:44:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 March 2020 21:44 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/1 "2020-03-29T21:44:37Z")

</div>

I have just bought one of these IR _pucks_ and flashed with with Tasmota so I can keep things local.

I made a simple flow to test it and it is receiving data when I point a remote at it and press a button.

Thing is I don't know how to send that message back to the _puck_ to repeat the command it just saw.

This is the basic flow.

It looks at the `topic` and if it is from the _puck_, it saves it to context.  
If a message with `payload` set to "SEND" it sets the payload to the stored value and sends it.

Alas nothing happens.

```auto
[{"id":"478161dd.30b0b8","type":"function","z":"b95543c8.1478f8","name":"","func":"if (msg.topic == \"IR_REMOTE_CONTROL/tele/RESULT\")\n{\n // Save to context.\n context.set(\"1\",msg.payload);\n node.warn(\"Saved\");\n return;\n}\nif (msg.payload == \"SEND\")\n{\n msg.payload = context.get(\"1\");\n return msg;\n}\n","outputs":1,"noerr":0,"x":310,"y":1280,"wires":[["92a365c6.af355"]]},{"id":"d20f5a68.c104c","type":"mqtt in","z":"b95543c8.1478f8","name":"IR_Command_RX","topic":"IR_REMOTE_CONTROL/#","qos":"2","datatype":"auto","broker":"8a2e80be.f7c928","x":170,"y":1200,"wires":[["2df2942d.674894","478161dd.30b0b8"]]},{"id":"92a365c6.af355","type":"mqtt out","z":"b95543c8.1478f8","name":"","topic":"IR_Command_TX","qos":"","retain":"","broker":"8a2e80be.f7c928","x":530,"y":1280,"wires":[]},{"id":"37235a8f.e72fce","type":"inject","z":"b95543c8.1478f8","name":"","topic":"","payload":"SEND","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1280,"wires":[["478161dd.30b0b8"]]},{"id":"2df2942d.674894","type":"debug","z":"b95543c8.1478f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":350,"y":1150,"wires":[]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"ARDUINO_STATUS","birthQos":"2","birthPayload":"connected","willTopic":"ARDUINO_STATUS","willQos":"0","willPayload":"disconnected"}]

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 March 2020 22:18 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/2 "2020-03-29T22:18:15Z")

</div>

What IR _puck_ did you purchase?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 March 2020 22:21 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/3 "2020-03-29T22:21:23Z")

</div>

[This one.](https://templates.blakadder.com/mirabella_genio_I002577.html)

Going through the fun of testing, but am not having much joy.

Though I have since discovered the command should be more like:

`msg = {"Protocol":"SAMSUNG","Bits":32,"Data":"0xE0E0D02F","DataLSB":"0x07070BF4","Repeat":4};`

With the topic of: `IR_REMOTE_CONTROL/cmnd/IRSend`

But the _puck_ isn't receiving that in its console.

This is the modified flow:

```auto
[{"id":"2fa6f939.231a8e","type":"inject","z":"b95543c8.1478f8","name":"","topic":"","payload":"SEND","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":1350,"wires":[["25b3f758.654538"]]},{"id":"25b3f758.654538","type":"function","z":"b95543c8.1478f8","name":"","func":"msg = {\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"DataLSB\":\"0x07070BF4\",\"Repeat\":4};\n\n//msg = {\"IrReceived\":{\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"DataLSB\":\"0x07070BF4\",\"Repeat\":0}}\n\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":1350,"wires":[["d3bd9bd9.761bc"]]},{"id":"d3bd9bd9.761bc","type":"change","z":"b95543c8.1478f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"IR_REMOTE_CONTROL/cmnd/IRSend","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":1280,"wires":[["92a365c6.af355","a0855ef3.c05038"]]},{"id":"92a365c6.af355","type":"mqtt out","z":"b95543c8.1478f8","name":"IR_TX","topic":"IR_Command_TX/cmnd/IRSend","qos":"","retain":"","broker":"8a2e80be.f7c928","x":730,"y":1280,"wires":[]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"ARDUINO_STATUS","birthQos":"2","birthPayload":"connected","willTopic":"ARDUINO_STATUS","willQos":"0","willPayload":"disconnected"}]

```

This is what I see in the `debug` window:  
`{"Protocol":"SAMSUNG","Bits":32,"Data":"0xE0E0D02F","DataLSB":"0x07070BF4","Repeat":4,"_msgid":"df5bf20e.44991","topic":"IR_REMOTE_CONTROL/cmnd/IRSend"}`

And this is the bigger picture looking at the device's console, the message is not received.

 ![Screenshot from 2020-03-30 09-24-13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6b953c1623d4e46cf21f07518d04034f77e891a.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [29 March 2020 22:27 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/4 "2020-03-29T22:27:16Z")

</div>

That looks like a BIG rabbit hole - I'm going to slowly climb out 🙂

JFI I use LIRC on old Jessie on Pi for my IR stuff so this is way beyond my paygrade 🙂

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 March 2020 22:29 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/5 "2020-03-29T22:29:27Z")

</div>

No problems. It is my problem. Thanks though.

I'm guessing/hoping it will be a stupid thing I am doing like the `topic` or something like that not being exact.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [29 March 2020 23:43 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/6 "2020-03-29T23:43:38Z")

</div>

Been trying and (still) not having any luck.

The question still stands: Has anyone got one of these who could help me with getting it working?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 March 2020 00:53 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/7 "2020-03-30T00:53:24Z")

</div>

Progress, but still not there.

If I enter this from a CLI it works:  
`mosquitto_pub -h 192.168.0.99 -t "IR_REMOTE_CONTROL/cmnd/IRSend" -m "{"Protocol":"SAMSUNG","Bits":32,"Data":"0xE0E0D02F","Repeat":4}"`

But I am now stuck how to put that into a MQTT message in Node-Red.

(Typically as I have now posted the question I will work it out. But if I don't: I won't.)

If you don't mind, maybe show me where I am messing it up.

This is the flow as of now:

```auto
[{"id":"2fa6f939.231a8e","type":"inject","z":"b95543c8.1478f8","name":"","topic":"","payload":"SEND","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":1350,"wires":[["25b3f758.654538"]]},{"id":"25b3f758.654538","type":"function","z":"b95543c8.1478f8","name":"","func":"//msg = {\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"DataLSB\":\"0x07070BF4\",\"Repeat\":4};\n//msg.IRSend = {\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"DataLSB\":\"0x07070BF4\",\"Repeat\":4};\n//msg.IRSend = {\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"Repeat\":4};\nmsg = {\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"Repeat\":4};\n//msg = {\"IrReceived\":{\"Protocol\":\"SAMSUNG\",\"Bits\":32,\"Data\":\"0xE0E0D02F\",\"DataLSB\":\"0x07070BF4\",\"Repeat\":0}}\n\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":1350,"wires":[["d3bd9bd9.761bc"]]},{"id":"d3bd9bd9.761bc","type":"change","z":"b95543c8.1478f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"IR_Command_TX/cmnd/IRSend","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":1280,"wires":[["92a365c6.af355","a0855ef3.c05038"]]},{"id":"92a365c6.af355","type":"mqtt out","z":"b95543c8.1478f8","name":"IR_TX","topic":"","qos":"","retain":"","broker":"8a2e80be.f7c928","x":730,"y":1280,"wires":[]},{"id":"8a2e80be.f7c928","type":"mqtt-broker","z":"","name":"MQTT host","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"ARDUINO_STATUS","birthQos":"2","birthPayload":"connected","willTopic":"ARDUINO_STATUS","willQos":"0","willPayload":"disconnected"}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [30 March 2020 01:02 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/8 "2020-03-30T01:02:58Z")

</div>

Found the problem!

`topic` should have been `IR_REMOTE_CONTROL/cmnd/IRSend`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 April 2020 01:03 UTC](https://discourse.nodered.org/t/anyone-here-every-played-with-ir-commands/23860/9 "2020-04-13T01:03:08Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
