How to use DataTrigger to activate a collection of Actions

DataTrigger allows only to activate setters related to the object parameters.

How can I use a DataTrigger to set actions like the one proposed in the EventTrigger (for example ScriptAction or PropertyAction)?

Here is the context: I use HR to control my AV system. For example I have a button to launch Netflix on AppleTV or watch a secific TV channel on my STB. I also use Alexa to do the same (Alexa launch Netflix, Alexa watch CNN…). I want to make sure that my HR UI is up to date even when the AV state is set by Alexa.

My setup is using OpenHab to set complex rules depending on Alexa commands (for example launch Netflix on AppleTV). I am using MQTT to communicate between OpenHab and HR.

Through MQTT I have a DataTrigger event when Alexa/OpenHab has launched Netflix but I do not know how to use that DataTrigger to set a ScriptAction to hightlight the netflix button (I am using a GridView to highlight one specific button) or a PropertyAction to set my TVControl device to AppleTV?

A DataTrigger can’t run a set of Actions. I am however working on a new Scenes feature that will let you do this to a certain degree. These will be outside of the XAML page but you’ll be able to make calls to specific controls, but you will have access to the “App” functions.

For your case, if all you need to do is highlight a control, this should be possible with Setters. I’ve attached a simple example showing how both a Button & GridView for you to review.
Regis.hrp (4.0 KB)

Thanks Bill for the example. I am however using the gridview to highlight the curent action button so I am not sure that your example works in my case.

I was trying a workaround using the DataTrigger to set an action like for example set isChecked to true and then have another EventTrigger with the desired set of actions when the button is Checked but this EventTrigger does not seem to trig.

My design attached if it helps. I have implemented the workaround on the Netflix button
regis4.6.hrp (3.8 MB)

This is set up a bit unusual. Your GridView doesn’t appear to be linked to any device commands. Normally when you use a GridView you’ll at a bare minimum use the SelectedValue property. That’s how states are tracked & commands are sent. It looks like if you just bind your Rule variable to this property everything should work & stay in-sync, even when you change it from a different device.

…I think I see what you are doing now with this control. In addition to setting the SelectedValue property, you’ll probably want to uncheck the IsHitTestVisible property. This way it doesn’t conflict with your buttons which are also setting the Rule variable.

Is it possible for you to setup a virtual device on OpenHAB based on the state of your AV system? You can use it to synchronize the state of your system to HR (especially great if you have multiple devices running HR).

For example a virtual dimmer (level).
Level_0 = Off
Level_1 = AppleTV
Level_2 = STB
Level_3 = Netfix on AppleTV
Level_4 = CNN on STB
and so on…

Based on the “level” of the virtual device, you can use DataTriggers (Setters) to manipulate properties of your buttons, grids, ect… (make your netflix button highlighted).

The state of the virtual device will have to be set by all control devices (OpenHAB Rules, HomeRemote).

Of course, this makes things get more complicated with the more states your AV system (I suggest you write them down somewhere lol) but, it will sync your device state together regardless if they are started by Alexa (your Rules) or HR.

I do this with the Hubitat hub and a virtual dimmer for each room and it works really well.

Thanks Jeff. That is exactly what I am doing using MQTT to bring back the latest AV status to HR. The issue is that when I get the status that the AV setup has changed due to an external actions (like Alexa) I need HR to take some actions (like setting up the right device) and I am struggling to take such action with a DataTrigger

Hello Bill. I was using a script action in the EventTrigger to set the gridview selectedvalue but your suggestion to use the “Rule” value to set the gridview selectedvalue is much more elegant. I am now able to highlight the button even when the action come from Alexa. But I still need to setup HR to the proper device.

I have seen that in the gridview I could have an EventTrigger for each item. That will be perfect to set up the proper device when the gridview item change but I am not sure how to use that feature. I have tried to use the SelectionChange trigger but I get the “cannot attached eventtrigger selectionchange” error message when I launch HR. I am not sure what the 2 other triggers ‘Loaded’ or ‘Unloaded’ are meant for?

SelectionChange fires after you click a new cell in the GridView. Loaded fires when the control is visible on screen. Unloaded fires when it’s not visible on screen.

I kind of think that this new “Scenes” feature I’m working on now will get you what you need. Like I said earlier, this will let you run a set of Actions when a device attribute/variable changes. Maybe hold off on this for now & wait for the next release.

Hello Bill,
I have seen that designer 3.10 implements the new scene feature. I am excited to try it but I do not know how to update my version 3.6 to 3.10.
When I try to download 3.10.6 from your web site it redirects me to the Windows Store App Installer and propose to donwload 3.9.6 with an error message “Ask the developer for a new app package. This package may conflict with a package already installed, or it depends on things not installed here (package dependencies), or is made for a different architecture (0x80073CF3)”

Uninstall & reinstall the Designer from the website. Installer version is Designer version

There’s a bug in the MSIX installer that I need to send to Microsoft. It throws errors when I increase the minor version number to 10. That’s why the installer version number doesn’t match the actual version number.

Thanks. I have installed 3.10.2 but I am not sure how to use the scene.

My goal is create an action that will set myTVdevice to to the proper device type (appleTV , cable box…) depending of the Rule value (my mqtt variable)

I have created one scene per device type and use the rule values to trigger one of these scenes but I am not sure to understand what action I could use to set myTVdevice. I was trying to avoid using a script and I am not familiar with the MethodAction (What is the App? what Method and parameter should I use?)

You can use a DataAction to set your variables. Scene Actions are no different than a Button’s Clicked Actions. They both work exactly the same way.

I am trying to have a PropertyAction like this one:

I do not know how to do it with DataAction?

Scenes do not have access to your XAML controls. They run completely separate of your pages. That’s why PropertyAction isn’t available for Scenes.