Feature request on reactions side.
-
@tarkus said in Feature request on reactions side.:
Secondary conditional rules on reactions.
Could you please expound further? My first guess is that you'd like to see a 2nd set of Conditions, which get evaluated later (e.g. after Set Reaction runs), in lieu of calling another Rule?
-
I can give an example.
I have a rule that turns off my garden lights at 12.30am every night via a schedule.
In that rules "Set Reaction" I also wanted a http request to make a TTS announcement to my Google Home speaker.
However I only wanted the http request to be sent if Vera was still in Home mode.
If Vera is in Night mode and I'd already gone to bed, I didn't want the TTS announcement to occur at all.
There was no way for me to do this in MSR that I could see, so instead I had to use Lua code in the "Set Reaction" and have Vera itself evaluate its current House mode status and send the http request or not.
I was unable to have this additional condition (constraint) in the "Set Reaction" just for the http request part of the actions.
I could of maybe created a second rule only for the http request action, but I don't want to create a bunch of other rules just for this type of thing.
-
toggledbitswrote on Apr 7, 2021, 3:17 PM last edited by toggledbits Apr 7, 2021, 11:18 AM
The rule that turns off your garden lights ("Garden Lights Off" ) will go true at the appointed time (presumably). This rule should not have the TTS request.
A second rule ("Garden Lights Announcement") uses a Rule condition in its triggers to watch the Garden Lights Off rule, and has a constraint for Home mode. Set reaction is the TTS request.
Done.
-
Yes that makes sense and I understand how that could work with two rules.
But I didn't want two rules, so instead used Lua code initiated in my rules "Set Reaction", to determine Vera's current House mode status and have Vera send out the http request if in "Home" mode or NOT if in any other mode.
-
@librasun Sure I currently have lua that has multiple "if" conditions that is run on the reaction side. Consider these "if" conditions in the lua the secondary conditions.
Usage senario:
Say you have 3 separate expression / variables with varying values of 0-9 lets call them.
Variable_1
Variable_2
Variable_3On the reaction side
If variable_1 = 2
Send TV IR code for digit 1
If variable_1 = 2
Send TV IR code for digit 2
etc, etc
delay 1 second
If variable_2 = 1
Send TV IR code for digit 1
If variable_2 = 2
Send TV IR code for digit 2
etc, etc
delay 1 second
If variable_3 = 1
Send TV IR code for digit 1
If variable_3 = 2
Send TV IR code for digit 2
etc, etc
-
LibraSunreplied to Tarkus on Apr 7, 2021, 5:01 PM last edited by LibraSun Apr 7, 2021, 1:05 PM
@tarkus said in Feature request on reactions side.:
@librasun Sure I currently have lua that has multiple "if" conditions
If I'm following your example correctly, each of your three variables can take on integer values from
0
-9
inclusive, derived from the status of some device on Vera (I call ittv
here for convenience). And you want to send three separate IR codes determined by each variable's value. Here's how I would do that in MSR (in pseudocode, of course):EXPRESSIONS:
v1 := getEntity( "vera>tv" ).attributes.<attr>.<val1> v1 := getEntity( "vera>tv" ).attributes.<attr>.<val2> v1 := getEntity( "vera>tv" ).attributes.<attr>.<val3> buttonCodes := ["code0","code1","code2", ... ,"code9"] c1 := buttonCodes[v1] c2 := buttonCodes[v2] c3 := buttonCodes[v3]
SET REACTION:
[Entity Action] ["vera>device_<remote#>"] [x_service_name_send_code] [${{ c1 }}] [Delay] [ 1 ] [Entity Action] ["vera>device_<remote#>"] [x_service_name_send_code] [${{ c2 }}] [Delay] [ 1 ] [Entity Action] ["vera>device_<remote#>"] [x_service_name_send_code] [${{ c3 }}]
What I'm doing is asking MSR to "lookup" the corresponding
buttonCode
from an array (conveniently indexed0
through9
), assigning those string values toc1
-c3
, and making those substitutions in each successive steps of the Set Reaction.Am I close to your goal?
-
I am afraid the Global Cache IR plugin that Patrick added support for does not seem to work with expressions in the send code field. I tried to add the hex code for a digit to a Global expression and put ${{Digit_1}} in the send code field but it did not work.
-
Can you show me the valid values which the plugin accepts? (After all, they do exist and are transmitted by Lua, and I haven't yet encountered a value which MSR cannot send, so this makes me doubly curious.) Maybe I need to see more of your actual setup, if you don't mind?
FUN READ: https://kinkeadtech.com/control-ir-devices-with-z-wave/
-
@toggledbits can variable substitution be added to the "Code" field shown?
-
Variable substitution works in all action fields.
-
There you go!
-
yes, it just does not fire when putting the code into a variable.
-
Did you look in the MSR logs to see what was being sent? Did you look in the Vera log to see what was being received?
-
@tarkus said in Feature request on reactions side.:
yes, it just does not fire when putting the code into a variable.
Is MSR giving you any feedback in the Log and/or Status screen? I ask because perhaps you haven't used quotes around the hex code strings when defining your variables, for instance?
-
Have not gotten that far. Just was playing around with this, this morning before my workday started. Will dig into logs when I get a chance.
-
@librasun Ok the quotes did the trick! So I am assuming for
"code0","code1","code2", ... ,"code9"
I am assuming I am making 10 variables. i.e.
code0="0000 0067 0000 000D 0060 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 0422"
ect, ect....
-
@tarkus said in Feature request on reactions side.:
@librasun Ok the quotes did the trick! So I am assuming for
"code0","code1","code2", ... ,"code9"
I am assuming I am making 10 variables. i.e.
code0="0000 0067 0000 000D 0060 0018 0030 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0030 0018 0018 0018 0018 0018 0018 0018 0018 0422"
ect, ect....
Okay, not exactly. In my example, above, I had intended for you to paste all 10 codes, with quotes, directly into the array itself. I now see how cumbersome that would look, and not lend itself very well to editing.
So your approach of creating all 10 variables this way makes more sense... BUT you'd have to reference them in the array without quotes, as in:
buttonCodes = [code1, code2, code3, .... , code9]
and be sure to place this Expression definition after all 10 codeN declarations (this is just a best practice, not mandatory).
11/37