Ok, guys. I’ll try to explain this.
trigger: keyword is used to let the expression evaluate to true when the value of the predicate following the
trigger: keyword changes
for keyword is used to let the expression evaluate to true when the value of the predicate preceding the
for keyword has been true for the given time period
- Using both keywords together are seen as contradictory as the two conditions cannot occur at the same time for the given predicate
To make the confusion even bigger: First, I think the
trigger: keyword is not required in the given example as with the ECA rules system introduced in v0.9 the WHEN part only evaluates when a given event occurs. For example,
WHEN door is open triggers when the door state changes from closed to open. Actually, the current rule system has a flaw, as one can write
WHEN door is open for 2 seconds, however, this will only evaluate to true when the door state has changed from closed to open. I think this should actually be written as
WHEN door is open AND IF door is open for 2 seconds. There is another flaw:
WHEN door is open on for 2 seconds and its 18:00 will evaluate to true even if the door state has not changed at all. So, in the combined expression if reads
WHEN its 18:00 and IF door is open on for 2 seconds. That’s confusing.
Getting back to your example, try the following:
# Fires once at about 18:02h if the door has been open for 2 seconds
WHEN door is open on for 2 seconds and its 18:00 then
- It does not make sense to use
trigger in the WHEN part. I believe it is not required at all.
- The rule system has some conceptual flaws and need better documentation. The documentation given in the wiki is outdated