Hey wonderful openHab users!
I had an idea for a rule and wonered if anyone could point me in the right direction.
Essentially I have 2 different music sources that I use in my house. I use sonos on my main floor, and use an amazon echo for the basement, and outside.
I have a tablet running habpanel on the main floor, and one in the basement.
My plan was to clone each dashboard, but switch the media controls to control to other music source.
I was wondering if it would be possible with a rule to switch dashboards depending on which device is playing audio.
This is my sudo code, and looking for feedback if this would be the best way to implement, or if there is a cleaner way, as I tend to over-engineer rules
Also not sure if there is a variable for media player of “is playing” rather than recived command “Play”
rule "set dashboard based on media player active upstairs"
when
Item SonosPlay1KitchenSpeakers_MediaControl received command
then
if( receivedCommand == "PLAY" ) {
activepanel.sendCommand(UpperMediaControl)
}
end
rule "set dashboard based on media player active basement"
when
Item BasementEcho_Player received command
then
if( receivedCommand == "PLAY" ) {
activepanel.sendCommand(LowerMediaControl)
}
if( receivedCommand == "PAUSE" ) {
activepanel.sendCommand(UpperMediaControl)
}
end
Lets me know if I am on the right track or not, or if I didnt explain that well enough please
Thanks all!