# Node-red catch not work with ewelink node-red control-device

**URL:** <https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663>\
**Category:** eWeLink CUBE\
**Tags:** node-red\
**Created:** [April 27, 2024, 8:17am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663 "2024-04-27T08:17:45Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 27, 2024, 8:17am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/1 "2024-04-27T08:17:45Z")

</div>

Why node-red catch not catch error from node-red ewelink control-device. Node-red complete not work to.  
Why?  
msg.payload.error is not error for catch?  
How can I do to catch this error?

---

<div class="post-metadata">

**Author:** ![SuiKa](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/suika/32/8656_2.png) [@SuiKa](https://forum.ewelink.cc/u/SuiKa)\
**Post date:** [April 28, 2024, 1:47am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/2 "2024-04-28T01:47:07Z")

</div>

What is your use case?  
Can I have some screenshot or configuration of your node?

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 28, 2024, 5:34am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/3 "2024-04-28T05:34:00Z")

</div>

install a test node “control-device” and catch its errors using the standard node “catch”. doesn’t catch.  
error 110006 is not caught.

---

<div class="post-metadata">

**Author:** ![SuiKa](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.ewelink.cc/suika/32/8656_2.png) [@SuiKa](https://forum.ewelink.cc/u/SuiKa)\
**Post date:** [April 28, 2024, 6:11am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/4 "2024-04-28T06:11:13Z")

</div>

110006 is an error code returned by api, not an internal error.  
It should not be thrown or catched.

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 28, 2024, 7:14am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/5 "2024-04-28T07:14:43Z")

</div>

Can you do in control-device chechbox “raise api error” to caught api error by catch?

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [April 28, 2024, 7:02pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/6 "2024-04-28T19:02:51Z")

</div>

Put a debug node after the device to see the string of characters created by an error. The error node is just to catch errors in Node Red itself. Then put a switch node after looking for that specific error and send yourself a notification using WhatsApp/telegram/pushover etc. I do something similar to catch all errors and try again with devices that are sometimes not available on wifi. You can add delays and counters to try again a certain number of times every 30s or so. It’s so simple I suspect the functionality could easily be added into the node itself.

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 28, 2024, 9:23pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/7 "2024-04-28T21:23:49Z")

</div>

Exactly as you described is what I do.  
But my error is part of the normal operation of the system.  
While running programs, another chain or someone else can turn off the power and all you need to do is catch the error and turn on the power for a while and restart the setup.  
But there are a lot of places where the error occurs and there are also a lot of connections with a restart as a result.  
The diagram looks ugly and unreadable.  
But if each control-device had a “raise API error” checkbox and possibly an error filter, then the scheme would become much simpler.

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [April 28, 2024, 10:39pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/8 "2024-04-28T22:39:59Z")

</div>

This is what I keep meaning to do to help with the mess:  
[https://nodered.org/docs/user-guide/editor/workspace/subflows](https://nodered.org/docs/user-guide/editor/workspace/subflows)

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 29, 2024, 2:26am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/9 "2024-04-29T02:26:30Z")

</div>

In my case this is not really necessary and does not greatly simplify the algorithm.  
Catch would be the most convenient and clearest in meaning.

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 29, 2024, 2:47pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/10 "2024-04-29T14:47:12Z")

</div>

Is it possible to do what I suggest?

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [April 29, 2024, 5:40pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/11 "2024-04-29T17:40:35Z")

</div>

Not easily no. You could find a badly coded node and then having it only fire if there is an eWelibk style error or look up how errors are fired within Node Red and then manually use the method with a function node. I would just put a repeatable eWeLink-error catching series of nodes in a sub-flow called “catch eWeLink error” and then use used the new Node you created.

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 29, 2024, 6:21pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/12 "2024-04-29T18:21:35Z")

</div>

Well, I don’t have poorly coded nodes, the power can simply be turned off and must be turned on if an error occurs.  
It’s not possible to put it into the subflow, there are too many branches.  
But the opportunity to not draw a bunch of branches, checks and connections would be great.  
Can I make a subflow like this so that the control device can do a raise error"?

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [April 29, 2024, 10:25pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/13 "2024-04-29T22:25:23Z")

</div>

Pretty sure creating a badly coded node would be easy to do. JavaScript isn’t a language I know so I’ve probably done it quite a lot.

Suspect a function node saying:

{node.error(“eWeLink Error”, msg)};  
rtn msg

or something like that would create an error that would be seen by the normal catch node. I’m probably using the curly brackets wrong.

My experience of sub-flows is that they are just a way to make things look nicer. Just bare in mind they only have 1 entrance, but can have multiple our. Limits what you can do with them.

---

<div class="post-metadata">

**Author:** ![telepin](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@telepin](https://forum.ewelink.cc/u/telepin)\
**Post date:** [April 30, 2024, 1:02am UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/14 "2024-04-30T01:02:48Z")

</div>

It turns out I need to pass different control-device calls to the subflow.  
And how to do it?

---

<div class="post-metadata">

**Author:** ![eerke](https://avatars.discourse-cdn.com/v4/letter/e/eb9ed0/32.png) [@eerke](https://forum.ewelink.cc/u/eerke)\
**Post date:** [April 30, 2024, 2:44pm UTC](https://forum.ewelink.cc/t/node-red-catch-not-work-with-ewelink-node-red-control-device/31663/15 "2024-04-30T14:44:32Z")

</div>

I don’t really know what you mean. If you mean you only need to pass some messages to your ai flow then a Switch Node. For example you could pass only errors to the subflow. If you actually want to change the contents of messages; eg copy from one bit of a message to another but then it is a Change Node.
