Dashboard 2.0 – One control set for multiple devices per user, without storage

Hi,

I'm using Node-RED Dashboard 2.0 to control four smart sockets. I want to use a single dropdown to select a socket, and then use one button (on/off) and one slider (brightness) to control the selected socket.

Each user should be able to select and control a socket independently using the same UI. The dropdown works per user (using socketid), but the problem is: you have to manually track the selected value per user, usually with flow.set() or similar. I want to avoid any kind of context storage, and also don’t want to manage socket IDs in arrays or objects manually.

What I’m wondering: is it possible to send a msg with a socketid to the dropdown and retrieve the currently selected value for that specific user? If so, I could avoid storing anything and still know what device the user wants to control.

Thank you in advance!

I don't use D2 myself so can't necessarily comment on the details of your question.

However, I do know about socketid and you should note that socketid is not stable. It is set to a new value if the users connection drops for any reason. That would include the users browser tab being suspended (either by the browser or the OS).

That is why UIBUILDER maintains several, more stable, ID's. Including a stable clientId which remains the same for all tabs of the open browser profile until the browser is restarted. Also a tabId (generated by the browser) and the IP address of the client.

Why do you not want to store anything in context?

Node-RED is generslly stateless in its flows. There is no "get" message that can be sent to a widget/node in order to return the current state

You can do that by creating the dropdown with Vuetify or pure HTML within a template node. then you can set/retrieve values to/from the dropdown based on its element Id.

1 Like