Didn’t find any documentation on that. What can be done with the expression attribute?
How can I built numeric and logic expression? What is the correct syntax for ($var1 and $var2) ?..
-
How to use expression variables
-
@Heizelmann
$var3 = ($var1 + $var2)
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
and what about boolean operations?
-
Can you explain what you are trying to build ?
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
I have some presence sensors and I would build a variable which is true if at least one sensor is present and false if all sensors are absent.
-
IF [Telefoon Richard reports present or Telefoon Simone reports present] and $AnybodyHome = 0 THEN $AnybodyHome = 1
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
So a second rule is necessary to switch $AnybodyHome to 0 if no one is present, right? How does this looks like?
One expression variable would be more elegant, but as I guess it is not possible. -
IF Telefoon Richard reports absend and Telefoon Simone reports absend THEN $AnybodyHome = 0
pimatic rocks!!!
-
@Heizelmann said:
So a second rule is necessary to switch $AnybodyHome to 0 if no one is present, right? How does this looks like?
One expression variable would be more elegant, but as I guess it is not possible.Why does anybody has a problem with a lot of rules? I like to cut a lot of rules into smaller ones, just for mor flexibility and overview.
Like my projects and help? Consider donating electroneum etnjwAKGPqF6omQWRmpp9u2BPyVDG9VuyRQjNJ1S8yfBdfR9qeUQ46kRy8KS2CNqbpNLRrsgmNW6F2TMzxmZgPrh6KctrkrYbm
-
@koffienl: Thanks for helping to find a solution of my specific problem.
My problem is not to have more or less rules, the intention of this thread was not about ‘rules’ but to understand ‘expression variables’.Before going into more details let me summarize the outcome until now:
To solve the intended scenario with expression variables is currently not possible because logical operations are not allowed. A simple expression variable like the following is not possible.variables: { name: AnybodyHome expression: $ TelefoonRichard.presence or $TelefoonSimone.presence }
As a workaround a set of 2 rules together with a value variable is proposed:
variables:[ { name: AnybodyHome value: 0 }, ... ], rules:[ { id: AtHome name: At Home rule: IF [Telefoon Richard reports present or Telefoon Simone reports present] and $AnybodyHome = 0 THEN $AnybodyHome = 1 }, { id: NotAtHome name: Not At Home rule: IF Telefoon Richard reports absend and Telefoon Simone reports absend THEN $AnybodyHome = 0 }, ... ]
Pimatic offers the feture ‘expression variables’ and it looks more natural for me to express a variable from a function of others variables as the propsed set of rules.
This is fine because I don’t need to take care of whether or when a variable is updated. The resulting variable is always synchronous with the used variables. It is not clear to the native user why the arithmetic expression ($var1 + $var2) is allowed but not the logical expression ($var1 and $var2)
Comparing to rules you don’t need to distinguish between ‘trigger:’ ‘is’ ‘reports’ ‘signals’ and to take care of the target variable is already set.
For a native user it is not clear when to use what. Documentation about the difference is not found. Anyway it is shorter and easier to understand.As a user (non-developer) firstly I would like to have a natural, easy understandable and manageable user interface and secondly I would like to have a complete documentation about all features.
Rules are a big topic in general but here I would like to focus on expression variables. Let us give the users an explanation what is possible or not, how to use it, and discuss how the feature ‘expression variables’ can be improved.