Hello, maybe somebody will help me. I am trying to define a button which is switching lights in one room off. For unknown reason it is not working more than once every time linknx is started.
My definitions of objects and rule are as follows:
<objectid="goscinny_full"gad="0/5/11"flags="crwtf">gościnny wszystko on off</object><objectid="goscinny_przycisk_p6_toggle"gad="2/0/23"init="request">scena</object><ruleid="action_goscinny_przycisk_p6_toggle"><conditiontype="or"><conditiontype="object"id="goscinny_przycisk_p6_toggle"value="on"trigger="true"/><conditiontype="object"id="goscinny_przycisk_p6_toggle"value="off"trigger="true"/></condition><actionlist><actiontype="set-value"id="goscinny_full"value="off"/></actionlist><actionlisttype="on-false"><actiontype="set-value"id="goscinny_full"value="off"/></actionlist></rule>
The output from the log file whenever I press the button is as follows:
20110310 00:00:57,116 INFO Object : New value off for object goscinny_przycisk_p6_toggle (type: 1.001)
20110310 00:00:57,116 INFO SwitchingObject : SwitchingObject (id=goscinny_przycisk_p6_toggle): Compare value_m='0' to value='1'
20110310 00:00:57,116 INFO Condition : ObjectCondition (id='goscinny_przycisk_p6_toggle') evaluated as '0'
20110310 00:00:57,116 INFO SwitchingObject : SwitchingObject (id=goscinny_przycisk_p6_toggle): Compare value_m='0' to value='0'
20110310 00:00:57,116 INFO Condition : ObjectCondition (id='goscinny_przycisk_p6_toggle') evaluated as '1'
20110310 00:00:57,116 INFO SwitchingObject : SwitchingObject (id=goscinny_przycisk_p6_toggle): Compare value_m='0' to value='1'
20110310 00:00:57,117 INFO Condition : ObjectCondition (id='goscinny_przycisk_p6_toggle') evaluated as '0'
20110310 00:00:57,117 INFO SwitchingObject : SwitchingObject (id=goscinny_przycisk_p6_toggle): Compare value_m='0' to value='0'
20110310 00:00:57,117 INFO Condition : ObjectCondition (id='goscinny_przycisk_p6_toggle') evaluated as '1'
and …. nothing else happens. There is no write for 'goscinny_full' even though the condition is evaluated to true. The flags to force write for the object is set. The goscinny_full is never updated to 'off. Probably I have made small mistake which I cannot see myself.
What is weird, similiar action for another button on the same switch works always:
Hi Damago1
looking at you code it is not 100% clear to me, what your "goscinny_przycisk_p6_toggle" does.
I understood, that you want to send a "goscinny_full" ->"off", Ok, But how is the "goscinny_przycisk_p6_toggle" working?
Is this a button? or something else? If it is a typical push-button", the it sends an "on" when pressed and (maybe) an "off", when released. Or is it some some sort of "toggle"-button, which sends an "on" on the first touch and then an "off" on the second…? I wanted to understand this, because the code in your case I would think is simle:
<objectid="goscinny_full"gad="0/5/11"flags="crwtus">goscinny wszystko on off</object><objectid="goscinny_przycisk_p6_toggle"gad="2/0/23"flags="cwtus"init="request">scena</object><ruleid="action_goscinny_przycisk_p6_toggle"><conditiontype="or"><conditiontype="object"id="goscinny_przycisk_p6_toggle"value="on"trigger="true"/></condition><actionlisttype="if-true"><actiontype="set-value"id="goscinny_full"value="off"/></actionlist><actionlisttype="if-false"><actiontype="set-value"id="goscinny_full"value="off"/></actionlist></rule>
This should even work, if you get 2 goscinny_przycisk_p6_toggle with the same value in a row. ( 2 x on or 2 x off…)
If you want to have the toggle only, (take just the change fro on -> off or off -> on, then you have to replace the "if-true" with "on-true" and the "if-false" with on-false.
Please tell me, if that worked,
best Regards, Jens
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
<objectid="goscinny_full"gad="0/5/11"flags="crwtus">goscinny wszystko on off</object><objectid="goscinny_przycisk_p6_toggle"gad="2/0/23"flags="cwtus"init="request">scena</object><ruleid="action_goscinny_przycisk_p6_toggle"><conditiontype="object"id="goscinny_przycisk_p6_toggle"value="on"trigger="true"/><actionlisttype="if-true"><actiontype="set-value"id="goscinny_full"value="off"/></actionlist><actionlisttype="if-false"><actiontype="set-value"id="goscinny_full"value="off"/></actionlist></rule>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, the reason why it's executed only once is that the condition you are using ( (p6_toggle==on) OR (p6_toggle==off) ) is always true.
And since actionlist with type "on-true" (the default one) mean when the rule changes from false to true , the rule is only executed once because at startup the rule is initialized to "false", then first evaluation changes it to true => action is executed, then the rule stay "true" forever and no action is executed.
If you want the action list to be executed every time the rule is evaluated as "true", use actionlist type="if-true" as explained by auto-mate.
To simplify your condition, I think you could just use condition <condition type="object" id="goscinny_przycisk_p6_toggle" trigger="true" /> , without specifying a value. This kind of condition will always be "true" but will force evaluation of the rule every time object changes (and if you use the 's' flag on object, it will be every time the object is set, even if the new value is the same as the previous one.)
Regards,
Jean-François
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
how about adding an additional section explaining the actionlist syntax in the wiki? I have seen several discussions on this topic in this and some other forum. Many people could benefit from some extended documentation.
Thanks, Othmar
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for the replies. This might be the reason, the condition never did become false. Although I thought that whenever I will use 'trigger=true' the rule SHOULD be re-evaluated whenever "goscinny_przycisk_p6_toggle" changes value. Or even receives value over the bus. For instance with scenes, you never receive 'home_theatre_scene"=false. Anytime the scene button is pressed you will receive "home_theatre_scene" = true.
Jean-François, if you will confirm this, I will update the documentation WIKI accordingly. Recently I am updating Wiki myself). The rule:
is triggered when:
a) when a message with a value of "goscinny_przycisk_p6_toggle" is sent over KNX bus, even with the same value,
b) when a value of "goscinny_przycisk_p6_toggle" is changed from on to off
c) once at the beginning, and never again, because the condition will never become false and this prevents the rule from being re-evaluated
Yours
Damago1
P.S.
Extra explaination: "goscinny_przycisk_p6_toggle" is indeed a value which getts toggled whenever anyone presses the button. Upon each button press the value is toggled. There is no button release message sent. Another buttons I have do send "1" or "9" (alternatively) when the button is pressed and "0" when released. Such funny buttons.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Damago1,
let me try to explain again: (and Jean-François, please correct me if I'm wrong)
Some term clarification first:
A) An OBJECT is the definition of a KNX group-object, including the "group-address" (gad), "datapoint type" (type), "flags" and some other attributes for persistence and logging…etc. )
An OBJECT has a value.
An OBJECT has "flags" - these are the same flags used in ETS (crwtu) with some extension: there is also a "s" flag (formerly the "f"=force-flag), which also tells linknx rule-engine to use this object as a "stateless" object.
PLEASE REMEBER If you don't specifiy the "s"-flag, an object is ONLY send to the bus or received from the bus, if its value has changed.
-> If you don't set the "s"-flag, only the first message will be used in any CONDITION evaluation. Consecutive messages will already be filtered on reception before(!) reaching the rule-engine again!
-> you have to set the "s" flag, if you want to send or receive consecutive messages with the same value and use this in any rules.
(for example for using in scene-definition-objects…!)
B) A RULE consists of CONDITIONS and ACTIONS.
The (re-)evaluation of a (Rule-) CONDITION, which contains an (sub-) object-condition, is only triggered, when a gad is received from the bus and the "trigger" attribute for the object condition is specified. Conditions not containing "trigger" attribute are just used for logical evaluation.
C) a RULE-evaluation can cause 4 types of ACTIONS, depending on the conditions evaluation.
C1) conditions have changed from false to true: -> <actionlist type="on-true"> (this is the default, if you omit "type")
C2) conditions have changed from true to false: -> <actionlist type="on-false">
C3) conditions have been (re-)evaluted because of some trigger and are true: -> <actionlist type="if-true">
C4) conditions have been (re-)evaluted because of some trigger and are false: -> <actionlist type="if-false">
So comming back to your statements:
a) "by default", your rule (i.e. the "condition") is only evaluated, when a changed "goscinny_przycisk_p6_toggle" is received from the bus (because you have not specified the "s"-flag in the object definition).
-> specify the "s" flag for "goscinny_przycisk_p6_toggle" and the rule is always evaluated.
b) correct
c) because in your case the result of the evaluation of the conditions will never get false, the
<actionlist type="on-true"> will be executed ONLY once on the first "trigger" (i.e. the first change(!), "the beginning").
Conclusion
-> if you want to have an action on every received message (true or false), you have to use the <actionlist type="if-true">
it's not so easy to understand in the beginning…don't hesitate to ask, if it is not clear. :-)
Thanks, best Regards, Jens
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, maybe somebody will help me. I am trying to define a button which is switching lights in one room off. For unknown reason it is not working more than once every time linknx is started.
My definitions of objects and rule are as follows:
The output from the log file whenever I press the button is as follows:
and …. nothing else happens. There is no write for 'goscinny_full' even though the condition is evaluated to true. The flags to force write for the object is set. The goscinny_full is never updated to 'off. Probably I have made small mistake which I cannot see myself.
What is weird, similiar action for another button on the same switch works always:
Yours
Damago1
Hi Damago1
looking at you code it is not 100% clear to me, what your "goscinny_przycisk_p6_toggle" does.
I understood, that you want to send a "goscinny_full" ->"off", Ok, But how is the "goscinny_przycisk_p6_toggle" working?
Is this a button? or something else? If it is a typical push-button", the it sends an "on" when pressed and (maybe) an "off", when released. Or is it some some sort of "toggle"-button, which sends an "on" on the first touch and then an "off" on the second…? I wanted to understand this, because the code in your case I would think is simle:
This should even work, if you get 2 goscinny_przycisk_p6_toggle with the same value in a row. ( 2 x on or 2 x off…)
If you want to have the toggle only, (take just the change fro on -> off or off -> on, then you have to replace the "if-true" with "on-true" and the "if-false" with on-false.
Please tell me, if that worked,
best Regards, Jens
PS: Update
ups. forgot to delete the "or"-clause:
Hi, the reason why it's executed only once is that the condition you are using ( (p6_toggle==on) OR (p6_toggle==off) ) is always true.
And since actionlist with type "on-true" (the default one) mean when the rule changes from false to true , the rule is only executed once because at startup the rule is initialized to "false", then first evaluation changes it to true => action is executed, then the rule stay "true" forever and no action is executed.
If you want the action list to be executed every time the rule is evaluated as "true", use actionlist type="if-true" as explained by auto-mate.
To simplify your condition, I think you could just use condition <condition type="object" id="goscinny_przycisk_p6_toggle" trigger="true" /> , without specifying a value. This kind of condition will always be "true" but will force evaluation of the rule every time object changes (and if you use the 's' flag on object, it will be every time the object is set, even if the new value is the same as the previous one.)
Regards,
Jean-François
Jean-François,
how about adding an additional section explaining the actionlist syntax in the wiki? I have seen several discussions on this topic in this and some other forum. Many people could benefit from some extended documentation.
Thanks, Othmar
Thank you for the replies. This might be the reason, the condition never did become false. Although I thought that whenever I will use 'trigger=true' the rule SHOULD be re-evaluated whenever "goscinny_przycisk_p6_toggle" changes value. Or even receives value over the bus. For instance with scenes, you never receive 'home_theatre_scene"=false. Anytime the scene button is pressed you will receive "home_theatre_scene" = true.
Jean-François, if you will confirm this, I will update the documentation WIKI accordingly. Recently I am updating Wiki myself). The rule:
is triggered when:
a) when a message with a value of "goscinny_przycisk_p6_toggle" is sent over KNX bus, even with the same value,
b) when a value of "goscinny_przycisk_p6_toggle" is changed from on to off
c) once at the beginning, and never again, because the condition will never become false and this prevents the rule from being re-evaluated
Yours
Damago1
P.S.
Extra explaination: "goscinny_przycisk_p6_toggle" is indeed a value which getts toggled whenever anyone presses the button. Upon each button press the value is toggled. There is no button release message sent. Another buttons I have do send "1" or "9" (alternatively) when the button is pressed and "0" when released. Such funny buttons.
Hi Damago1,
let me try to explain again: (and Jean-François, please correct me if I'm wrong)
Some term clarification first:
A) An OBJECT is the definition of a KNX group-object, including the "group-address" (gad), "datapoint type" (type), "flags" and some other attributes for persistence and logging…etc. )
An OBJECT has a value.
An OBJECT has "flags" - these are the same flags used in ETS (crwtu) with some extension: there is also a "s" flag (formerly the "f"=force-flag), which also tells linknx rule-engine to use this object as a "stateless" object.
PLEASE REMEBER If you don't specifiy the "s"-flag, an object is ONLY send to the bus or received from the bus, if its value has changed.
-> If you don't set the "s"-flag, only the first message will be used in any CONDITION evaluation. Consecutive messages will already be filtered on reception before(!) reaching the rule-engine again!
-> you have to set the "s" flag, if you want to send or receive consecutive messages with the same value and use this in any rules.
(for example for using in scene-definition-objects…!)
B) A RULE consists of CONDITIONS and ACTIONS.
The (re-)evaluation of a (Rule-) CONDITION, which contains an (sub-) object-condition, is only triggered, when a gad is received from the bus and the "trigger" attribute for the object condition is specified. Conditions not containing "trigger" attribute are just used for logical evaluation.
C) a RULE-evaluation can cause 4 types of ACTIONS, depending on the conditions evaluation.
C1) conditions have changed from false to true: -> <actionlist type="on-true"> (this is the default, if you omit "type")
C2) conditions have changed from true to false: -> <actionlist type="on-false">
C3) conditions have been (re-)evaluted because of some trigger and are true: -> <actionlist type="if-true">
C4) conditions have been (re-)evaluted because of some trigger and are false: -> <actionlist type="if-false">
So comming back to your statements:
a) "by default", your rule (i.e. the "condition") is only evaluated, when a changed "goscinny_przycisk_p6_toggle" is received from the bus (because you have not specified the "s"-flag in the object definition).
-> specify the "s" flag for "goscinny_przycisk_p6_toggle" and the rule is always evaluated.
b) correct
c) because in your case the result of the evaluation of the conditions will never get false, the
<actionlist type="on-true"> will be executed ONLY once on the first "trigger" (i.e. the first change(!), "the beginning").
Conclusion
-> if you want to have an action on every received message (true or false), you have to use the <actionlist type="if-true">
it's not so easy to understand in the beginning…don't hesitate to ask, if it is not clear. :-)
Thanks, best Regards, Jens
Thank you Jens, your understanding seems correct.
Jean-François