I think this problem still exists as of 2.5.
My current solution is as follows:
- I created multiple audiogroup things, one for each member of the audiogroup
- I created rules to keep track of which one is online, then update a virtual item to save the name of the active one
- Use that virtual item in say/play
Thing chromecast:audiogroup:gh_all_1 "All Google Home 1" [ ipAddress="192.168.1.1", port=42351 ]
Thing chromecast:audiogroup:gh_all_2 "All Google Home 2" [ ipAddress="192.168.1.2", port=42351 ]
Thing chromecast:audiogroup:gh_all_3 "All Google Home 3" [ ipAddress="192.168.1.3", port=42351 ]
Thing chromecast:audiogroup:gh_all_4 "All Google Home 4" [ ipAddress="192.168.1.4", port=42351 ]
from core.rules import rule
from core.triggers import when
from core.actions import Things
@rule("Track Online Audiogroup", "Keep track of which audiogroup is online")
@when("Thing chromecast:audiogroup:gh_all_1 changed")
@when("Thing chromecast:audiogroup:gh_all_2 changed")
@when("Thing chromecast:audiogroup:gh_all_3 changed")
@when("Thing chromecast:audiogroup:gh_all_4 changed")
@when("System started")
@when("Time cron 0 */5 * * * ?")
def init_audiogroup(event):
# find the current active audiogroup
audiogroup = ''
for i in range(4):
chromecast_uid = "chromecast:audiogroup:gh_all_{}".format(i+1)
if Things.getThingStatusInfo(chromecast_uid).toString() == "ONLINE":
audiogroup = chromecast_uid
break
if audiogroup != items.Chromecast_Audiogroup.toString():
init_audiogroup.log.info("Audiogroup ONLINE: {}".format(audiogroup))
postUpdate("Chromecast_Audiogroup", audiogroup)
In rules that need to broadcast to audiogroup:
Audio.playSound(items.Chromecast_Audiogroup.toString(), "defaultdoorbell.mp3")
@cweitkamp, my suggestion would be to allow the audiogroup
thing to specify multiple ip addresses, and the binding can automatically pick whichever one that’s online. What do you think?
e.g.:
Thing chromecast:audiogroup:gh_all "All Google Home" [ ipAddress1="192.168.1.1", ipAddress2="192.168.1.2", ipAddress3="192.168.1.3", ipAddress4="192.168.1.4", port=42351 ]