[Guide] Reactive Lutron Occupancy-based Room Sync
One of the cool things Dash Users have been doing with Lutron By Dash has been the idea of syncing sources based on the occupancy of that room. This can be used in a variety of different ways from simple Music Sync to video, audio, lighting, and anything else. The issue? This kind of logic took some know-how to accomplish and could be difficult to troubleshoot at times. While it wouldn't take long to get it done, it was still a lot of IF/ELSE Statements to create and maintain as the system grows and evolves and for a first-timer at attempting the concept it could be intimidating.
Per usual, Dash React to the rescue. We actually have a few ways we could accomplish this task. In order to determine the best route we need to consider what we want to accomplish.
In this guide we will be focusing on the Master Suite & Master Bathroom. Whenever we are using the Master Bedroom and walk into the Master Bathroom whatever source that is playing in the Master Bedroom should automatically follow us to the Master Bathroom for as long as we occupy it.
To take this to the next level, something React provides which was quite a bit more difficult (to the point I don't believe anyone ever bothered) is try "Room Syncing" so that should the source change in the Master Bedroom, the Master Bathroom will automatically follow suit.
We can go over tons of specifics on how this may need to function, but lets start with getting the basics down. Now while React appears intimidating at first glance, it is important to note here how much easier this type of functionality is to program within the React Infrastructure than the way we used to do this. What used to take many different macros and many Nested IF/Else Statements (which was also slow and redundant) can now be done with just a few simple commands.
The Desired Result
By the time we are done with the initial programming of this concept, we are expecting it to operate like so:
- When we walk into the Bathroom, if a Source is playing in the Bedroom it will automatically be turned on to match the source.
- Should the source be changed from one room, the other room should reflect the same change. At some point we may want to build some way of allowing this to change so the user could select Pandora, for example without interrupting the user in the Master Bedroom.
- When the Bathroom is no longer occupied, it should automatically unsync from the Bedroom and turn itself off.
To start, we will need to create Device Events for our Lutron Occupancy Sensors. These will allow us to generate macros that will be triggered whenever the Bathroom becomes Occupied or Unoccupied. This is simple enough to achieve with Lutron By Dash, below is a screenshot (I like to use the Serial Numbers rather than Integration ID's since the Serial Numbers never have a chance of changing).
We do the same for Unoccupied
Next we need to Get the Value of our Bedroom Variable. For the purposes of this guide, we are assuming you are setting up your Rooms & Sources using the Dash Method (either using standard URC String Variables or with Dash React). This makes it so we are aware of what is going on in the Master Bedroom.
Within our setup, we have setup React so that it is always tracking everything in our system. For Sources we use a format that looks like this:
While you could use any style you prefer, many dealers have adopted this method as it is readable and easy to work with.
Within our Bathroom Becomes Occupied Device Event Macro, the first thing we need to do is retrieve the current value of our "Bedroom" variable and save it into our matching URC String Variable. This is one quick TCL Command so simple enough!
If you haven't already, you will need to create your String Variables in order to save the values into them.
Now remember, we only want a sync to occur should something be playing within the Master Bedroom. We can enhance this in various ways but for the sake of simplicity (and since it is already working well as-is) lets create a simple IF/ELSE Statement that checks if our Bedroom Source Variables Value is equal to "Off" (both the default value and the value when the room is in its off state).
If the Bedroom is off we do not wish to conduct any syncing so we leave that area empty and move on to the "ELSE" part of our statement. This is where we will conduct our magic! Ready for the hard part?
So here it comes, in order to accomplish the sync, move whatever is playing in the Master Bedroom into the Master Bathroom (but only if it is currently playing something within the Master Bedroom) we have to ... do... ONE COMMAND!
If you look at the command above, we use the "Variable Syncing" feature. This TCL Command will sync two or more variables together so that their values will always match. If you change one variable any synced variables will automatically change as well until unsynced. We also define what value should be initially synced to the rest in the group. In our case we "Start" from the Bedroom and "Sync To" the Bathroom. This will automatically copy the value of the Bedroom into the Bathroom (and conduct any React Events accordingly)!
For Sync Type, for the sake of this tutorial just copy us by using the "Forced Add To Sync" option. Theoretically any of the options would work for our circumstances and we will go over what these mean in future tutorials, guides, and documentation.
Sync ID is utilized so that we can later cancel or add/remove other variables from our Sync Group. We will go over that next. Make sure you use an ID you can remember!
Here is our Macro thus far:last edited by Braden Napier
Braden R. Napier