Browse code

Am finalizat toate update-urile in DB pentru mqttparser.

Liviu Pislaru authored on 05/03/2018 17:02:43
Showing 2 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 #!/usr/bin/perl
2 2
 # parser pentru mesajele MQTT
3
-# Version: 1.0.5
3
+# Version: 1.0.6
4 4
 
5 5
 use strict;
6 6
 use warnings;
... ...
@@ -92,7 +92,40 @@ while (my $mqttMessage = <$SUB> ) {
92 92
         if (exists $decoded->{'Humi'}){      
93 93
           addFILE ($topic, "Humi", $decoded->{'Humi'});
94 94
         }
95
+        if (exists $decoded->{'Module'}){
96
+          addDB ($topic, "Module", $decoded->{'Module'});
97
+        }
98
+        if (exists $decoded->{'Version'}){   
99
+          addDB ($topic, "Version", $decoded->{'Version'});      
100
+        }
101
+        if (exists $decoded->{'ESPMac'}){  
102
+          addDB ($topic, "ESPMac", $decoded->{'ESPMac'});      
103
+        }                  
104
+        if (exists $decoded->{'IPAddress'}){   
105
+          addDB ($topic, "IPAddress", $decoded->{'IPAddress'});  
106
+        }
107
+        if (exists $decoded->{'LoopInterval'}){
108
+          addDB ($topic, "LoopInterval", $decoded->{'LoopInterval'});
109
+        }        
95 110
       }
111
+      if (index($queue, "INFO") != -1) {
112
+        my $decoded = decode_json($json);
113
+        if (exists $decoded->{'Temp'}){
114
+
115
+        }
116
+        if (exists $decoded->{'Module'}){
117
+          addDB ($topic, "Module", $decoded->{'Module'});
118
+        }
119
+        if (exists $decoded->{'Version'}){
120
+          addDB ($topic, "Version", $decoded->{'Version'});
121
+        }
122
+        if (exists $decoded->{'IPAddress'}){
123
+          addDB ($topic, "IPAddress", $decoded->{'IPAddress'});
124
+        }
125
+        if (exists $decoded->{'RestartReason'}){                   
126
+          addDB ($topic, "RestartReason", $decoded->{'RestartReason'});
127
+        }
128
+      } 
96 129
     }
97 130
   }
98 131
   else {
... ...
@@ -5,24 +5,13 @@ tele/quyhgw-1880/LWT Online
5 5
 
6 6
 2. JSON:
7 7
 stat/jbkots-1673/ESP {"Temp":23.87}
8
-stat/64x35up-1790/TEMP {"Temp":23.30, "Humi":41.00}
9
-tele/mng9184-1657/ENERGY {"Time":"2018-03-04T21:53:50","Total":1387.609,"Yesterday":23.704,"Today":27.064,"Period":103,"Power":1254,"Factor":1.00,"Voltage":236,"Current":5.262}
10
-
11
-Mesaje (inca) neprocesate:
8
+stat/qbzesh-1250/ESP {"Temp":23.30, "Humi":41.00}
9
+stat/qbzesh-1250/ESP {"Module":"NodeMCU DHT22","Version":"v2.0.1"}
10
+stat/qbzesh-1250/ESP {"ESPMac":"2C-3A-E8-3D-E8-2B","IPAddress":"192.168.1.35"}
11
+stat/qbzesh-1250/ESP {"LoopInterval":"15 minute"}
12 12
 
13
-1. NON JSON:
14
-
15
-2. JSON:
16
-stat/qbzesh-1432/ESP {"ESPMac":"2C-3A-E8-3D-E7-DD", "IPAddress":"192.168.1.141"}
17
-tele/mng9184-1657/STATE {"Time":"2018-03-04T21:53:50","Uptime":75,"Vcc":3.189,"POWER":"ON","Wifi":{"AP":1,"SSId":"ICS","RSSI":74,"APMac":"70:4F:57:8C:41:EC"}}
18
-stat/64x35up-1577/STATUS8 {"StatusPWR":{"Total":335.776, "Yesterday":27.194, "Today":24.761, "Power":1161, "Factor":1.00, "Voltage":220, "Current":4.902}}
13
+tele/64x35up-2452/INFO1 {"Module":"Sonoff Pow","Version":"5.10.0","FallbackTopic":"DVES_3B4994","GroupTopic":"sonoffs"}
14
+tele/64x35up-2452/INFO2 {"WebServerMode":"Admin","Hostname":"64x35up-2452-2452","IPAddress":"192.168.23.146"}
15
+tele/64x35up-2452/INFO3 {"RestartReason":"Power on"}
19 16
 
20
-
21
-TODO:
22
-
23
-1. De trimis ca JSON:
24
-stat/64x35up-1791/ESP 15 minute
25
-
26
-2. De sters spatiile din JSON:
27
-stat/rqx958t-3422/ESP {"ESPMac":"DC-4F-22-18-25-39", "IPAddress":"192.168.1.46"}
28
-stat/64x35up-1790/TEMP {"Temp":23.30, "Humi":41.00}
17
+tele/mng9184-1657/ENERGY {"Time":"2018-03-04T21:53:50","Total":1387.609,"Yesterday":23.704,"Today":27.064,"Period":103,"Power":1254,"Factor":1.00,"Voltage":236,"Current":5.262}