I have a Sonos system that I've created a dashboard for. Primarily, the dashboard will contain a bunch of tiles that represent different music presets. Referring to the screenshot, I have virtual switches that represent each station preset and a transparent PNG image set as the background. This allows the "ON" background color to identify which preset is playing.
In my example here, if I were to select "Cool Oldies" then it would become selected (ON) and "The Pulse" would change to deselected (OFF).
The way I'm doing it now is by configuring each rule (one per preset) to turn off all the other stations by selected each switch except for the one I'm playing. While this works, if I add another station preset later, I have to modify all of the rules!
I'm trying to see if there's a better way at controlling the logic for the switches though - meaning only one can ever be ON and all others OFF.
Use a button controller with 12 buttons. In the Samsung Multiroom Integration, the buttons for preset channels are embedded in the code for convenience which means no additional devices to implement the capability.
Yeah, I did this with another dashboard for another room and it's very clean. But - the switch (button) itself doesn't change status so it's not quite as easy to see which one is pressed.
Alright, gonna try this again (I posted a Rule I thought would work, but resulted in an infinite loop so I deleted the post). This is a tough one. I made what you want to happen take place in one rule. Not sure if that will help much since adding a new tile still results in a bit of updating to the rule.
As you can see I have three virtual switches (named Bob Marley, Bob Dylan, Bobby Brown) and any of them turning on triggers the rule. First thing that happens is a GV (I named Music Tile) is set to the name of the device that triggered the rule, the next thing that happens is all the switches turn off (except for the one you just turned on) But there is a little work to do when you add a new switch:
add the new switch as a trigger
add a new Else-IF line referencing the possibility the GV was set to the name of your new switch.
updated each of the lists of switches that turn off.
Maybe someone smarter than me will have a better solution, looking forward to seeing if there is one. I imagine you could also write the rule above without using GV, and just reference the switches, but in this case I like the use of GV. Having this GV could come in useful in other circumstances and Bruce has stated that GV don't really add any overhead and to feel free to add as many as you want.
On another note I do a similar thing with my squeezebox integration
When you add a tile simply add a new trigger to the rule and add one more Else-IF statement.
Once you make the rule, it will take a few presses to get it working. The only issue you may have is if you press the same tile twice it will not go back on till you hit another tile.
Alright, Sorry for so many posts. But I finally figured it completely out, works 100% and you can even press the same tile repeatedly. Simply need to create 2 Global Variables
When you need to add another tile simply add the switch as one of the triggers and add one more Else-IF statement written in a similar fashion to the ones shown. I made a dashboard with these three tiles and tested. Works great.
Thanks for the logic problem, when I first got my Hubitat, rule machine was a little scary, I had no previous experience with computer programming or logic statements, but I think I am finally getting the hang of it. LOL
It's currently 10:50pm where I live and I have to stay up till midnight to pick my wife up from her shift at the hospital (microbiology lab). It was nice to work on this problem, killed a lot of time. Thanks.
Possibly an attribute tile with track description would allow the currently playing. Part of that is what you have queued and whether it provides feedback on the naming. I am not familiar enough with the Sonos driver.
This is a great idea! You inspired me to do similar but used Node Red for logic. I don't know if I did it the most efficient way so that only 1 switch is on but it works.