rules question - variable not updated?
Posted: 14 Dec 2020, 14:33
hi,
I am trying to set up a time and pulses counting mechanism for a GPIO state.
have currently the following rule:
now it is looking like the VAR#4 is not updated properly. the following log makes me thinking this:
on line 991017 it is trying to set VAR#4 to 1607951544
on line 993054 that [VAR#4] is 1607951488.00 - I think this is from a previous run - Why? I reset it at GPIO state change to 0 to 0
on line 993060 it is trying to set VAR#4 to 1607951546
on line 1023149 [VAR#4] is still at 1607951488.00 - Why?
on line 1023156 it is trying to set VAR#4 to 1607951576
on line 1053244 now [VAR#4] is at 1607951616.00 - Why?
on line 1023156 it is trying to set VAR#4 to 1607951606
on line 1023149 [VAR#4] is still at 1607951616.00 - Why
did I do something wrong, or why it does not work?
have also tried to put the calculation in brackets e.g. Let,1,([VAR#1]+%unixtime%-[VAR#4]) - but this did not help.
I am using ESP_Easy_mega_20201102_normal_ESP8266_4M1M on a Wemos D1 mini.
Thanks!
BR
Alois
I am trying to set up a time and pulses counting mechanism for a GPIO state.
have currently the following rule:
Code: Select all
On System#Boot do
Monitor GPIO,2
timerSet,1,30
Let,1,0 // counting seconds
Let,2,0 // GPIO state
Let,3,0 // counting pulses
Let,4,0 // unixtime last secondcalculation
endon
On Clock#Time=All,00:01 do
Let,1,0
Let,3,0
EndOn
on GPIO#2=1 do
if [VAR#2] = 0
Let,2,1
Let,3,[VAR#3]+1
if [VAR#4] = 0
Let,4,%unixtime%
else
Let,1,[VAR#1]+%unixtime%-[VAR#4]
endif
timerSet,1,2
endif
endon
on GPIO#2=0 do
if [VAR#2] = 1
Let,2,0
Let,1,[VAR#1]+%unixtime%-[VAR#4]
Let,4,0
endif
timerSet,1,2
endon
On Rules#Timer=1 do
if [Plugin#GPIO#Pinstate#2] = 1
Let,1,[VAR#1]+%unixtime%-[VAR#4]
Let,4,%unixtime%
endif
SendToHTTP,192.168.0.250,80,/humidity.php?mac=%mac%&rssi=%rssi%&temperature=[Temperature#Temperature]
SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=%sysname%&ipv4=%ip%&uptime=%uptime%&load=%sysload%&freeram=%sysheap%&rssi=%rssi%&tempsens=[Temperature#Temperature]&rulesruntime=[Var#1]&rulespulses=[Var#3]
timerSet,1,30
endon
Code: Select all
953015: HTTP: status,GPIO,2
959149: DS : Temperature: 26.31 (28-b0-46-56-b5-1-3c-ed)
959193: EVENT: Temperature#Temperature=16.31
961991: WD : Uptime 16 ConnectFailures 0 FreeMem 21448 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
966436: EVENT: Clock#Time=Mon,14:12
971752: EVENT: Rules#Timer=1,1
971789: ACT : SendToHTTP,192.168.0.250,80,/humidity.php?mac=EC:FA:BC:A7:CF:67&rssi=-71&temperature=16.31
971819: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=Spieleraumheizung&ipv4=192.168.10.243&uptime=16&load=6.85&fre
971836: ACT : timerSet,1,30
979965: DS : Temperature: 26.31 (28-b0-46-56-b5-1-3c-ed)
979993: EVENT: Temperature#Temperature=16.31
983020: HTTP: status,GPIO,2
990953: HTTP: GPIO,2,1
990960: GPIO : port#2: set to 1
990994: EVENT: GPIO#2=1
991007: ACT : Let,2,1
991011: ACT : Let,3,2.00+1
991017: ACT : Let,4,1607951544
991025: ACT : timerSet,1,2
991533: HTTP: status,GPIO,2
991991: WD : Uptime 17 ConnectFailures 0 FreeMem 21448 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
993027: EVENT: Rules#Timer=1,1
993054: ACT : Let,1,512.00+1607951546-1607951488.00
993060: ACT : Let,4,1607951546
993070: ACT : SendToHTTP,192.168.0.250,80,/humidity.php?mac=EC:FA:BC:A7:CF:67&rssi=-71&temperature=16.31
993101: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=Spieleraumheizung&ipv4=192.168.10.243&uptime=17&load=7.30&fre
993117: ACT : timerSet,1,30
1000781: DS : Temperature: 26.38 (28-b0-46-56-b5-1-3c-ed)
1000793: EVENT: Temperature#Temperature=16.38
1013014: HTTP: status,GPIO,2
1021597: DS : Temperature: 26.31 (28-b0-46-56-b5-1-3c-ed)
1021603: EVENT: Temperature#Temperature=16.31
1021991: WD : Uptime 17 ConnectFailures 0 FreeMem 21472 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
1023121: EVENT: Rules#Timer=1,1
1023149: ACT : Let,1,512.00+1607951576-1607951488.00
1023156: ACT : Let,4,1607951576
1023165: ACT : SendToHTTP,192.168.0.250,80,/humidity.php?mac=EC:FA:BC:A7:CF:67&rssi=-71&temperature=16.31
1023196: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=Spieleraumheizung&ipv4=192.168.10.243&uptime=17&load=7.14&fre
1023213: ACT : timerSet,1,30
1026436: EVENT: Clock#Time=Mon,14:13
1042413: DS : Temperature: 26.31 (28-b0-46-56-b5-1-3c-ed)
1042493: EVENT: Temperature#Temperature=16.31
1043074: HTTP: status,GPIO,2
1051991: WD : Uptime 18 ConnectFailures 0 FreeMem 21472 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
1053216: EVENT: Rules#Timer=1,1
1053244: ACT : Let,1,640.00+1607951606-1607951616.00
1053250: ACT : Let,4,1607951606
1053259: ACT : SendToHTTP,192.168.0.250,80,/humidity.php?mac=EC:FA:BC:A7:CF:67&rssi=-70&temperature=16.31
1053291: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=Spieleraumheizung&ipv4=192.168.10.243&uptime=18&load=7.04&fre
1053309: ACT : timerSet,1,30
1063229: DS : Temperature: 26.38 (28-b0-46-56-b5-1-3c-ed)
1063293: EVENT: Temperature#Temperature=16.38
1073040: HTTP: status,GPIO,2
1081991: WD : Uptime 18 ConnectFailures 0 FreeMem 21472 WiFiStatus WL_CONNECTED ESPeasy internal wifi status: Conn. IP Init
1083312: EVENT: Rules#Timer=1,1
1083364: ACT : Let,1,640.00+1607951636-1607951616.00
1083370: ACT : Let,4,1607951636
1083380: ACT : SendToHTTP,192.168.0.250,80,/humidity.php?mac=EC:FA:BC:A7:CF:67&rssi=-70&temperature=16.38
1083411: ACT : SendToHTTP,192.168.0.250,80,/apcucollector.php?smartswitch=Spieleraumheizung&ipv4=192.168.10.243&uptime=18&load=7.09&fre
1083427: ACT : timerSet,1,30
on line 993054 that [VAR#4] is 1607951488.00 - I think this is from a previous run - Why? I reset it at GPIO state change to 0 to 0
on line 993060 it is trying to set VAR#4 to 1607951546
on line 1023149 [VAR#4] is still at 1607951488.00 - Why?
on line 1023156 it is trying to set VAR#4 to 1607951576
on line 1053244 now [VAR#4] is at 1607951616.00 - Why?
on line 1023156 it is trying to set VAR#4 to 1607951606
on line 1023149 [VAR#4] is still at 1607951616.00 - Why
did I do something wrong, or why it does not work?
have also tried to put the calculation in brackets e.g. Let,1,([VAR#1]+%unixtime%-[VAR#4]) - but this did not help.
I am using ESP_Easy_mega_20201102_normal_ESP8266_4M1M on a Wemos D1 mini.
Thanks!
BR
Alois