Unable to update text field on just one session using msg.socketid

I thought I should be able to update a text or text input field in just one of the connected sessions by including msg.socketid but I cannot get it to work.

I am using a ui_control node to detect the opening of a dashboard tab and then passing that message on to the text nodes after adding a timestamp to msg.payload. I had expected that to only update the tab on the device that has just opened the tab, but I see that all connected devices receive the new timestamp. Should this flow operate as I expected or am I incorrect?

[{"id":"1821b1188180a4c6","type":"ui_ui_control","z":"bdd7be38.d3b55","name":"","events":"all","x":140,"y":3100,"wires":[["50f33ee13411047e"]]},{"id":"cf55096d8fbff95b","type":"ui_text","z":"bdd7be38.d3b55","group":"903a6ab8.4f4ca8","order":3,"width":0,"height":0,"name":"","label":"ui_text","format":"{{msg.payload}}","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":730,"y":3080,"wires":[]},{"id":"bc151026b9db7aca","type":"function","z":"bdd7be38.d3b55","name":"Add timestamp","func":"msg.payload = new Date().toISOString()\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":3100,"wires":[["cf55096d8fbff95b","ab3b4ae211852e81"]]},{"id":"ab3b4ae211852e81","type":"ui_text_input","z":"bdd7be38.d3b55","name":"","label":"ui_text_input","tooltip":"","group":"903a6ab8.4f4ca8","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":300,"topic":"topic","sendOnBlur":true,"className":"","topicType":"msg","x":730,"y":3140,"wires":[[]]},{"id":"50f33ee13411047e","type":"switch","z":"bdd7be38.d3b55","name":"Home?","property":"name","propertyType":"msg","rules":[{"t":"eq","v":"Home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":300,"y":3100,"wires":[["5d460a612a21cdcd","bc151026b9db7aca"]]},{"id":"5d460a612a21cdcd","type":"debug","z":"bdd7be38.d3b55","name":"debug 116","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":470,"y":3040,"wires":[]},{"id":"903a6ab8.4f4ca8","type":"ui_group","name":"Home","tab":"e2e6f4f5.56f91","order":1,"disp":false,"width":"6","collapse":false,"className":""},{"id":"e2e6f4f5.56f91","type":"ui_tab","name":"Home","icon":"dashboard","order":3,"disabled":false,"hidden":false}]

You are incorrect. There is only one source of truth. We can’t have indicators saying the power is off when it may be on.

Ok, it was posts like this that led me astray I think.

I am not sure it is a well defined a question as that. If the developer decided he wanted to affect only the current tab when a button is clicked, for example, there is no reason why that should not be allowed. However, if that is the way it is then that is ok. I don't actually need to do this, I was just exploring the capability with a view to the design of Dashboard 2.0.

So is it just notifications, navigation and show/hide that are affected by the socketid?

At the end of the day. Until you have separate user login sessions then there can only ever be one state of a widget held in a flow. Of course the browser client can hold it own state, but then who do you trust? That is a design decision, and we (I) chose to stick with the server being the source of truth.

1 Like

OK, thanks.

The text-box node is global. whatever value it receives will show on all sessions.

You have the option to use a ui-template node and define a session-specific text box in HTML.
Messages which include a session indicator (msg.socketid), will only be received by the text box of same current session.

In case the message comes without a session indicator (e.g. comes from a non-dashboard node), you can mimic this behavior, using a hidden HTML field, initialized with a unique UUID.

I have a working example of this, in case you are interested.

1 Like

OK, thanks, as I said, I don't need to do this, I was just clarifying my understanding of how the current dashboard works.

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