Menu

'or' condition not working properly

Damago
2013-01-05
2013-01-05
  • Damago

    Damago - 2013-01-05

    I have found a situation where the 'or' type condition is not working properly. I have a rule like this:

    <rule id="pietro_ALL_przycisk_p3_budzenie">
    <condition type="or">
      <condition type="object" id="pietro_schody_przycisk_p3" value="1" trigger="true" />
      <condition type="object" id="pietro_schody_przycisk_p3" value="9" trigger="true" />
      <condition type="object" id="pietro_korytarz_przycisk_p3" value="1" trigger="true" />
      <condition type="object" id="pietro_korytarz_przycisk_p3" value="9" trigger="true" />
    </condition>
    <actionlist>
      <action type="set-value" id="poddasze_centralne" value="off" />
    </actionlist>
    </rule>
    

    If I change the value of pietro_schody_przycisk_p3 than the rule is working ok --> the condition is evaluated and the actionlist is triggered properly. But whenever the pietro_korytarz_przycisk_p3 is changed to 1 or 9 than the actionlist is NOT triggered. Maybe the problem is that I have two triggers for the same group address or maybe the problem is elsewhere. I did not analyze the source code for this.

    The output from the log file whenever the pietro_schody_przycisk_p3 is changed is:

    20130105 00:49:51,336  INFO Object : New value 9 for object pietro_korytarz_przycisk_p3 (type: 5.xxx)
    20130105 00:49:51,336  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    20130105 00:49:54,292  INFO Object : New value 0 for object pietro_korytarz_przycisk_p3 (type: 5.xxx)
    20130105 00:49:54,292  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    20130105 00:49:56,740  INFO Object : New value 1 for object pietro_korytarz_przycisk_p3 (type: 5.xxx)
    20130105 00:49:56,741  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    20130105 00:49:59,904  INFO Object : New value 0 for object pietro_korytarz_przycisk_p3 (type: 5.xxx)
    20130105 00:49:59,904  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    

    As you see the value of the condition object is changed, there is indication that the condition is beginning to be evaluated BUT nothing else happens.

    In comparison whenever the value of the pietro_schody_przycisk_p3 is changed:

    20130105 00:53:26,033  INFO Object : New value 1 for object pietro_schody_przycisk_p3 (type: 5.xxx)
    20130105 00:53:26,033  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    20130105 00:53:26,035  INFO ObjectValue : UIntObjectValue: Compare value_m='1' to value='1'
    20130105 00:53:26,035  INFO Condition : ObjectCondition (id='pietro_schody_przycisk_p3') evaluated as '1'
    20130105 00:53:26,035  INFO Rule : Rule pietro_ALL_przycisk_p3_budzenie evaluated as 1, prev value was 0
    20130105 00:53:26,035  INFO Rule : Evaluate rule pietro_ALL_przycisk_p3_budzenie
    20130105 00:53:26,035  INFO ObjectValue : UIntObjectValue: Compare value_m='1' to value='1'
    20130105 00:53:26,035  INFO Condition : ObjectCondition (id='pietro_schody_przycisk_p3') evaluated as '1'
    20130105 00:53:26,036  INFO Rule : Rule pietro_ALL_przycisk_p3_budzenie evaluated as 1, prev value was 1
    20130105 00:53:26,036  INFO Action : Execute SetValueAction: set poddasze_centralne with value off
    

    ...this time not only the rule is evaluated but also there is an effect of such evaluation in the log file, and actionlist is properly triggered.

    Either I am too blind to see some obvious error, or there is some bug in linknx.

    I am using the latest version 0.1.30

     
    • Damago

      Damago - 2013-01-05

      Update:
      the problem is probably not the double trigger for the same GAD.
      the problem is probably with the 'or' condition NOT accepting more than two subconditions in some situations (maybe when some subconditions are refering to the same GAD?). The rule started working properly when I had changed it to:

      <rule id="pietro_ALL_przycisk_p3_budzenie">
      <condition type="or">
        <condition type="or">
          <condition type="object" id="pietro_korytarz_przycisk_p3" value="1" trigger="true" />
          <condition type="object" id="pietro_korytarz_przycisk_p3" value="9" />    
        </condition>
        <condition type="or">
          <condition type="object" id="pietro_schody_przycisk_p3" value="1" trigger="true" />
          <condition type="object" id="pietro_schody_przycisk_p3" value="9" />
        </condition>
      </condition>
      <actionlist type="if-true">
        <action type="set-value" id="poddasze_centralne" value="off" />
      </actionlist>
      </rule>
      

      So I had to enclose the 'or' condition within another 'or' condition. This is a bug. The 'or' condition should accept one or more subconditions according to documentation.

      What is funny: the or condition with more than two subconditions but refering to different objects seem to work fine.

       

      Last edit: Damago 2013-01-05
  • Othmar

    Othmar - 2013-01-05

    Isn't it the fact that you changed the actionlist type to "if-true" that made it work? Without it it defaults to the type "on-true" which causes the actionlist only to execute when the outcome of the condition changes from false to true. I think your first example will work when you use "if-true" and your second example will stop working if you omit the "if-true".

     
  • Damago

    Damago - 2013-01-05

    I am pretty sure that it was not the if-true. The if-true is an artefact after my many different attempts to make it work properly. Changing to 'if-true' didn't work and only finally changing the condition did work.

    Also logically analyzing the situation - standard on-true (default) is enough in this particular case because the values become 0 after I release the button and are 1 or 9 only while the button is pressed (every second press of the button is 9 and the remaining presses 1). So the rule always becomes false after I release buttons (both values = 0), and should become true when I press one of two buttons (one of the values becomes '1' or '9' for the duration of the press).

    Additionally: When i have placed both rules checking for '9' at the beginning of 'or' condition and both checking for '1' at the end of the condition, than the actionlist was triggered every second press of the button. So it means that despite 4 subconditions of 'or' being present only the first two were checked.

    My suspitions:
    some bug related to the fact that more than one condition is attached to the same group address
    or the rules work bad in case of type 5.xxx value comparisons...
    * or someting else.

    For me: the code needs review here. There is a bug IMHO

     

Log in to post a comment.

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.