Question about tcp connection status and inject node during dashboard start

I have two questions regarding tcp request node, please.

  1. How can I detect if a tcp connection is established or not in dashboard? I connect and disconnect manually. Additionally , I can send commands to the server via dashboard buttons. I would would like to prevent sending commands if the client is disconnected.
    Also I would like to indicate connection status with green or red button.

  2. It seems that a inject node that injects something single time after a second, does not
    work as expected if dashboard has been started. It works in editor, manually injected.
    The intention is to setup dashboard switches to off, for the case they are on and to disconnect tcp during dashboard start in any case.

What do you mean by 'dashboard'? Do you mean node-red-dashboard, @flowfuse/node-red-dashboard, or are you talking about the node-red editor?

Also when you say you want to detect if the connection is established in dashboard, do you actually mean in a node-red flow?

Which client are you talking about?

I mean the node-red dashboard, of cause.

This is the client I currently mean:

You could attach the status node to the tcp node to obtain changes in connection status but that feels a little like a hack

[{"id":"8711b5c3da75af56","type":"tcp request","z":"99338e433530145b","name":"","server":"","port":"","out":"time","ret":"buffer","splitc":"0","newline":"","trim":false,"tls":"","x":1341.655517578125,"y":480.84393310546875,"wires":[[]]},{"id":"1b71b2eb07490f38","type":"status","z":"99338e433530145b","name":"","scope":["8711b5c3da75af56"],"x":1292.811149597168,"y":566.5888996124268,"wires":[["50d6656fb21967f9"]]},{"id":"50d6656fb21967f9","type":"debug","z":"99338e433530145b","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1489.519775390625,"y":569.951416015625,"wires":[]}]

the output of the status node would then be sent to the dashboard.

Use the cron-plus node for all things to do with regular job triggering. inject node will only inject once the flow is restart.

Generally you have to update the dashboard manually meaning you send the corresponding dashboard nodes messages via the flows you design in the editor.

To be pedantic the ui-switch that you show is from @flowfuse/node-red-dashboard, not node-red-dashboard.

There are multiple clients there, the browser running the node-red editor, the client running the dashboard, showing the switch, and node-red itself which is a client of the tcp connection. I am guessing that you mean when there is no browser open looking at the dashboard. Is that correct? If so then that is not easy.

I'm sorry if I not precise enough. But I'm still beginner and I do not look behind the
capabilities and the terminology yet.

I mean , if I run the flow either starting from node-red-editor or directly via the link (without editor).

It could be that either the flow in dashboard is terminated without disconnect or the server is suddenly not available anymore or the server is not running. During the next new start of the flow there is no synchronization between the client in dashboard and the server. That is what I would like to prevent.
Hopefully you understand what I mean.

Thanks for help.

Not fully. Do you mean that when node red is started the switch in the dashboard may not show the correct connected state?

Is so then use a Status node as suggested earlier and use that to set the switch position.

On this question, I don't understand what you mean by 'if dashboard has been started'. The flow image that you posted should certainly set the switch to Off when node-red is restarted, which is when the inject will fire.

Can you explain how you, as a user of the system, not via the editor, connect and disconnect TCP?

Node-red runs on a computer of some sort. You can access the editor and/or the dashboard via a browser, which need not be on the same computer.

Please give us a bit of info on your setup.

What is at the far end of the TCP connection? Are you turning something on and off?

First , thank you both for trying to help.

I think it'll be the best to provide a simple example how I use the tcp request node.
However , I currently run out of time and I can only provide this example end of next week.

In advance, my project is to receive data from an external weather station which
deliver a set of information any second. I manually connect and disconnect to the server. To be able to control the server in the weather station , I can simultaneously send different commands. For example to select different sets of information or select the raw data of the different sensors.

I'm going to provide just the tcp part of that project, so you can see what I'm doing
at the input side of the tcp request node.
Again, I'm a newcomer with node-red and I possible do something more complicated as experts would do.

It might help us to advise if you can share the make and model of the weather station, or if it is a public station with a website, the URL.

The weather station is a commercial unit without web capability, it just delivers a data stream of results of the different sensors. I already designed a simple server using PlatformIO for a ESP8266 device. The ESP receives the data from the sensor unit and translates it to visible values. The server also handles the tcp connection and the selection of the different data formats. Nothing special.

I and many others use MQTT to exchange data between ESPs and Node-red.
Not saying that's better than your TCP arrangement, it's just the protocol I prefer.

Yes, could be better. However, I did some other projects with tcp arrangement before
and I'm quite familiar with it. So I currently prefer this solution.

Tanks for your friendly support.
I have to leave.