Create dynamic groups through UI

Hi, I can't seem to grasp how I should go about doing what I need: I have 24 relays. I can toggle them individually using UI buttons, and obviously, I can trigger a group of relays with a UI button as well. But what I'm trying to do is to allow the user to select which relay trigger in what group. A dynamic assignement for each relay. I can't seem to wrap my head around the right way to do it ?
If I want to assign any relay (1 to 24) to groups A, B, C or D (and store said assignment), should I create 24 dropdowns buttons to assign the group, have that assignment create a group topic and use that to create a button to call on that group ? How can I store the assignment to make it resilient ?

To be clear on the desired outcome, an example of user selection would look like :
1,2,4, 6, 9 to Group A,
3,5,7,8 to Group B,
10, 11,12 to Group C,
13, 14,15,17,20 to Group D
and 16,18,19 unassigned.

In the dashboard, UI toggles "Group A", "Group B", etc would toggle relays on/off assigned to that group.
User could change assignments at will.

Suggestions are appreciated to push me in the (a) proper direction, seems to me that I'm the one making it complicated :slight_smile:

What about a page (call it relay to Group Assignment) with all 24 relays listed - assign a MultiState Switch UI to each one to enable the user to set the group for each button/relay - store the output of these into a context object (flow or Global and make sure this is backed by storage not just memory)

So the object would look like - RelayGroupAssignment.GroupA.Members and you could then have an array of relays in that group etc.

Read that when you start up and prepopulate the Settings page each time so everyone knows which groups the relays are members of

Then you have a 2nd UI page that allows you to turn individual relays on/off or whole groups on/off


1 Like

Yes, excellent. I did search for something like the MultiState Switch UI but didn't find it. That does present the UI in the right fashion, and the method you highlight works for me. Thanks, I needed that nudge :slight_smile:

1 Like

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