[Guide] Source Setup Magic & Dash React 101
One of the first ways many have started to implement Dash React into their systems is by using it to enhance the "Source Setup" macros and making it simple to setup any of the systems in our room just by changing a variables value. We should start by making it clear that there are an unbelievable amount of ways to accomplish almost anything we do within Dash React. As we learn more fun & interesting ways to use Dash React tutorials such as this may change or new guides may be posted.
How it Works
With Dash React we are creating events within our systems that will trigger an automatic reaction to any event. We accomplish this by implementing a framework which allows you to create and manipulate "Variables." Your system can set the values of variables from any macro and as the Dash App is updated, it will continue to offer more and more deep integration with other Dash Apps.
Variables can be String or Integer, each has it's own properties and benefits. In this guide we will focus on the String Variables. Let's start with a simple example and expand upon it as we move on. Our Events can parse the value of our Variable and a macro can be set to trigger whenever each event becomes true.
Dash React is actually operating differently than how many Modules & Dash Apps are working. React will read all the events you have programmed right when it starts up and "compile" them into simple to maintain and efficient "Groups." These groups only care about events that relate to them and allow React to remain extremely fast & powerful in even the most demanding of setups.
That also shows that it is sometimes a good idea to separate out your Variables if the tasks don't always correlate to each other. For example, having "LivingRoomSource" and "LivingRoomLights" separated may be smart (more on that in other guides).
Let's take a look at few events we might schedule in a "Set Source" type of Event Sets.
In the diagram above we lets say we tied these events to a variable we name "LivingRoomSource," our events are looking for the value of the variable to either equal "Off", include "DVD", or include "Watch." We can actually do much more powerful logic on the values of the variable, but more on that in future guides!
Each Event we program will occur simultaneous to any others, this means that if our macro becomes "Watch-DVD" both Event 2 and Event 3 are going to fire at the same time rather than one after another, speeding up the execution of our macros significantly. This also means we have to take special care as-to how we build our macros because there is no guarantee as-to which event is triggered first (unless we design our implementation differently).
So lets take a look at what these events will look like in Accelerator:
Variable becomes Off
Above is one of the simpler events we can program as it is simply looking for the value of our LivingRoomSource Variable to become exactly "Off." Anything else and it won't trigger.
It is interesting to note that you can have multiple of the same events programmed if you want multiple macros fired every time the Variable Value becomes "Off." This could allow you to turn off multiple devices simultaneously by changing the event to "Off." We can also get similar and more flexible functionality by using the "Includes" and other operators.
When things really start to become interesting, and where the potential starts to open up to do some very powerful (and easy to accomplish) automation is when we start to use operators and/or multiple events to operate against our variables value.
Let's take a look at how we would create an event that says "If Includes Watch." It doesn't matter where or how, as long as "Watch" is in our Variables Value we want to trigger a macro to turn on / setup our TV / Display as we know the user is expecting to Watch something.
Variable INCLUDES Watch
Notice the "Becomes Operator" is set to "Includes" which tells the event how to parse the value of the variable.
It is important to name your Event Macros in a way you will quickly understand what they are watching for. In our example we are using "R: LivingRoomSource * Watch" - the "R:" Signifies that the macro is attached to React, then we name the variable it watches. We use the "*" to signify "Includes" and then list what it is we are looking for ("Watch").
We would then do the same for "If Includes DVD" and use that macro to turn on and prepare the DVD Player. We could add any other parameters we saw fit (and add them easily in the future) to dictate the way we want our macros to trigger and how. This starts to show the amazing flexibility that Dash React provides you!last edited by Braden Napier
Braden R. Napier