Hallo,
ich habe eine Problem mit linknx und Lua script. Ich möchte den Stromverbrauch von einem Zählerwert in einen Verbrauchswert umrechnen und in einem neuen Objekt speichern.
Im Log (grüne Zeile) sieht man, dass der Wert von "SAMPLE" zwischendurch korrekt berechnet wird. Im PersistentStorage und im Log wird immer der gleich Werte angezeigt.
Ich komme einfach nicht mehr weiter. Vielleicht hat hier jemand eine Idee.
Manfred
Linknx Version
# linknx -V
linknx 0.0.1.32
- E-mail gateway enabled (with pthread support)
- LUA scripting support enabled
- Log4cpp logging enabled
Objektdefinition
<object type="9.xxx" id="SAMPLE" gad="9/3/0" init="persist" log="true" flags="cwtuf">Sample</object>
Regel
<rule id="TEST">
<condition type="timer" trigger="true">
<every>10s</every> <!-- alle 5 Min -->
</condition>
<actionlist type="if-true">
<action type="script">
function round(num, idp)
local mult = 10^(idp or 0);
return math.floor(num * mult + 0.5) / mult;
end;
value = round(tonumber(14229.8 + tonumber(obj("EG_TECH_ZA2_DA")) / 1000),2);
print ("value = ", value);
set("SAMPLE", value);
</action>
</actionlist>
</rule>
Logdatei
2015-05-17 10:12:57,674 INFO > Rule - Evaluate rule TEST
2015-05-17 10:12:57,674 INFO > Condition - TimerCondition evaluated as '0'
2015-05-17 10:12:57,674 INFO > Rule - Rule TEST evaluated as 0, prev value was 1
2015-05-17 10:12:57,674 DEBUG > Rule - Action list 'false' executed for rule TEST
2015-05-17 10:12:57,674 INFO > PeriodicTask - Rescheduled at 2015-5-17 10:13:07 (1431850387)
2015-05-17 10:12:57,674 INFO > Action - Execute LuaScriptAction
2015-05-17 10:12:57,674 DEBUG > LuaScriptAction - Getting object with id=EG_TECH_ZA2_DA
2015-05-17 10:12:57,674 DEBUG > Object - Object (id=EG_TECH_ZA2_DA): get
2015-05-17 10:12:57,674 DEBUG > LuaScriptAction - Object 'EG_TECH_ZA2_DA' has value '16322488'
2015-05-17 10:12:57,675 DEBUG > LuaScriptAction - Setting object with id=SAMPLE
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > KnxConnection - write(gad=9/3/0, buf, len=4)
2015-05-17 10:12:57,675 DEBUG > KnxConnection - Write request sent
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > Object - New value 30535.68 for object SAMPLE (type: 9.xxx)
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > FilePersistentStorage - Writing '30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > FilePersistentStorage - Writing log'30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,675 DEBUG > LuaScriptAction - Object 'SAMPLE' set to value '30552.29'
2015-05-17 10:12:57,715 DEBUG > KnxConnection - Write from 0.0.0 to 9/3/0: 5d d3
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > Object - New value 30535.68 for object SAMPLE (type: 9.xxx)
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > FilePersistentStorage - Writing '30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > FilePersistentStorage - Writing log'30535.68' for object 'SAMPLE'
ich habe eine Problem mit linknx und Lua script. Ich möchte den Stromverbrauch von einem Zählerwert in einen Verbrauchswert umrechnen und in einem neuen Objekt speichern.
Im Log (grüne Zeile) sieht man, dass der Wert von "SAMPLE" zwischendurch korrekt berechnet wird. Im PersistentStorage und im Log wird immer der gleich Werte angezeigt.
Ich komme einfach nicht mehr weiter. Vielleicht hat hier jemand eine Idee.
Manfred
Linknx Version
# linknx -V
linknx 0.0.1.32
- E-mail gateway enabled (with pthread support)
- LUA scripting support enabled
- Log4cpp logging enabled
Objektdefinition
<object type="9.xxx" id="SAMPLE" gad="9/3/0" init="persist" log="true" flags="cwtuf">Sample</object>
Regel
<rule id="TEST">
<condition type="timer" trigger="true">
<every>10s</every> <!-- alle 5 Min -->
</condition>
<actionlist type="if-true">
<action type="script">
function round(num, idp)
local mult = 10^(idp or 0);
return math.floor(num * mult + 0.5) / mult;
end;
value = round(tonumber(14229.8 + tonumber(obj("EG_TECH_ZA2_DA")) / 1000),2);
print ("value = ", value);
set("SAMPLE", value);
</action>
</actionlist>
</rule>
Logdatei
2015-05-17 10:12:57,674 INFO > Rule - Evaluate rule TEST
2015-05-17 10:12:57,674 INFO > Condition - TimerCondition evaluated as '0'
2015-05-17 10:12:57,674 INFO > Rule - Rule TEST evaluated as 0, prev value was 1
2015-05-17 10:12:57,674 DEBUG > Rule - Action list 'false' executed for rule TEST
2015-05-17 10:12:57,674 INFO > PeriodicTask - Rescheduled at 2015-5-17 10:13:07 (1431850387)
2015-05-17 10:12:57,674 INFO > Action - Execute LuaScriptAction
2015-05-17 10:12:57,674 DEBUG > LuaScriptAction - Getting object with id=EG_TECH_ZA2_DA
2015-05-17 10:12:57,674 DEBUG > Object - Object (id=EG_TECH_ZA2_DA): get
2015-05-17 10:12:57,674 DEBUG > LuaScriptAction - Object 'EG_TECH_ZA2_DA' has value '16322488'
2015-05-17 10:12:57,675 DEBUG > LuaScriptAction - Setting object with id=SAMPLE
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > KnxConnection - write(gad=9/3/0, buf, len=4)
2015-05-17 10:12:57,675 DEBUG > KnxConnection - Write request sent
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > Object - New value 30535.68 for object SAMPLE (type: 9.xxx)
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > FilePersistentStorage - Writing '30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,675 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,675 INFO > FilePersistentStorage - Writing log'30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,675 DEBUG > LuaScriptAction - Object 'SAMPLE' set to value '30552.29'
2015-05-17 10:12:57,715 DEBUG > KnxConnection - Write from 0.0.0 to 9/3/0: 5d d3
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > Object - New value 30535.68 for object SAMPLE (type: 9.xxx)
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > FilePersistentStorage - Writing '30535.68' for object 'SAMPLE'
2015-05-17 10:12:57,715 DEBUG > Object - Object (id=SAMPLE): get
2015-05-17 10:12:57,715 INFO > FilePersistentStorage - Writing log'30535.68' for object 'SAMPLE'
Kommentar