Browse code

Am redus la 20 de secunde timp de dupa start in care nu proceseaza LWT Am adaugat procesarea mesajelor de uptime

Liviu Pislaru authored on 08/03/2018 21:55:46
Showing 2 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/perl
2 2
 # parser pentru mesajele MQTT
3
-# Version: 1.1.0
3
+# Version: 1.1.1
4 4
 
5 5
 use strict;
6 6
 use warnings;
... ...
@@ -63,7 +63,7 @@ while (my $mqttMessage = <$SUB> ) {
63 63
         my $curtime = strftime("%s", localtime(time));
64 64
         my $uptime = $curtime-$startime;
65 65
         # nu procesez retained LWT cand pornesc mqttparser 
66
-        if ($uptime>60){ 
66
+        if ($uptime>20){ 
67 67
           # stergem consumul pentru azi si ieri cand este offline priza
68 68
           if ($nonjson eq 'Offline') {
69 69
             delDB($topic);
... ...
@@ -122,9 +122,6 @@ while (my $mqttMessage = <$SUB> ) {
122 122
       }
123 123
       if (index($queue, "INFO") != -1) {
124 124
         my $decoded = decode_json($json);
125
-        if (exists $decoded->{'Temp'}){
126
-
127
-        }
128 125
         if (exists $decoded->{'Module'}){
129 126
           addDB ($topic, "Module", $decoded->{'Module'});
130 127
         }
... ...
@@ -138,6 +135,12 @@ while (my $mqttMessage = <$SUB> ) {
138 138
           addDB ($topic, "RestartReason", $decoded->{'RestartReason'});
139 139
         }
140 140
       } 
141
+      if ($queue eq "STATE"){
142
+        my $decoded = decode_json($json);
143
+        if (exists $decoded->{'Uptime'}) {
144
+          addDB ($topic, "Uptime", $decoded->{'Uptime'});
145
+        }  
146
+      }
141 147
       if ($queue eq "ALARM"){
142 148
         $json=~ s/\"/\\"/g;
143 149
         my $script="php /admin/scripts/mqttparser/alarm.php $topic $json";
... ...
@@ -17,4 +17,5 @@ tele/64x35up-2452/INFO1 {<strong>"Module":"Sonoff Pow"</strong>,<strong>"Version
17 17
 tele/64x35up-2452/INFO2 {"WebServerMode":"Admin","Hostname":"64x35up-2452-2452",<strong>"IPAddress":"192.168.23.146"</strong>}<br>
18 18
 tele/64x35up-2452/INFO3 {<strong>"RestartReason":"Power on"</strong>}<br>
19 19
 tele/mng9184-1657/ENERGY {"Time":"2018-03-04T21:53:50","Total":1387.609,<strong>"Yesterday":23.704</strong>,<strong>"Today":27.064</strong>,"Period":103,"Power":1254,"Factor":1.00,"Voltage":236,"Current":5.262}<br>
20
+tele/1mining-7408/STATE {"Time":"2018-03-08T20:44:13",<strong>"Uptime":28</strong>,"Vcc":3.147,"POWER":"ON","Wifi":{"AP":1,"SSId":"ICS","RSSI":100,"APMac":"70:4F:57:8C:41:EC"}}<br>
20 21
 </p>