# ESP Tasmota + IR Sensor

**URL:** <https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218>\
**Category:** Hardware\
**Created:** [17 March 2020 09:28 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218 "2020-03-17T09:28:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [17 March 2020 09:28 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/1 "2020-03-17T09:28:58Z")

</div>

Hi,

I request help from Portugal.

I made a protection with an ESP w / Tasmota + IR Sensor.  
 ![8de8b56387c2c52ed470b5a9efe0a5a51f8842b6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8de8b56387c2c52ed470b5a9efe0a5a51f8842b6.jpeg)

 ![c8d3e75343b54b91238f50b8e9107b8545609ba1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8d3e75343b54b91238f50b8e9107b8545609ba1.jpeg)

to do some functions with the TV control in the room, like turning off the light in the room ... But I am not able to integrate it into NODE-RED.

MQTT receives the code in NODE-RED, but I'm not able to say code x, it does the function y.  
Can you help?

 ![c3b2ceba0a2f08cb61a8adde829d317010055e3c](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a9665b71fb3ecc58027937f48d39f1fdd415768e.png)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [17 March 2020 09:31 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/2 "2020-03-17T09:31:07Z")

</div>

It would be helpful to see the MQTT message that you are trying to utilise.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 March 2020 09:36 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/3 "2020-03-17T09:36:43Z")

</div>

... add a debug node after the mqtt in node - set to show full msg - and show us the result of a couple of messages so we can see the different types that arrive.

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [17 March 2020 18:41 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/4 "2020-03-17T18:41:40Z")

</div>

I apologize for my english, google translator.

I think this is what they asked for:

 ![Sem Título](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/6/36742ac4ffdd99742cd2f549991484c121aa293f.png)  
 ![Sem Título](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/420fe079b4b9bc26a11b2a69506a4b70694586d4.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 March 2020 21:19 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/5 "2020-03-17T21:19:19Z")

</div>

Set the mqtt output to complete msg output.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 March 2020 21:33 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/6 "2020-03-17T21:33:53Z")

</div>

Great - so from that debug we can see that the (useful) topic is the `testeIR/tele/RESULT` one - and that the reply is a JSON string... and that the really useful bit is the `Data` property within that.  
So first we can change the MQTT node to Output - a parsed JSON object. That would change it from a string into an object... then you need a change node - set to move `msg.payload.Data` to msg.payload - before then feeding into a switch (as you have ) and a debug jsut so you can check it's getting the right sort of data.

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [17 March 2020 21:50 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/7 "2020-03-17T21:50:21Z")

</div>

Thank you for your help. I understood the plan, but I don't know how to do it. Can it help explained with print or a Node-RED flow?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 March 2020 22:41 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/8 "2020-03-17T22:41:40Z")

</div>

Change the mqtt node:

 ![Screenshot 2020-03-17 at 23.39.15](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/6/b6512269faac0e232218aabbebdb83db58d41ff8.jpeg)

Change the switch node, instead of property `msg.payload`, change it to `msg.payload.Data`

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [19 March 2020 18:35 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/9 "2020-03-19T18:35:42Z")

</div>

hi, still not working. Can you help please?

```auto
{"Time":"2020-03-19T19:32:26","IrReceived":{"Protocol":"NEC","Bits":32,"Data":"0x00FDAA55"}}

```

 ![Sem Título](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/783731321bfca72c641c233084bc33566ffcc81c.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 March 2020 19:26 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/10 "2020-03-19T19:26:51Z")

</div>

what is the output from the switch ?

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [19 March 2020 19:40 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/11 "2020-03-19T19:40:08Z")

</div>

There is no information at the output on the Switch.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [19 March 2020 22:52 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/12 "2020-03-19T22:52:55Z")

</div>

I think @bakman2 wants to see what is comming fron the switch, Put a separate debug node on each output of the switch.

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [19 March 2020 23:00 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/13 "2020-03-19T23:00:37Z")

</div>

I put Debug in the outputs of the Switch, there is no message in Debug, there is simply no message, Debug is empty.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [19 March 2020 23:04 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/14 "2020-03-19T23:04:59Z")

</div>

> [@bakman2](#):
>
> msg.payload.Data

But your object shows: `payload.IrReceived.Data` so that is what you should use in the switch node.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [19 March 2020 23:30 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/15 "2020-03-19T23:30:08Z")

</div>

Put another condition in the switch node and use the 'otherwise' option.  
Also, in the switch node are you using 'checking all rules' or 'stopping after first match'?

Use 'stopping after first match' if you aren't trying to make an AND condition with the rules i.e.  
if A and B and C go do something \<== 'checking all rules'  
vrs  
if A go do something1  
if B go do something2  
if C go do something3

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [20 March 2020 15:08 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/16 "2020-03-20T15:08:14Z")

</div>

![Sem Título](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d09ee521d97485f1db07feb79505f9c1102e1643.png)

is the most correct string?

 ![Sem Título](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/3/e37c711aad65a5640c3c41281d0587b39ca1146a.png)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 16:04 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/17 "2020-03-20T16:04:21Z")

</div>

Where is the rule checking for 'otherwise'???

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [20 March 2020 16:05 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/18 "2020-03-20T16:05:54Z")

</div>

Thank you for your help. But can you tell me how to do it?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [20 March 2020 16:06 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/19 "2020-03-20T16:06:53Z")

</div>

click the button to add a new rule then click on the condition (the ==) and scroll to the bottom

---

<div class="post-metadata">

**Author:** ![pedroware](https://avatars.discourse-cdn.com/v4/letter/p/e8c25b/32.png) [@pedroware](https://discourse.nodered.org/u/pedroware)\
**Post date:** [20 March 2020 18:39 UTC](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218/20 "2020-03-20T18:39:38Z")

</div>

Solved successfully. Thanks to all

[Next page](https://discourse.nodered.org/t/esp-tasmota-ir-sensor/23218.md?page=2)
