Send a http request to the client using the switch/clicking the button

Hi everyone,
unfortunatelly I could not find the solution to this via the search and I am too much of a newbie to adjust solutions that might go the same direction.

I use Fully Kiosk Browser to display my dashboard on 3 tablets throughout the building.
I have a switch, that makes all of these devices switch focus to an other tab and back after 30 secounds, using the api and a http requests.
I'd like to limit this to the device where tho switch node is used, so I need that ip.

Anybody got an idea,
I'd really appreciate it.

Thanks.

My understanding is, if you send the socketid form the switch node that is pressed in the http request and feed into the ui-control node to change tab, it should only affect the browser that the socketid matches.

Or if the other way round as I am unsure, as your question is fairly vague.

msg.req.ip from the http in node should contain the ip address

Maybe I did not make it clear:
I want to change the tab in my browser to another site then my dashboard, not change the tab within my dashboard.

No maybe, you were definitely not clear.

You will need to show your flow and describe how it works, then we can maybe guide you how to separate the browsers (which?).

This is one of my flows.

[{"id":"e9a3883af6280054","type":"ui_switch","z":"b7f921f1.342a2","name":"Note","label":"","tooltip":"","group":"66cd75f9.a20fcc","order":4,"width":1,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"Switches","onvalueType":"str","onicon":"fa-music fa-lg","oncolor":"white","offvalue":"Switches","offvalueType":"str","officon":"fa-music fa-lg","offcolor":"white","animate":false,"className":"","x":110,"y":2800,"wires":[["a9f100666edd7802","e62dc641d32d9db9","a820445d0a649018"]]},{"id":"a9f100666edd7802","type":"http request","z":"b7f921f1.342a2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.102.42:2323/?cmd=focusTab&tab=1&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":270,"y":2800,"wires":[[]]},{"id":"e62dc641d32d9db9","type":"delay","z":"b7f921f1.342a2","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":260,"y":2880,"wires":[["5ebefae7b2274da9","a9956fa5dbb28b37"]]},{"id":"5ebefae7b2274da9","type":"http request","z":"b7f921f1.342a2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.102.42:2323/?cmd=focusTab&tab=0&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":470,"y":2800,"wires":[[]]},{"id":"a820445d0a649018","type":"http request","z":"b7f921f1.342a2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.102.41:2323/?cmd=focusTab&tab=1&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":270,"y":2840,"wires":[[]]},{"id":"a9956fa5dbb28b37","type":"http request","z":"b7f921f1.342a2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.102.41:2323/?cmd=focusTab&tab=0&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":470,"y":2840,"wires":[[]]},{"id":"66cd75f9.a20fcc","type":"ui_group","name":"Timer","tab":"ee5eca78.025538","order":3,"disp":false,"width":"14","collapse":false},{"id":"ee5eca78.025538","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

So if you only want the switch to send http request to the one tablet, why not only have one set of http request connected to the switch?

I will think up example for you.

I want to send the http request to the tablet the switch was used on, that's why I want to know its ip.

Yes, as I said in my first post you can use socketid, you can log connections and store ip and log disconnects and delete ip. Then use socketid from theswitch press to retreive the ip for that socketid.
Here is an example

[{"id":"a4b1e29f7c271f6d","type":"ui_button","z":"bf569dbfc3bc07ed","name":"","group":"4f791fdc1745d3d9","order":2,"width":0,"height":0,"passthru":false,"label":"change tab","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"str","topic":"topic","topicType":"msg","x":170,"y":420,"wires":[["be0171059739e39f"]]},{"id":"be0171059739e39f","type":"change","z":"bf569dbfc3bc07ed","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"tablet[msg.socketid]","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":420,"wires":[["334e40257f0383bf","a9f100666edd7802","e62dc641d32d9db9"]]},{"id":"334e40257f0383bf","type":"debug","z":"bf569dbfc3bc07ed","name":"debug 345","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":210,"y":500,"wires":[]},{"id":"a9f100666edd7802","type":"http request","z":"bf569dbfc3bc07ed","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{msg.ip}}}:2323/?cmd=focusTab&tab=1&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{},"x":550,"y":420,"wires":[[]]},{"id":"e62dc641d32d9db9","type":"delay","z":"bf569dbfc3bc07ed","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":460,"y":480,"wires":[["5ebefae7b2274da9"]]},{"id":"be5f448dd16a1f9a","type":"switch","z":"bf569dbfc3bc07ed","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connect","vt":"str"},{"t":"eq","v":"lost","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":580,"wires":[["c3432231a008d11f"],["375b2fa07990ccbe","334e40257f0383bf"]]},{"id":"5ebefae7b2274da9","type":"http request","z":"bf569dbfc3bc07ed","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{msg.ip}}}.42:2323/?cmd=focusTab&tab=0&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{},"x":630,"y":480,"wires":[[]]},{"id":"b202c61e3480c3ae","type":"ui_ui_control","z":"bf569dbfc3bc07ed","name":"","events":"all","x":160,"y":580,"wires":[["be5f448dd16a1f9a"]]},{"id":"c3432231a008d11f","type":"change","z":"bf569dbfc3bc07ed","name":"","rules":[{"t":"set","p":"tablet[msg.socketid]","pt":"flow","to":"socketip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":560,"wires":[[]]},{"id":"375b2fa07990ccbe","type":"change","z":"bf569dbfc3bc07ed","name":"","rules":[{"t":"delete","p":"tablet[msg.socketid]","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":600,"wires":[[]]},{"id":"4f791fdc1745d3d9","type":"ui_group","name":"micro","tab":"c954274bbed7292e","order":1,"disp":false,"width":"18","collapse":false,"className":""},{"id":"c954274bbed7292e","type":"ui_tab","name":"Solar","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I guess I can adopt this to work for me.
I think I get the basics,
so thanks a lot :slight_smile:

When do we sign the adoption papers, I am eager to rid my self of another freeloader, taking up vital memory.

[edit]
And here is the other suggestion from my first post, using a http-in node to get ip.

[{"id":"c17277d02cae2d74","type":"http in","z":"bf569dbfc3bc07ed","name":"","url":"/ip","method":"get","upload":false,"swaggerDoc":"","x":70,"y":360,"wires":[["a2094a225ef815d0","be0171059739e39f"]]},{"id":"a2094a225ef815d0","type":"http response","z":"bf569dbfc3bc07ed","name":"","statusCode":"","headers":{},"x":70,"y":400,"wires":[]},{"id":"be0171059739e39f","type":"change","z":"bf569dbfc3bc07ed","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"req.ip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":360,"wires":[["334e40257f0383bf","a9f100666edd7802","e62dc641d32d9db9"]]},{"id":"334e40257f0383bf","type":"debug","z":"bf569dbfc3bc07ed","name":"debug 345","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":250,"y":440,"wires":[]},{"id":"a9f100666edd7802","type":"http request","z":"bf569dbfc3bc07ed","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{msg.ip}}}:2323/?cmd=focusTab&tab=1&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":570,"y":360,"wires":[[]]},{"id":"e62dc641d32d9db9","type":"delay","z":"bf569dbfc3bc07ed","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":440,"y":420,"wires":[["5ebefae7b2274da9"]]},{"id":"5ebefae7b2274da9","type":"http request","z":"bf569dbfc3bc07ed","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://{{{msg.ip}}}.42:2323/?cmd=focusTab&tab=0&password=PASSWORD","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":610,"y":420,"wires":[[]]},{"id":"a4b1e29f7c271f6d","type":"ui_button","z":"bf569dbfc3bc07ed","name":"","group":"4f791fdc1745d3d9","order":2,"width":0,"height":0,"passthru":false,"label":"change tab","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"1","payloadType":"str","topic":"topic","topicType":"msg","x":150,"y":320,"wires":[["a3ebf87a7887b528"]]},{"id":"a3ebf87a7887b528","type":"http request","z":"bf569dbfc3bc07ed","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.10:1880/ip","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":310,"y":320,"wires":[[]]},{"id":"4f791fdc1745d3d9","type":"ui_group","name":"micro","tab":"c954274bbed7292e","order":1,"disp":false,"width":"18","collapse":false,"className":""},{"id":"c954274bbed7292e","type":"ui_tab","name":"Solar","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

This one is not up for adoption, but you may adapt it.
P.s It does not work anyway as the http request would just return the ip of node-red server in the http in node.

Actually, I didn't like your tone in your first post, but I thought "s/he might be condecending, but I need help, so I'll be nice".
Maybe you guessed by now, I'm not a native speaker, so if you want to make fun about adoption/adaptation, we can continue this in a different language....
How 'bout German?

Und um unmissverständlich klar zu machen, dass du besser programmierst als ich, der sich explizit als "Newbie" vorgestellt hat musstest du noch eine Variante posten.
Aber weißt du was, deine erste Lösung hat schon nicht "out-of-the-box" funktioniert,
deshalb werde ich die zweite gar nicht erst nicht testen
Nachdem ich die msg.url in einer Function Node zusammengesetzt habe geht es,
vielleicht hast du die Url falsch escaped.

Versteh' mich nicht falsch,
ich bin dir für deinen Lösungsansatz sehr dankbar,
aber deinen Ton kann ich nicht gutheißen.
Bitte hilf mir nie wieder.
Lieber trage ich ein Problem bis zum Sankt Nimmerleinstag mit mir herum,
als in der Schuld einer Person zu stehen, die sich so herablassend verhält.

If you have a similar problem, this worked for me:

[{"id":"be5f448dd16a1f9a","type":"switch","z":"07d4ed6d128d4b8f","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"connect","vt":"str"},{"t":"eq","v":"lost","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":160,"wires":[["c3432231a008d11f"],["375b2fa07990ccbe"]]},{"id":"b202c61e3480c3ae","type":"ui_ui_control","z":"07d4ed6d128d4b8f","name":"","events":"all","x":160,"y":160,"wires":[["be5f448dd16a1f9a"]]},{"id":"c3432231a008d11f","type":"change","z":"07d4ed6d128d4b8f","name":"","rules":[{"t":"set","p":"tablet[msg.socketid]","pt":"flow","to":"socketip","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":140,"wires":[[]]},{"id":"375b2fa07990ccbe","type":"change","z":"07d4ed6d128d4b8f","name":"","rules":[{"t":"delete","p":"tablet[msg.socketid]","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":180,"wires":[[]]},{"id":"e89e664b7ab3b623","type":"change","z":"07d4ed6d128d4b8f","name":"","rules":[{"t":"set","p":"ip","pt":"msg","to":"tablet[msg.socketid]","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":260,"wires":[["191375e2f58ef5b5"]]},{"id":"e0ad691f905fa6c2","type":"http request","z":"07d4ed6d128d4b8f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":990,"y":280,"wires":[[]]},{"id":"8d4952f17295e6ed","type":"delay","z":"07d4ed6d128d4b8f","name":"30s","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":730,"y":320,"wires":[["d564a50fb921bc39"]]},{"id":"e9a3883af6280054","type":"ui_switch","z":"07d4ed6d128d4b8f","name":"Note","label":"","tooltip":"","group":"66cd75f9.a20fcc","order":4,"width":1,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"1","onvalueType":"str","onicon":"fa-music fa-lg","oncolor":"white","offvalue":"1","offvalueType":"str","officon":"fa-music fa-lg","offcolor":"white","animate":false,"className":"","x":150,"y":260,"wires":[["e89e664b7ab3b623"]]},{"id":"2c7d16ba5a4a37f9","type":"ui_switch","z":"07d4ed6d128d4b8f","name":"Headphone","label":"","tooltip":"","group":"66cd75f9.a20fcc","order":5,"width":1,"height":1,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"2","onvalueType":"str","onicon":"fa-headphones fa-lg","oncolor":"white","offvalue":"2","offvalueType":"str","officon":"fa-headphones fa-lg","offcolor":"white","animate":false,"className":"","x":170,"y":320,"wires":[["e89e664b7ab3b623"]]},{"id":"bc7b7a9b9e2da8cb","type":"function","z":"07d4ed6d128d4b8f","name":"set url","func":"msg.url = \"http://\"+msg.ip+\":2323/?cmd=focusTab&tab=\"+msg.payload+\"&password=PASSWORD\"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":260,"wires":[["e0ad691f905fa6c2"]]},{"id":"d564a50fb921bc39","type":"function","z":"07d4ed6d128d4b8f","name":"set url","func":"msg.url = \"http://\"+msg.ip+\":2323/?cmd=focusTab&tab=0&password=PASSWORD\"\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":320,"wires":[["e0ad691f905fa6c2"]]},{"id":"191375e2f58ef5b5","type":"function","z":"07d4ed6d128d4b8f","name":"filter ip","func":"if (msg.ip === \"192.168.102.39\") return msg;\nif (msg.ip === \"192.168.102.40\") return msg;\nif (msg.ip === \"192.168.102.41\") return msg;\nif (msg.ip === \"192.168.102.42\") return msg;\n\nreturn null;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":260,"wires":[["bc7b7a9b9e2da8cb","8d4952f17295e6ed"]]},{"id":"66cd75f9.a20fcc","type":"ui_group","name":"Timer","tab":"ee5eca78.025538","order":3,"disp":false,"width":"14","collapse":false},{"id":"ee5eca78.025538","type":"ui_tab","name":"Dashboard","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Glad you adapted my example, as it was an example. And the final solution. You clearly used the socketid and my idea to log and delete ip and the idea to retreive the ip. Could not test request nodes as I had no access to the api. The error in the http request nodes is , I should of used {{{ip}}} not {{{msg.ip}}}. So my flow example would have worked as is except a simple typo.

What tone are you talking about from my first post, the only thing I can think, did me calling your post fairly vague upset you?, It was vague and misleading, with little clear information, not even an example.

Should I bother responding to you in future? as you clearly are upset by my tone, not that meant to upset you, apology if I did I did not mean any offense.

My remark about adopt was also a joke, now I know you are German I will refrain from joking. Damn there i go joking again.

[edit] I posted a second variant not to belittle but to teach, You should of taken my first post and experimented to see if the ideas had any merit, instead you dismissed them.

Translation form previous post

And to make it unmistakably clear that you program better than me, who explicitly introduced himself as a "newbie", you had to post another variant. But you know what, your first solution didn't work "out-of-the-box", That's why I'm not going to test the second one in the first place After I have assembled the msg.url in a function node it goes, maybe you escaped the url incorrectly. Don't get me wrong, I am very grateful to you for your approach, but I don't approve of your tone. Please don't ever help me again. I'd rather carry a problem around with me until the end of the day, than to be indebted to a person who behaves in such a condescending manner.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.