This has been my hobby project for a few months now and I have had some successes but I still need help.
Here is my goal
When the bathroom light is turned on (the trigger) the following will happen on the Sonos Play3 in the bathroom.
If it is after dusk and before dawn play a radio station of nightime sounds (crickets) and the script will stop.
If it is not after dusk and before dawn:
If the master bedroom player is playing, then link to it and the script will stop.
Otherwise
If the kitchen player is playing, then link to it and the script will stop.
Otherwise
Play a radio station and the script will stop.
What is working?
I am able to check the other players and see if they are playing
What is not working?
So far I am unable to link players with a script and I'm not able to play music with a script.
I've been working on this for a few months as a hobby and I love doing it and the Sonos plugin is my favorite. Dirk has really done an amazing job with this.
Here is my code so far:
Here is my goal
When the bathroom light is turned on (the trigger) the following will happen on the Sonos Play3 in the bathroom.
If it is after dusk and before dawn play a radio station of nightime sounds (crickets) and the script will stop.
If it is not after dusk and before dawn:
If the master bedroom player is playing, then link to it and the script will stop.
Otherwise
If the kitchen player is playing, then link to it and the script will stop.
Otherwise
Play a radio station and the script will stop.
What is working?
I am able to check the other players and see if they are playing
What is not working?
So far I am unable to link players with a script and I'm not able to play music with a script.
I've been working on this for a few months as a hobby and I love doing it and the Sonos plugin is my favorite. Dirk has really done an amazing job with this.
Here is my code so far:
Code:
Public Sub BathroomMusic (ByVal params As String) hs.writelog("BathroomMusic","Event has started") '*** if it is night play crickets *** if isnighttime then hs.writelog("BathroomMusic","It is nighttime") '*** code here to play crickets radio station *** else '*** not night time, if the bedroom is playing link to it *** hs.writelog("BathroomMusic","It is not nighttime") if hs.DeviceValueByName("Sonos Master Bedroom State") = 1 then hs.writelog("BathroomMusic","Master Bedroom is playing") '*** code here to link to bedroom player *** else '*** if the kitchen is playing link to it *** hs.writelog("BathroomMusic","Master Bedroom is not playing") if hs.DeviceValueByName("Sonos Kitchen State") = 1 then hs.writelog("BathroomMusic","Kitchen is playing") '*** code here to link to kitchen player *** else '*** play station *** hs.writelog("BathroomMusic","Kitchen is not playing") '*** code here to play rock station *** end if end if end if End Sub
Comment