There is a tuya-local-socket node in the flow that connects to the tuya lamp, but sometimes node loses connection and if i restart the flow (turn off and on the tuya node, deploy), it finds the lamp again. How to send a request to restart a node or flow using the API? I tried to compose a request to restart flow in a function node and send it via an http request node:
msg.url = "http://localhost:1880/flow/:id";
msg.method = "PUT";
msg.payload = {
"id": "b2d3b44817b68364",
"label": "Flow 1",
"nodes": ,
"configs":
};
return msg;
and receive a response in the console:
"{"code":"not_found","message":"Error"}"
Help me, please, how to make a request to restart the flow (or node)?
It would be helpful it you provided the actual name of the tuya node you are using. A quick search of the flow library shows there are 11 nodes with 'tuya' in the name.
also the version of node-red and node.js (see the startup log)
According to the NR API description [PUT /flow/:id : Node-RED], it is possible to update a individual flow configuration (restart?), regardless of which nodes exist in it. This is what I would like to do - restart flow by id.
(tuya node does not have a reset command)
I changed ":id" to the identifier of a specific flow. I run the PUT method:
msg.url = "http://localhost:1880/flow/b2d3b44817b68364";
msg.method = "PUT";
a pop-up window informs about changes to the stream on the server and offers to merge. If i select merge, all nodes are deleted from the flow.
There is no api for restarting an individual flow.
The PUT /flow/<id> endpoint can be used to update an existing flow - which will have the result of restarting it. But you have to provide the flow configuration as the body of the PUT request. If you don't send anything, then you are wiping it out and it will remove the nodes.
Yes, that's how it works. First, I got the flow configuration (GET), wrote it to a variable (flow.set), then read it from the variable (flow.get), changed some value and sent an update (PUT). Flow reload, the nodes have been initialized again. Thank you.