SK
Signal K•4d ago
Claeszv

Hello

I am in my first days of playing around in SignalK, so please bare over with my stupid questions. Also Discord is at bit confusing 😉 I have quite a lot experiense with home assiastant and node-red, but I am NOT a programmer. I can do simple coding with help from ChatGPT. I want to be able to control all switches and dimmers on my boat from #wilhelmsk also I am working on switching and light control using node-red but I have af few problems as follows: - How can I request the path-value of eg "electric.switching.state" from signalK server in Node-Red on demand? - When server is restartet I have to send-path data to SignalK to be able to operate switches in WilhelmSK otherwise switches are inactive and WilhelSK crashes. Do I just make an Node-Red automation, that resends path-data every xx seconds or is there a smarter way?
Thx in advance
13 Replies
Scott Bender
Scott Bender•4d ago
So yeah, use an inject node to send the current switch state periodically WilhelmSK crashes? There is a function in this example that calls “app.getSelfPath”
Scott Bender
Scott Bender•4d ago
You can see other examples in Discussions here https://github.com/SignalK/signalk-node-red
GitHub
GitHub - SignalK/signalk-node-red: Node server plugin that embeds n...
Node server plugin that embeds node red. Contribute to SignalK/signalk-node-red development by creating an account on GitHub.
Claeszv
ClaeszvOP•4d ago
Hi Scott and thx for your reply. I have looked into the links you sent and imported the flows also. I can see that you are using a global to store data from your flows and repeatedly syncronise the data. Is this the way to do it? I mean instead of picking the data from signalK server? I have tried to get the "appGetPath" working but without succes. And yes WilhelmSk crashes when I press the button "switch W/Led" and theres no data/Path in signalK. ex. when rebooting. besides that WilhelmSK is absolutely amazing.
Scott Bender
Scott Bender•4d ago
Oh. Ok I didn’t not check the LED switch… That use of global var is a pretty specific use. That var is used by other flows in my system. Basically to turn them on and off. Your use case is probably different Can you post your flow with app.getSelfPath
Claeszv
ClaeszvOP•4d ago
Yea, when it comes to control lights with multiple switches, I prefer to only have one place to store data I just deleted it. Cleaning up in too many expermental flows LOL Here it is: [{"id":"e1a781cb2cf322e2","type":"inject","z":"0794d9b554a615d1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":140,"wires":[["c1f41b35ab7a4e77"]]},{"id":"c1f41b35ab7a4e77","type":"function","z":"0794d9b554a615d1","name":"function 5","func":"// Define Signal K server URL og endpoint\nlet signalKServerURL = "http://localhost/signalk/v3/api\"; // Opdater med din Signal K servers URL\nlet endpoint = "/vessels"; // Du kan Ìndre dette endpoint baseret pü den ønskede data (f.eks. "/vessels/self" for en specifik büd)\n\n// SammensÌt den komplette URL\nlet url = signalKServerURL + endpoint;\n\n// Konfigurer HTTP GET-anmodningen\nmsg.url = url;\nmsg.method = "GET";\nmsg.payload = null; // For at undgü unødvendige data i payload\n\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":140,"wires":[["6b39d1a92570c2fa"]]},{"id":"6b39d1a92570c2fa","type":"http request","z":"0794d9b554a615d1","name":"","method":"use","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":590,"y":140,"wires":[["3229398bb35d4202"]]},{"id":"3229398bb35d4202","type":"debug","z":"0794d9b554a615d1","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":140,"wires":[]}]
Scott Bender
Scott Bender•4d ago
Hard to tell what’s going on there… Looks like you are using http get?
Claeszv
ClaeszvOP•4d ago
Yep. And it dosn't work 🙂
Scott Bender
Scott Bender•4d ago
Use app.getSelfPath Example above
Claeszv
ClaeszvOP•4d ago
which one of them? I have searched all of the links you sent earlier, but I couldnt find anything about app.getSelfPath
Scott Bender
Scott Bender•4d ago
It’s in a function in the switch automation example
Claeszv
ClaeszvOP•4d ago
Ok Thanks. I will look there Got it!! Million thanks
Want results from more Discord servers?
Add your server