Source Selection Using React


  • Tomorrow I am planning to embark on the journey with Dash React. I am rebuilding my system from scratch. As I work through it I will post some screen shots and hopefully some good tips. I guess I should address the topic. LOL. I am planning to start out the journey with source selection. So instead of string variables, I am going to use the new React module to select sources.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com


  • 24
    Posts
    6251
    Views
    Log in to reply


  • I am doing the same right now. I am thinking about a style of outline that will help organize the automation. Ill post whatever I come up with.

    Justin Spiniolas



  • My belief is that as a group we will begin to adopt new ways and find new fun and interesting ways to handle tasks that we want to accomplish. It's open-ended so I think it will be cool to see what we come up with!

    DashReact.png

    --
    Braden R. Napier



  • This is my first attempt. This attempt is wrong. I have posted the How To further down the page with the correct procedures. My intention for this post was to document how I started, where I went wrong, and how it ended up working.

    Attempt one. I am struggling with the each source. Do I need to create an event for each source available? As I am typing this, I think I am getting it. LOL. Okay, let me try this.

    So, first create an event with the variable for watch living room source.

    upload-8faf2a41-6683-4ff4-934c-52813ace3679

    This will be used for all sources.

    Second create events for each source. These will be used by all rooms that have access to the source.

    upload-471408bd-035a-4cc6-b2e1-3da7db0be62e

    Here I am creating an event for DirecTV.

    Now, we will create the actual trigger. This will be a TCL command in the Living Room Macro for DirecTV

    upload-3f9e0925-de14-4a67-a4aa-e2015ca8a5ab

    I probably messed this all up, but I gave it a shot. I didn't put in commands in the actual events, I believe those are will be the commands that should occur when that event happens.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • @Nick-Picklo said:

    Can you clarify or show a full example of turning a room source on and all it's components? I am struggling with the each source. Do I need to create an event for each source available? As I am typing this, I think I am getting it. LOL. Okay, let me try this.

    So, first create an event with the variable for watch living room source.

    upload-8faf2a41-6683-4ff4-934c-52813ace3679

    So what you've done here is created a macro that will trigger whenever the "LivingRoomSource" macro includes "Watch" - this is a macro where you would probably turn on the TV and set the HDMI Input (unless using multiple inputs on the TV).

    This will be used for all sources.

    This is actually correct, whenever you are "Watching" a source you will add "Watch" to your LivingRoomSource Variable and can be confident the TV will be on if programmed as specified above.

    Second create events for each source. These will be used by all rooms that have access to the source.

    upload-471408bd-035a-4cc6-b2e1-3da7db0be62e

    Here I am creating an event for DirecTV.

    While you could probably make something like this work, I think you are thinking about it backwards. Your variable name should still be LivingRoomSource and becomes operator should be "Includes" "DTV1" or "DirecTV1" (whichever you prefer). This means you would set your LivingRoomSource variable to Watch-DTV1 or Watch-DirecTV1 to trigger the commands

    As this stands you have two variables, one called LivingRoomSource and another called DirecTV1 - both of the macros you have created are set to trigger when their values include Watch.

    Now, we will create the actual trigger. This will be a TCL command in the Living Room Macro for DirecTV

    upload-3f9e0925-de14-4a67-a4aa-e2015ca8a5ab

    I probably messed this all up, but I gave it a shot. I didn't put in commands in the actual events, I believe those are will be the commands that should occur when that event happens.

    That trigger would not work but you are close, just modify the second event as shown and you should be good

    --
    Braden R. Napier



  • Ok, so I got it to work. I made two mistakes, well 4. Brady caught one, see post above. After discussing with Brady it seems that the better option (well he may change his mind, so for now we will call it the option that offers the greatest flexibility) for source selection is to build events for every source for each room.

    So, in doing that I made a second mistake. I changed the "Becomes Logic Options", for me it made sense that when the "statement becomes true", do x. That isn't the case, leaving it as the default "statement becomes true and remains true" is the correct method.

    My third mistake was using spaces in the value field. This has been updated now, I believe spaces are now allowed. So after fixing those, the set source worked.

    And it is fast. It fired everything on at one time. Crazy fast.

    Then the 4th mistake. I put the command for Off in the Room On field. LOL. So...I fixed that.

    One of the nice things about this is the simplicity. Because the actions are compartmentalized it is easy to troubleshoot and to understand what the action is doing. I find it easier to understand when compared to the string variable method. Also seems like less chance for programming errors.

    Stay tuned until tomorrow, I will post a short "how to" with screen shots and do my best to explain how and why each step works.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • Quick question...
    If all events fire at the same time how do you get round the problem of source switching with devices that take a while to come on?
    For example - My Anthem AVR will not respond to commands for 7 seconds while powering on. With string variables I can control when the input commands are sent by the order of the macro and delays, with event variables I can't. Or can I?
    Just re-programming my home system to try and get my head round React and this is the first thing I thought of.



  • Absolutely you can. That is the beauty of this. The separate commands all run at the same time in the background. I am driving right now. When I get a moment, this afternoon, I will post the screenshots and walk through.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • As usual you can expect there to be quite a few responses to any questions you may pose. However you are right that these types of things will likely be the biggest challenge for people. There are a few powerful methods you can use to accomplish your goals. However, it's positive to see that you guys are thinking about these things as these are the biggest hurdles dealers are going to run into... luckily the solutions are fairly simple!

    Regardless of the option we choose, keep in mind that React will still provide the end-user with an "instantly ready" experience as it will all trigger in the background, but we will simply run less simultaneously.

    So we are already assuming when we want to set a source, lets say Roku, we will be setting our variable to the following:

    Watch-Roku
    

    Now depending on how we have the system setup we will decide what each function does, and when it gets triggered. The obvious answer here is to have the following rules setup:

    IF $Bedroom (INCLUDES) Watch
    IF $Bedroom (INCLUDES) Roku

    So when setting our variable Bedroom to the value listed above, we would have two macros fire, one for "Watch" and one for "Roku." This also means we will have two simultaneous macro operations (each of the said macros). Our goal is to "compartmentalize" the functions of our systems into simple, easy to understand and modify re-useable snippets. Once we have done this, we will be able to manipulate our systems and execute more and more advanced functionality without the fear of missing a step in the programming, etc because we are always using the same snippets which we have confirmed as working.

    We get to decide what each function does and how it should React. Well if we consider our other variable values might look like this:

    Watch-DVD
    Watch-Cable
    Watch-ATV
    Listen-SNP-Pandora
    Listen-SNP-Sirius
    Listen-ATV
    Listen-CD
    

    We can start to assume various things about each of our values:

    • Whenever Watch is apart of our variable we know that at the very minimum the TV needs to be on. Since this runs in the background, we don't have to worry about adding delays, etc. so we can put something like "TV ON" "DELAY 7 SECONDS" "HDMI 1" and the user will never need to even know the delay occurred. We can also possibly safely assume that the AVR will need to be turned on and switched to the proper source so we will have a couple options in front of us here.

      1. We can simply turn on the Receiver and provide the proper delays on the "Roku", "DVD", "Cable", etc part of our macro. Keep in mind your macros are still in the background so any delays your end-user won't perceive other than waiting for the actual thing to switch - their UI will already be switched for them giving them a sense that the system is much more responsive.

      upload-80132348-4390-455d-b7a9-91f176f0e452
      upload-90aac6ad-ca18-4bef-840e-369e7d5ef4e1

      1. We can Turn on the AVR from the "Watch" macro (so that it only ever needs to be in one place). When we do this, if we decide to do the source switching in the "Roku", "Cable", etc part of our macro then we do need to consider how best to handle it to make sure the command will work as designed.
    • Option 1: Source Delays

    We could build in a simple delay. Since this macro runs in the background it shouldn't cause any problems to do something like so:

    upload-82391ff0-2302-497b-acde-614174fe0755

    In the above example we are instantly setting the AVR to the Roku input, but then providing a small delay (or whatever may be necessary) and then sending the command again. Since this runs in the background without freezing up the end-users UI this won't be a problem as if the AVR was already on the switch will be immediate, otherwise it will take the normal amount of time. Without any IF/ELSE Statements we have still accomplished our goal in just a few lines.

    • Option 2: URC Variable Abstraction

    While this won't make as much sense in this situation, another option when we run into complexities that we aren't sure how best to build Asynchronously, we can abstract from the React Methods and return to what we are used to. This would involve us running a GET VARIABLE VALUE Command on our variable from within the Watch side of our macro then using URC's Standard String Variable approach as we have been doing. We will have multiple macros running simultaneously so other things are going on as-needed. In significantly more complex situations there are times this may make a lot of sense to do as it provides a bit more ordered structure to your macro:

    upload-cd73231e-9db5-44e6-8727-226bb4c34afe

    Once we send this command, our URC String Variable will have a value of "Watch-Roku" (or whatever we set it to). We can then run any kind of URC Command against it simple enough:

    upload-7ef73c43-fb16-454e-905d-744f59340f58

    • Option 3: Callbacks & Triggers

    Ok so this is technically going to be the most reliable method of doing this type of thing when the situation becomes more complex - and it is extremely powerful. However, I am not going to go very deep into it (mainly because I have to play with various ways of doing this since there are probably 100 to figure out what the best is). Here is the basic idea/concept:

    • When we build our commands, we can "append" data to the variable which will then react with macros triggering.
    • When our Receiver has finished turning on, we can "Append" a parameter to our variable letting React know it's ready for commands.
    • When our new parameter is included in the macro, we can then send the proper input switch commands - we can use In-Event Logic ("If $Bedroom (INCLUDES) Roku AND AVRReady") or we can grab the variable value as shown above and check if it includes our "Ready" parameter (AVRReady).

    However, this option is definitely overkill for something like the AVR dilemma originally proposed. I wouldn't go this deep for something like that unless you are just doing it to learn and play with the React Toolchain or if you have a significantly more complex desire.

    Cloud Logging!

    Don't forget to add lots of Output to Cloud Logs while you are programming rather than waiting until you need it. This way your logs will make more sense as you know exactly what you are expecting to happen and where. You will need to do this less and less as you move on and start building your standard ways of doing things, but for now I can't recommend using it more than usual so you can see what is happening and why/when.

    --
    Braden R. Napier



  • ok muddling through this:

    When building my macros for each room dont I want my Strings to be specific?

    For example I dont simply want to use the string 'watch-dtv' , What I need to do is 'famwatch-dtv

    Correct?

    Jason Vizthum
    President
    Integral Technologies Inc.
    Lahaina, Hi & Riverside Ca



  • Hey Jason,
    Keep in mind things are separated into containers (which we are calling Variables so they are easier to understand). So your "Variable" is independent of any other values.

    So if you have a variable LivingRoom and a variable Bedroom - both can react different when their values become Watch-DTV since they will only know something happened if they themselves change.

    --
    Braden R. Napier



  • Just setting up our demo system with React and I have everything switching on and off as it should, however, I cannot get room tracking to work.
    The devices will switch on and the UI will jump to the correct interface but after 30 seconds it drops back to the main page.

    I know this has something to do with device power on and offs but don't know how to implement it with React.

    EDIT: The room tracking isn't working 'cause none of my React events are happening. Something has gone very wrong :(



  • Chris, you should verify that the variable name is exact in all locations. Same with the value.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • Checked that already.
    I've noticed that my React settings do not have the "Becomes Logic Options", "Statement Becomes True" that are in your screenshots. Different version or is something up?



  • FYI The term React comes from the user setting the variable and the system reacting to the variable that was set.

    Below are the screen shots of a simple source on and off. What this is going to do is to set up the Living Room and tune to Apple TV. I am doing it in 3 steps. Step 4 will be turning the room off.

    Step One. Create the device event for Living Room Source Watch. This will set up the room for what ever source you are going to watch. In this example, the TV is turned on, the matrix is turned on and the receiver is turned on.

    upload-e329e19b-be0f-495e-a0c0-741d845dedb6

    Step Two. Create the device event for the source selection for Apple TV. This will trigger when the value is seen (step three). In this event the commands for selecting the source are inserted. You will notice in the Device Events tree that I create similar events for all sources for each room.

    upload-b50d27ba-14e4-4b0f-b41c-2394b73a91f7

    Step Three. Navigate to the Edit Macro by Room and create the command that will make this work, basically setting the variable and triggering the events. This is the key to it all working. You want to set the variable for the source selected.

    upload-5fe65fee-4bce-4bfd-a9e2-32984835eae1

    Step Four. Turning the Room Off. You will need to create a Device Event for Living Room Source Off. This is what will be triggered when the variable is set.

    Here is the Living Room Source Off Device Event.

    upload-0e4708b3-5be5-4d06-ac5f-1451281950e6

    Next you will need to set the variable that will trigger this event. This variable should be set in the Room Off macro under Edit Special Macros. Note, for multiple rooms sharing sources, currently I have not found a way for true tracking to prevent sources from turning off in other rooms when that source is turned off in another room. I am sure this can be done with more variables and if/else or a more complex react procedure. For now I have removed the Off commands for the sources.

    upload-f006c2de-6879-4cae-8233-3b8d07f5c155

    That is it. For multiple rooms and sources you will want to repeat these. It seems long and drawn out, but it really isn't. It goes quickly and will have many benefits for complex systems.

    upload-f1e0eddb-004c-4b3a-9758-494c2d6e1470

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • @chris said:

    Checked that already.
    I've noticed that my React settings do not have the "Becomes Logic Options", "Statement Becomes True" that are in your screenshots. Different version or is something up?

    If you read the follow up post by Braden and myself you will see that the Logic Option in my first attempt is wrong. I changed that and I should not have. It needs to remain the default "Statement Remains or Becomes True".

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • I don't have that option at all..
    Under parameters I have:

    • Variable Name
    • Rule ID
    • Becomes Operator
    • Becomes Value
    • Was Operator
    • Was Value
    • Was Logic Options


  • @chris said:

    I don't have that option at all..
    Under parameters I have:

    • Variable Name
    • Rule ID
    • Becomes Operator
    • Becomes Value
    • Was Operator
    • Was Value
    • Was Logic Options

    upload-d6ddfb77-0922-4f1c-b0eb-8d87d12c2bf7

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • @chris said:

    Checked that already.
    I've noticed that my React settings do not have the "Becomes Logic Options", "Statement Becomes True" that are in your screenshots. Different version or is something up?

    Sounds like you are trying to use a TCL command for something. Read through my post on how to set it up. Look at where I am creating the various events. The only TCL command for React being used is in the Edit Room Macro.

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com



  • Nope. I just don't have that option:
    Upload.png



  • @chris What version of the module (TCM) are you running? Are you using the newest version? If not, import the newest version. When you import it, the version will show .92.

    upload-e99ea7a5-72fc-480f-95ce-dc39c2a3c6e1

    upload-9b329938-7059-441c-8a41-1dd348617ca0

    Nick Picklo, CGB
    Certified Graduate Builder
    m. 713.562.0009

    Websites:
    www.PickloHomes.com
    www.PickloDigitalHomes.com
    www.PickloPools.com


24
Posts
6251
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!