Menu

Condition's_Syntax

JensH Anthony jef2000 Damago
Attachments
Timecounter-complex.png (22386 bytes)
Timecounter-simple.png (19295 bytes)

General

The type of condition is determined by the type attribute.
Supported values for this attribute are: and, or, not, object, object-compare, object-src, timer, time-counter, ioport-rx and script

Logical conditions: and, or and not

These conditions have no attributes, except type described above. Condition of type and and or can have one or more children condition, while condition of type not can have only one child condition.
An and condition will only evaluate as true if all the child conditions evaluate as true.
An or condition will only evaluate as true if at least one of the child conditions evaluate as true.
A not condition will only evaluate as true if the child condition evaluate as false.

Timer conditions:

The only attribute for this condition is trigger (optional). Value can be true or false (default is false).
If trigger is true, a change in the timer condition will force the rule to re-evaluate it's condition.

Children of this condition can be at, every, until and during.
Elements at and every can't be used at the same time, but one of them must be specified.
Elements until and during can't be used at the same time.
Attributes for elements at and until are defined in section [TimeSpec_Syntax].
Elements every and during have no attributes. The element's text defines a number of seconds.
At the time specified by at or time interval specified by every , the timer value is set to true.
At the time specified by until or time interval specified by during , the timer value is set to false.
If neither until nor during is specified, the timer is instantaneous. In this case, if the timer reach the configured time, its value will change to true, the rule will be re-evaluated (if trigger is true) and the timer value will be set back to false.
Please note that you can always indicate if the timer rule should be executed on exception days or not. The attribute exception="no" means that given timer rule will not be evaluated on exception days. Exception days requiring special treatment are defined in the Services section of config file.

Comments

  • Please note that you can use combination of timer conditions where some conditions are used to trigger the valuation at certain time, and other are just defining the general timeframe when a condition can be valid. For instance in this example:
    <condition type="and">
      <condition type="timer">
        <at day="15" month="9" hour="0" min="0" />
        <until day="15" month="3" hour="0" min="0" />
      </condition>
      <condition type="timer" trigger="true">
        <at hour="8" min="0">
      </condition>
    </condition>
    

The action meaning the action will be triggered daily at 8:00am but only in the period from September 15th to March 15th.

  • Any part of the time specification can be omitted. This means that the condition:
    <condition type="timer" trigger="true">
       <at hour="8" min="12" month="2" exception="no" />
    </condition>
    

Will evaluate to true at 8:12am every day of February (since we are not defining the day).

Object condition:

As for timers the attribute trigger (optional) can beset to true or false (default is false).
If trigger is true, a change in the object value will force the rule to re-evaluate it's condition.
Attribute id says which object is monitored by this condition. Attribute value contains the reference value for the comparison.
Optional attribute op specifies the comparison operator, default value is eq, the supported values are:

  • eq : object value equals reference value
  • lt : object value is less than reference value
  • gt : object value is greater than reference value
  • ne : object value is not equal to reference value
  • lte : object value is less than or equal to reference value
  • gte : object value is greater than or equal to reference value

    <condition type="object" id="light_level" value="12" op="lt"></condition>

Object-src condition:

Similar to object condition, but with an additional src attribute specifying a device's physical address (e.g. 1.1.20) and evaluating to true only if the object condition is true and the last group telegram received for the configured group object was coming from the device specified by src attribute.

Object-compare condition:

Similar to object condition, but with the value attribute replaced by id2 which is the id of a second object for the comparison.
Sample (true if value of temp_salon is less than value of consigne_temp_salon):

<condition type="object-compare" id="temp_salon"
id2="consigne_temp_salon" op="lt" />

The comparison can only take place between objects of the same type or of "compatible" types.
Some groups of compatible types are:

  • 9.xxx and 14.xxx (floating point 16 and 32bit)

  • 5.xxx, 5.001, 5.003, 20.102, 7.xxx and 12.xxx (they all use an unsigned integer value internally)

  • 6.xxx, 8.xxx and 13.xxx (all use a signed integer value; 29.xxx is not compatible because it uses a 64bit integer)

  • 16.000 and 28.001 (character strings)

Time-Counter condition:

Since version 0.0.1.25 a time-counter condition has been introduced to support timers, which are more flexible than just using the "delay" in actions. A time-counter condition has 2 attributes:

  • threshold
  • reset-delay

and a "child-condition". If the child-condition stays true for the threshold time, the time-counter condition evaluates to TRUE and<actionlist>...</actionlist> is executed. If the child-conditions switches from TRUE to FALSE, then after reset-delay the time-counter condition switches to FALSE and the <actionlist type="on-false">...</actionlist> is executed.

Sample:

    <objects>
      <object id="Test_Switch1" gad="10/5/15" type="1.001" flags="cwtus">Test_Switch1</object>
      <object id="Test_Switch2" gad="10/5/16" type="1.001" flags="cwtus">Test_Switch2</object>
    </objects>
    <rules>
      <rule id="TestTimer">
        <condition type="time-counter" threshold="6" reset-delay="4" >
           <condition type="object" id="Test_Switch1" value="on" trigger="true" />
        </condition>
        <actionlist>
            <action type="set-value" id="Test_Switch2" value="on" />
        </actionlist>
        <actionlist type="on-false">
            <action type="set-value" id="Test_Switch2" value="off" />
        </actionlist>
      </rule>
    </rules>

In the example above the child-condition is

<condition type="object" id="Test_Switch1" value="on" trigger="true" />

In a diagram the behaviour can be shown like this:

The time-counter condition can also take short "spikes" into account as follows: The "true"-time is summed up until the "threshold" is reached or the "false" time has reached the "reset-delay". In this case the counting is started over.

Example scenario for using this type of condition is to set a threshold between the noise detection status coming from a babyphone and the action to trigger.

<condition type="time-counter" threshold="15" reset-delay="5m">

    <condition type="object" id="babyphone" value="on" trigger="true" />

</condition>

The condition is true if the babyphone detects noise for at least 15 seconds altogether. If no noise is seen for 5 minutes, the counter is reset.

Another use can be determining between short and long button presses if you want to use wall buttons which do not support short and long presses natively (for instance BIQ switches without temperature control). You can programm the button for blinds control and calculate the time during which the button value is "1" or "9" (pressed) where the value "0" can be used to reset the counter. And then use this to switch two different lights instead of blinds control.


Related

Wiki: Action's_syntax
Wiki: Main_Page
Wiki: Rules_section
Wiki: TimeSpec_Syntax

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.