formatting of "set variable" in rules
-
I am not a programmer, so I am picking this up piece by piece.
I would like to use a rule-based expression to store the current value of a dimmer, change the dimmer value, then change it back to the stored value.
I have a working global expression that I have used.
getEntity( "VeraShop>device_24" ).attributes.dimming.level
I have a blank global expression ready to use in "set variable" that is available to set.
I am stuck with the formatting of the "set variable" field to set the variable. If I get pointed in the right direction, I am fairly confident I can get the rest going on my own. .
Thanks in advance
-
I am not a programmer, so I am picking this up piece by piece.
I would like to use a rule-based expression to store the current value of a dimmer, change the dimmer value, then change it back to the stored value.
I have a working global expression that I have used.
getEntity( "VeraShop>device_24" ).attributes.dimming.level
I have a blank global expression ready to use in "set variable" that is available to set.
I am stuck with the formatting of the "set variable" field to set the variable. If I get pointed in the right direction, I am fairly confident I can get the rest going on my own. .
Thanks in advance
Maybe I did not ask that question correctly, but I guess what I was asking was how to create a variable reference in a set variable type reaction. I did figure that out, so the next thing I am stuck on is the syntax of how to apply that variable in a device_set_variable action.
I know my problem here is a lack of basic programing syntax, but I am doing my best to learn in my spare time. I am not looking for someone to give me a fish, I just have some questions about fishing.
-
if the value is 0.11 then ${{variable_name * 100}} would give you 11, If i understand correctly.
You cannot "Set Variable" on a variable that has an expression assigned to it. It will not set the value, because the expression, when present, always controls the value. "Set Variable" can only be used on expressionless variables.
If you want to store the value of a dimmer in a "Set Variable", the target variable has to be expressionless, but you can (must) use a
getEntity()
expression in the "Set Variable" operand. In the example below, the "Set Variable" saves the current dimming level at step 1, then the entity action sets the level to 100%, then there's a delay, and then the dimmer is set back to the saved value from step 1. -
Thanks, @Elcid. That was sort of a confusing example because the variable of .011 should not have been there. That was just for testing the device_set_variable action to make sure it worked.
Thanks, @toggledbits. That is exactly what I needed. I was trying to get the value using a getEntity() without double curly braces, so it did not work. When I got the expression to pull in with the proper formatting, I never went back and applied that to the getEntity() command that I was originally trying. I've got it now, and in time I'll get better at this.
-
T toggledbits locked this topic on