Last modified by Hera Guo on 2024/11/11 17:08

From version 61.1
edited by Hera Guo
on 2024/11/07 10:21
Change comment: There is no comment for this version
To version 18.1
edited by Hera Guo
on 2024/11/04 17:42
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,4 @@
1 - **Table of Contents:**
1 +**Table of Contents:**
2 2  
3 3  {{toc/}}
4 4  
... ... @@ -5,9 +5,6 @@
5 5  
6 6  
7 7  
8 -
9 -
10 -
11 11  = 1. About this demo =
12 12  
13 13  This demo is to show the installation for various sensors in Dragino Office, Dragino Facotry & ThingsEye Office. It covers various types of sensors such as Temperature, Humidity, CO2, Water Flow, Vibration & many many.
... ... @@ -60,7 +60,7 @@
60 60  
61 61  **device:**This section displays the specific information collected by the device, and different types of sensors have different display interfaces
62 62  
63 -[[image:屏幕截图 2024-11-04 134645.png]]
60 +[[image:1730699212334-960.png]]
64 64  
65 65  First floor:
66 66  
... ... @@ -85,7 +85,7 @@
85 85  
86 86  High Temperature、Low Temperature、High humidity、Low humidity、Low voltage、Device Disconnected
87 87  
88 -[[image:屏幕截图 2024-11-04 135045.png]]
85 +[[image:1730699566023-958.png]]
89 89  
90 90  = 4.configuration details =
91 91  
... ... @@ -95,521 +95,64 @@
95 95  
96 96  === 4.1.1.Data source (Entity aliases) ===
97 97  
98 -detail:Obtain data based on dashboard status
95 +Asset map:
99 99  
100 -[[image:1730709424998-915.png||height="729" width="1436"]]
97 +[[image:1730709409941-536.png||height="729" width="1440"]]
101 101  
102 -Alarm:Obtain alarm information
99 +detail:
103 103  
104 -[[image:1730709479828-595.png||height="696" width="1435"]]
101 +[[image:1730709424998-915.png||height="729" width="1436"]]
105 105  
106 -Dragino&GXHL,Ltd:Obtain data through asset types
103 +devid:
107 107  
108 -[[image:1730709511861-439.png||height="714" width="1435"]]
105 +[[image:1730709442773-502.png||height="738" width="1434"]]
109 109  
110 -Selected Supermarket:Retrieve devices by device type
107 +State:
111 111  
112 -[[image:1730709527720-418.png||height="751" width="1433"]]
109 +[[image:1730709461297-207.png||height="706" width="1434"]]
113 113  
114 -Supermarket Devices:Obtain data through device type
111 +Alarm:
115 115  
116 -[[image:1730709555797-383.png||height="726" width="1434"]]
113 +[[image:1730709479828-595.png||height="696" width="1435"]]
117 117  
118 -LHT65N Device:Obtain data based on device type
115 +Dragino&GXHL,Ltd:
119 119  
120 -[[image:1730857191863-514.png||height="725" width="1433"]]
117 +[[image:1730709511861-439.png||height="714" width="1435"]]
121 121  
122 -=== 4.1.2.Page Configuration ===
119 +Selected Supermarket:
123 123  
124 -==== 4.1.2.1、Configure the interface of the third layer Davies. ====
121 +[[image:1730709527720-418.png||height="751" width="1433"]]
125 125  
126 -==== 4.1.2.2、Configure the interface of the second layer asset ====
123 +Supermarkets:
127 127  
128 -===== 4.1.2.2.1 Equipment distribution diagram: =====
125 +[[image:1730709542597-321.png||height="734" width="1435"]]
129 129  
130 -**Data:**
127 +Supermarket Devices:
131 131  
132 -[[image:1730770392454-317.png||height="745" width="1439"]]
129 +[[image:1730709555797-383.png||height="726" width="1434"]]
133 133  
134 -**Appearannce:**In this module, we need to arrange our devices in the corresponding positions and use icons to display our devices. Therefore, in the Appearance interface, we need to configure them
135 135  
136 -**Tooltip function:**This module displays the current information of the device
132 +=== 4.1.2.Page Configuration ===
137 137  
138 -[[image:1730857537965-184.png]]
134 +1、Configure the interface of the third layer Davies.
139 139  
140 -{{code language="none"}}
141 -var msg = data
142 -if(msg.Label=="gateway" && msg.type == "gateway"){
143 - var stauts
144 - if (msg.gatewaystauts=="true"){
145 - stauts = "Connect"
146 - }
147 - else{
148 - stauts = "Disconnected"
149 - }
150 - var str = "<b>"+msg.entityName+"</b><br/><b>"+stauts+"</b><br/>"
151 - return str
152 -}
153 -else if(msg.type=="gxhl01" && msg.Label!="gateway"){
154 - var str = "<b>"+msg.entityName+"</b><br/><b>"+msg.Label+"</b><br/><b>Bat:</b>"+msg.BatV+"V<br/><b>Temperature:</b>"+ msg.TempC_SHT+ "°C<br/><b>Humidity:</b>"+msg.Hum_SHT+"%"
155 - return str
156 -}
157 -else{
158 - var str = "<b>"+msg.entityName+"</b><br/><b>"+msg.Label+"</b><br/><b>Bat:</b>"+msg.BatV+"V<br/><b>Temperature:</b>"+ msg.temperature+ "°C<br/><b>Humidity:"+msg.humidity+"%"+"</b><br/>"+
159 - "<b>Co2:"+msg.co2+"</b></br><b>Air_Pressure:"+msg.air_pressure
160 -
161 - return str
162 -}
163 -{{/code}}
164 164  
165 -(% class="wikigeneratedid" id="HMarkerimagefunctionFF1A" %)
166 -**Marker image function:**This module can display different icons based on different types of sensors and their status to achieve its functionality
137 +2、Configure the interface of the second layer asset
167 167  
168 -(% class="wikigeneratedid" %)
169 -[[image:1730857750749-240.png]]
170 170  
171 -{{code language="none"}}
172 -var res
173 -var msg = data
174 -if(msg.Label=="gateway" && msg.type=="gateway"){
175 - if (msg.gatewaystauts == "true"){
176 - res = {
177 - url: images[3],
178 - size: 40
179 -}
180 -}
181 -else{
182 - res = {
183 - url: images[2],
184 - size: 40
185 -}
186 -}}
187 -else if(msg.Label!="gateway" && msg.type=="gxhl01" ){
188 - if (msg.active=="false"){
189 - res = {
190 - url: images[1],
191 - size: 40
192 -}}
193 -else{
194 - res = {
195 - url: images[0],
196 - size: 40
197 -}
198 -}
199 -}
200 -else if(msg.type=="LWL02"){
201 - if (msg.WATER_LEAK_STATUS=="0"){
202 - res = {
203 - url: images[6],
204 - size: 40
205 -}}
206 -else{
207 - res = {
208 - url: images[7],
209 - size: 40
210 -}
211 -}
212 -}
213 -else if(msg.type=="LDS02"){
214 - if (msg.DOOR_OPEN_STATUS=="0"){
215 - res = {
216 - url: images[5],
217 - size: 40
218 -}}
219 -else{
220 - res = {
221 - url: images[8],
222 - size: 40
223 -}
224 -}
225 -}
226 -else if(msg.type=="LDS12"){
227 - res = {
228 - url: images[10],
229 - size: 40
230 -}}
231 -else if(msg.type=="SE01"){
232 - res = {
233 - url: images[9],
234 - size: 40
235 -}}
236 -else if(msg.type=="PB01"){
237 - res = {
238 - url: images[11],
239 - size: 40
240 -}}
241 -else if(msg.type=="S31b"){
242 - res = {
243 - url: images[12],
244 - size: 40
245 -}}
246 -else if(msg.type=="LHT65N"){
247 - res = {
248 - url: images[13],
249 - size: 40
250 -}}
251 -else{
252 - res = {
253 - url: images[4],
254 - size: 40
255 -}
256 -}
257 -return res;
258 -{{/code}}
140 +3、Configure the first layer menu interface
259 259  
260 -(% class="wikigeneratedid" %)
261 -[[image:1730770875793-351.png||height="799" width="1474"]]
142 +Map:
262 262  
263 -(% class="wikigeneratedid" %)
264 -**Actions:**We need to implement the function of entering the details interface through the corresponding device icon, so in this module, we need to add actions to achieve redirection
144 +Data:
265 265  
266 -{{code language="none"}}
267 -var entitySubType;
268 -var $injector = widgetContext.$scope.$injector;
269 -$injector.get(widgetContext.servicesMap.get('entityService')).getEntity(entityId.entityType, entityId.id)
270 - .subscribe(function(data) {
271 - entitySubType = data.type;
272 - console.log(entitySubType)
273 - if (entitySubType == 'gateway') {
274 - openDashboardStates('gateway_detail');
275 - } else if (entitySubType == 'gxhl01') {
276 - openDashboardStates('detail');
277 - }
278 - else if(entitySubType == 'AQS01-dragino-office'){
279 - openDashboardStates("aqs01_detail")
280 - }
281 - else if (entitySubType == 'LDS12') {
282 - openDashboardStates('lds12_detail');
283 - }
284 - else if (entitySubType == 'LDS02') {
285 - openDashboardStates('lds02_detail');
286 - }
287 - else if (entitySubType == 'SE01') {
288 - openDashboardStates('se01_detail');
289 - }
290 - else if (entitySubType == 'PB01') {
291 - openDashboardStates('pb01_detail');
292 - }
293 - else if (entitySubType == 'LWL02') {
294 - openDashboardStates('lwl02_detail');
295 - }
296 - else if (entitySubType == 'LPS8N') {
297 - openDashboardStates('lps8n_detail');
298 - }
299 - else if (entitySubType == 'LHT65N') {
300 - openDashboardStates('lht65n_detail');
301 - }
302 - else if (entitySubType == 'S31b') {
303 - openDashboardStates('s31b_detail');
304 - }
305 - });
146 +[[image:1730710271230-716.png||height="729" width="1427"]]
306 306  
307 -function openDashboardStates(statedId) {
308 - var stateParams = widgetContext.stateController.getStateParams();
309 - var params = {
310 - entityId: entityId,
311 - entityName: entityName
312 - };
148 +Actions:The map interface has two actions, among which Select supermarket can refresh the device list and related alarms on the right side to enter the location, and Supermarket_detail can jump to the second level physical interface to view the details of the location based on the selected location
313 313  
314 - if (stateParams.city) {
315 - params.city = stateParams.city;
316 - }
317 -
318 - widgetContext.stateController.openState(statedId, params, false);
319 -}
320 -
321 -{{/code}}
322 -
323 -[[image:1730771103096-522.png||height="815" width="1503"]]
324 -
325 -===== 4.1.2.2.2 Device List =====
326 -
327 -(% class="wikigeneratedid" id="HDataFF1A" %)
328 -**Data:**
329 -
330 -[[image:1730771199343-553.png||height="802" width="1501"]]
331 -
332 -**Actions:**Equipment distribution diagram: In this module, functions need to be implemented such as adding devices, editing devices, deleting devices, and jumping to the device details page. Therefore, the following actions need to be added:
333 -
334 -[[image:1730771228766-212.png]]
335 -
336 -(% class="wikigeneratedid" id="HEditdeviceFF1A" %)
337 -**Edit device:**Implementation function: Device editing
338 -
339 -[[image:1730771256045-238.png]]
340 -
341 -{{code language="none"}}
342 -let $injector = widgetContext.$scope.$injector;
343 -let customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));
344 -let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
345 -let attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));
346 -
347 -openEditDeviceDialog();
348 -
349 -function openEditDeviceDialog() {
350 - customDialog.customDialog(htmlTemplate, EditDeviceDialogController).subscribe();
351 -}
352 -
353 -function EditDeviceDialogController(instance) {
354 - let vm = instance;
355 -
356 - vm.device = null;
357 - vm.attributes = {};
358 -
359 - vm.editDeviceFormGroup = vm.fb.group({
360 - deviceName: ['', [vm.validators.required]],
361 - deviceType: ['', [vm.validators.required]],
362 - deviceLabel: [''],
363 - attributes: vm.fb.group({
364 - latitude: [null],
365 - longitude: [null]
366 - })
367 - });
368 -
369 - vm.cancel = function() {
370 - vm.dialogRef.close(null);
371 - };
372 -
373 - vm.save = function() {
374 - vm.editDeviceFormGroup.markAsPristine();
375 - if (vm.editDeviceFormGroup.get('deviceType').value !== vm.device.type) {
376 - delete vm.device.deviceProfileId;
377 - }
378 - vm.device.name = vm.editDeviceFormGroup.get('deviceName').value,
379 - vm.device.type = vm.editDeviceFormGroup.get('deviceType').value,
380 - vm.device.label = vm.editDeviceFormGroup.get('deviceLabel').value
381 - deviceService.saveDevice(vm.device).subscribe(
382 - function () {
383 - saveAttributes().subscribe(
384 - function () {
385 - widgetContext.updateAliases();
386 - vm.dialogRef.close(null);
387 - }
388 - );
389 - }
390 - );
391 - };
392 -
393 - getEntityInfo();
394 -
395 - function getEntityInfo() {
396 - deviceService.getDevice(entityId.id).subscribe(
397 - function (device) {
398 - attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',
399 - ['latitude', 'longitude']).subscribe(
400 - function (attributes) {
401 - for (let i = 0; i < attributes.length; i++) {
402 - vm.attributes[attributes[i].key] = attributes[i].value;
403 - }
404 - vm.device = device;
405 - vm.editDeviceFormGroup.patchValue(
406 - {
407 - deviceName: vm.device.name,
408 - deviceType: vm.device.type,
409 - deviceLabel: vm.device.label,
410 - attributes: {
411 - latitude: vm.attributes.latitude,
412 - longitude: vm.attributes.longitude
413 - }
414 - }, {emitEvent: false}
415 - );
416 - }
417 - );
418 - }
419 - );
420 - }
421 -
422 - function saveAttributes() {
423 - let attributes = vm.editDeviceFormGroup.get('attributes').value;
424 - let attributesArray = [];
425 - for (let key in attributes) {
426 - attributesArray.push({key: key, value: attributes[key]});
427 - }
428 - if (attributesArray.length > 0) {
429 - return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);
430 - } else {
431 - return widgetContext.rxjs.of([]);
432 - }
433 - }
434 -}
435 -{{/code}}
436 -
437 -**Delete device:**Implementation function: Device deletion
438 -
439 -[[image:1730771318657-502.png]]
440 -
441 -{{code language="none"}}
442 -let $injector = widgetContext.$scope.$injector;
443 -let dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));
444 -let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
445 -
446 -openDeleteDeviceDialog();
447 -
448 -function openDeleteDeviceDialog() {
449 - let title = "Are you sure you want to delete the device " + entityName + "?";
450 - let content = "Be careful, after the confirmation, the device and all related data will become unrecoverable!";
451 - dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(
452 - function (result) {
453 - if (result) {
454 - deleteDevice();
455 - }
456 - }
457 - );
458 -}
459 -
460 -function deleteDevice() {
461 - deviceService.deleteDevice(entityId.id).subscribe(
462 - function () {
463 - widgetContext.updateAliases();
464 - }
465 - );
466 -}
467 -
468 -{{/code}}
469 -
470 -**jump:I**mplementation function: Jump to the device details page
471 -
472 -[[image:1730771386258-676.png]]
473 -
474 -{{code language="none"}}
475 -console.log(entityName)
476 -var entitySubType;
477 -var $injector = widgetContext.$scope.$injector;
478 -//console.log($injector)
479 -$injector.get(widgetContext.servicesMap.get('entityService')).getEntity(entityId.entityType, entityId.id)
480 - .subscribe(function(data) {
481 - console.log(data)
482 - entitySubType = data.type;
483 - console.log(entitySubType)
484 - if (entitySubType == 'AQS01-dragino-office') {
485 - openDashboardStates('aqs01_detail');
486 - }else if (entitySubType == 'gateway') {
487 - openDashboardStates('gateway_detail');
488 - } else if (entitySubType == 'gxhl01') {
489 - openDashboardStates('detail');
490 -
491 - } else if (entitySubType == 'tank-type1') {
492 - openDashboardStates('test1');
493 - }
494 - else if (entitySubType == 'LDS12') {
495 - openDashboardStates('lds12_detail');
496 - }
497 - else if (entitySubType == 'LDS02') {
498 - openDashboardStates('lds02_detail');
499 - }
500 - else if (entitySubType == 'SE01') {
501 - openDashboardStates('se01_detail');
502 - }
503 - else if (entitySubType == 'PB01') {
504 - openDashboardStates('pb01_detail');
505 - }
506 - else if (entitySubType == 'LWL02') {
507 - openDashboardStates('lwl02_detail');
508 - }
509 - else if (entitySubType == 'LPS8N') {
510 - openDashboardStates('lps8n_detail');
511 - }
512 - else if (entitySubType == 'LHT65N') {
513 - openDashboardStates('lht65n_detail');
514 - }
515 - else if (entitySubType == 'S31b') {
516 - openDashboardStates('s31b_detail');
517 - }
518 - });
519 -
520 -function openDashboardStates(statedId) {
521 - var stateParams = widgetContext.stateController.getStateParams();
522 - //console.log(stateParams)
523 - var params = {
524 - entityId: entityId,
525 - entityName: entityName
526 - };
527 - widgetContext.stateController.updateState(statedId, params, false);
528 -}
529 -{{/code}}
530 -
531 -(% class="wikigeneratedid" id="H-1" %)
532 -**Add device:**Implementation function: Add device
533 -
534 -[[image:1730771441589-122.png]]
535 -
536 -{{code language="none"}}
537 -let $injector = widgetContext.$scope.$injector;
538 -let customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));
539 -let deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));
540 -let attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));
541 -
542 -openAddDeviceDialog();
543 -
544 -function openAddDeviceDialog() {
545 - customDialog.customDialog(htmlTemplate, AddDeviceDialogController).subscribe();
546 -}
547 -
548 -function AddDeviceDialogController(instance) {
549 - let vm = instance;
550 -
551 - vm.addDeviceFormGroup = vm.fb.group({
552 - deviceName: ['', [vm.validators.required]],
553 - deviceType: ['', [vm.validators.required]],
554 - deviceLabel: [''],
555 - attributes: vm.fb.group({
556 - latitude: [null],
557 - longitude: [null]
558 - })
559 - });
560 -
561 - vm.cancel = function() {
562 - vm.dialogRef.close(null);
563 - };
564 -
565 - vm.save = function() {
566 - vm.addDeviceFormGroup.markAsPristine();
567 - let device = {
568 - name: vm.addDeviceFormGroup.get('deviceName').value,
569 - type: vm.addDeviceFormGroup.get('deviceType').value,
570 - label: vm.addDeviceFormGroup.get('deviceLabel').value
571 - };
572 - deviceService.saveDevice(device).subscribe(
573 - function (device) {
574 - saveAttributes(device.id).subscribe(
575 - function () {
576 - widgetContext.updateAliases();
577 - vm.dialogRef.close(null);
578 - }
579 - );
580 - }
581 - );
582 - };
583 -
584 - function saveAttributes(entityId) {
585 - let attributes = vm.addDeviceFormGroup.get('attributes').value;
586 - let attributesArray = [];
587 - for (let key in attributes) {
588 - attributesArray.push({key: key, value: attributes[key]});
589 - }
590 - if (attributesArray.length > 0) {
591 - return attributeService.saveEntityAttributes(entityId, "SERVER_SCOPE", attributesArray);
592 - } else {
593 - return widgetContext.rxjs.of([]);
594 - }
595 - }
596 -}
597 -{{/code}}
598 -
599 -==== ====
600 -
601 -===== 4.1.2.2.3 Asset Alarm: =====
602 -
603 -**Data:**
604 -
605 -[[image:1730771504586-433.png||height="762" width="1431"]]
606 -
607 -
608 -**Actions**:The map interface has two actions, among which Select supermarket can refresh the device list and related alarms on the right side to enter the location, and Supermarket_detail can jump to the second level physical interface to view the details of the location based on the selected location
609 -
610 610  [[image:1730710850458-781.png||height="770" width="1429"]]
611 611  
612 -**Select supermarket:**Implementation function: Refresh the side page
152 +Select supermarket:
613 613  
614 614  {{code language="none"}}
615 615  var params = widgetContext.stateController.getStateParams();
... ... @@ -624,7 +624,7 @@
624 624  
625 625  [[image:1730710875401-848.png||height="767" width="1429"]]
626 626  
627 -**Supermarket_detail:**Implementation function: Jump to the asset details page
167 +Supermarket_detail:
628 628  
629 629  {{code language="none"}}
630 630  var params = JSON.parse(JSON.stringify(widgetContext.stateController.getStateParams()));
... ... @@ -641,9 +641,7 @@
641 641  
642 642  [[image:1730710990334-601.png||height="772" width="1433"]]
643 643  
644 -* (((
645 -In this demo, exclusive map icons were set as follows:
646 -)))
184 +* In this demo, exclusive map icons were set as follows:
647 647  
648 648  {{code language="none"}}
649 649  var res = {
... ... @@ -655,418 +655,23 @@
655 655  
656 656  [[image:1730710395303-672.png||height="771" width="1438"]]
657 657  
658 -===== 4.1.2.3.2 Asset List: =====
196 +Asset List:
659 659  
660 -**Data:**
661 661  
662 662  [[image:1730710693066-349.png||height="772" width="1439"]]
663 663  
664 -**Actions:**The Assets List interface has an action, which is the same as the Supermarket_details in the Map. You can jump to the second level entity interface to view the details of the selected location based on its location
201 +Actions:The Assets List interface has an action, which is the same as the Supermarket_details in the Map. You can jump to the second level entity interface to view the details of the selected location based on its location
665 665  
666 666  [[image:1730712335338-750.png||height="751" width="1423"]]
667 667  
668 668  [[image:1730712473941-913.png||height="781" width="1422"]]
669 669  
670 -===== 4.1.2.3.3 All Alarms: =====
207 +All Alarms:
671 671  
672 672  [[image:1730712539209-554.png||height="764" width="1424"]]
673 673  
674 674  == 4.2 Alarm configuration details ==
675 675  
676 -=== 4.2.1 High temperature ===
677 -
678 -Creat:
679 -
680 -[[image:1730862483514-101.png||height="750" width="1407"]]
681 -
682 -Clear:
683 -
684 -[[image:1730862584519-902.png||height="758" width="1404"]]
685 -
686 -=== 4.2.2 Low Temperature ===
687 -
688 -Creat:
689 -
690 -[[image:1730863708259-750.png||height="752" width="1403"]]
691 -
692 -Clear:
693 -
694 -[[image:1730863750414-979.png||height="746" width="1403"]]
695 -
696 -=== 4.2.3 High humidity ===
697 -
698 -Creat:
699 -
700 -[[image:1730864045747-876.png||height="752" width="1396"]]
701 -
702 -Clear:
703 -
704 -[[image:1730864077395-395.png||height="735" width="1393"]]
705 -
706 -=== 4.2.4 Low humidity ===
707 -
708 -Creat:
709 -
710 -[[image:1730864117808-484.png||height="741" width="1392"]]
711 -
712 -Clear:
713 -
714 -[[image:1730864159071-895.png||height="745" width="1392"]]
715 -
716 -=== 4.2.5 Low voltage ===
717 -
718 -Creat:
719 -
720 -[[image:1730864207037-477.png||height="740" width="1388"]]
721 -
722 -Clear:
723 -
724 -[[image:1730864250506-111.png||height="735" width="1389"]]
725 -
726 -=== 4.2.6 Device Disconnected ===
727 -
728 -Creat:
729 -
730 -[[image:1730864293216-991.png||height="739" width="1387"]]
731 -
732 -Clear:
733 -
734 -[[image:1730864331859-740.png||height="735" width="1385"]]
735 -
736 736  == 4.3 Rule chain configuration details ==
737 737  
738 -[[image:1730864784118-474.png]]
739 -
740 -**Script:**Email configuration for sending device alarm information
741 -
742 -[[image:1730864676542-406.png||height="732" width="1384"]]
743 -
744 -{{code language="none"}}
745 -function locatime(timenumber){
746 - var date = new Date(timenumber)
747 - return date.toLocaleDateString() + ' ' + date.toLocaleTimeString()
748 -}
749 -var name = msg.name
750 -var devicename = msg.originatorName
751 -var label = msg.originatorLabel
752 -var status = msg.status
753 -var detaildata =JSON.parse(msg.details.data)
754 -var tempswitch
755 -
756 -if (name != "Device Disconnected") {
757 - //detaildata=JSON.parse(msg.details.data)
758 - if (detaildata.Temperature_alarm_switch == true) {
759 - tempswitch = "open"
760 - } else {
761 - tempswitch = "close"
762 - }
763 - var humswitch
764 - if (detaildata.Humidity_alarm_switch == true) {
765 - humswitch = "open"
766 - } else {
767 - humswitch = "close"
768 - }
769 - var batswitch
770 - if (detaildata.Voltage_alarm_switch == true) {
771 - batswitch = "open"
772 - } else {
773 - batswitch = "close"
774 - }
775 - var str2 = "<p>-- Temperature alarm switch status: " +
776 - tempswitch + "</p>" +
777 - "<p>-- Humidity alarm switch status: " + humswitch +
778 - "</p>" +
779 - "<p>-- Voltage alarm switch status: " + batswitch
780 -}
781 -
782 -if (name == "High Temperature" && status ==
783 - "ACTIVE_UNACK") {
784 - var emailstr =
785 - "<div><p><span style='color: black; font-weight: bold'>" +
786 - "Device " + label + " has alarm:</span></p>" +
787 - "<p><span style='color: red; font-weight: bold'>-- High Temperature Alarm</span></p>" +
788 - "<p>-- Current Temperature : " + detaildata
789 - .TempC_SHT + "</p><br>" +
790 - "<p>Device Configure:</p>" +
791 - "<p>-- Temperature Threshold : min: " + detaildata
792 - .Low_temperature_alarm + ", max: " + detaildata
793 - .High_temperature_alarm + "</p>" +
794 - "<p>-- Humidity Threshold: min: " + detaildata
795 - .Low_humidity_alarm + ", max:" + detaildata
796 - .High_humidity_alarm + "</p>" +
797 - "<p>-- Battery threshold: min: " + detaildata
798 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
799 - return {
800 - msg: {
801 - "data": emailstr
802 - },
803 - metadata: metadata,
804 - msgType: msgType
805 - };
806 -} else if (name == "Low Temperature" && status ==
807 - "ACTIVE_UNACK") {
808 - var emailstr =
809 - "<div><p><span style='color: black; font-weight: bold'>" +
810 - "Device " + label + " has alarm:</span></p>" +
811 - "<p><span style='color: red; font-weight: bold'>-- Low Temperature Alarm</span></p>" +
812 - "<p>-- Current Temperature : " + detaildata
813 - .TempC_SHT + "</p><br>" +
814 - "<p>Device Configure:</p>" +
815 - "<p>-- Temperature Threshold : min: " + detaildata
816 - .Low_temperature_alarm + ", max: " + detaildata
817 - .High_temperature_alarm + "</p>" +
818 - "<p>-- Humidity Threshold: min: " + detaildata
819 - .Low_humidity_alarm + ", max:" + detaildata
820 - .High_humidity_alarm + "</p>" +
821 - "<p>-- Battery threshold: min: " + detaildata
822 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
823 -
824 - return {
825 - msg: {
826 - "data": emailstr
827 - },
828 - metadata: metadata,
829 - msgType: msgType
830 - };
831 -
832 -} else if (name == "Device Disconnected" && status ==
833 - "ACTIVE_UNACK") {
834 - var time1 = locatime(Number(detaildata.lastActivityTime))
835 - //var time1 = detaildata.lastActivityTime
836 - // var chazhi = parseInt((detaildata.inactivityAlarmTime-detaildata.lastActivityTime)/1000/60)
837 - // var emailstr =
838 - // "<div><p><span style='color: red; font-weight: bold'>" +
839 - // "Device " + label + " has Alarm</span></p><p>Last activity time: "+time1+"</p><p>Last Uplink: 21"+"minutes ago</p></div>"
840 -
841 - var emailstr ="Device " + label + " has Alarm##Last activity time: "+time1+"##Last Uplink: 21minutes ago"
842 - var newType = "POST_TELEMETRY_REQUEST"
843 - return {
844 - msg:emailstr,
845 - metadata: metadata,
846 - msgType: newType
847 - }
848 -} else if (name == "High humidity" && status ==
849 - "ACTIVE_UNACK") {
850 - var emailstr =
851 - "<div><p><span style='color: black; font-weight: bold'>" +
852 - "Device " + label + " has alarm:</span></p>" +
853 - "<p><span style='color: red; font-weight: bold'>-- High Humidity Alarm</span></p>" +
854 - "<p>-- Current Temperature : " + detaildata
855 - .Hum_SHT + "</p><br>" +
856 - "<p>Device Configure:</p>" +
857 - "<p>-- Temperature Threshold : min: " + detaildata
858 - .Low_temperature_alarm + ", max: " + detaildata
859 - .High_temperature_alarm + "</p>" +
860 - "<p>-- Humidity Threshold: min: " + detaildata
861 - .Low_humidity_alarm + ", max:" + detaildata
862 - .High_humidity_alarm + "</p>" +
863 - "<p>-- Battery threshold: min: " + detaildata
864 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
865 -
866 - return {
867 - msg: {
868 - "data": emailstr
869 - },
870 - metadata: metadata,
871 - msgType: msgType
872 - };
873 -} else if (name == "Low humidity" && status ==
874 - "ACTIVE_UNACK") {
875 - var emailstr =
876 - "<div><p><span style='color: black; font-weight: bold'>" +
877 - "Device " + label + " has alarm:</span></p>" +
878 - "<p><span style='color: red; font-weight: bold'>-- Low Humidity Alarm</span></p>" +
879 - "<p>-- Current Temperature : " + detaildata
880 - .Hum_SHT + "</p><br>" +
881 - "<p>Device Configure:</p>" +
882 - "<p>-- Temperature Threshold : min: " + detaildata
883 - .Low_temperature_alarm + ", max: " + detaildata
884 - .High_temperature_alarm + "</p>" +
885 - "<p>-- Humidity Threshold: min: " + detaildata
886 - .Low_humidity_alarm + ", max:" + detaildata
887 - .High_humidity_alarm + "</p>" +
888 - "<p>-- Battery threshold: min: " + detaildata
889 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
890 -
891 - return {
892 - msg: {
893 - "data": emailstr
894 - },
895 - metadata: metadata,
896 - msgType: msgType
897 - };
898 -} else if (name == "Low voltage" && status ==
899 - "ACTIVE_UNACK") {
900 - var emailstr =
901 - "<div><p><span style='color: black; font-weight: bold'>" +
902 - "Device " + label + " has alarm:</span></p>" +
903 - "<p><span style='color: red; font-weight: bold'>-- Low Voltage Alarm</span></p>" +
904 - "<p>-- Current Temperature : " + detaildata.BatV +
905 - "</p><br>" +
906 - "<p>Device Configure:</p>" +
907 - "<p>-- Temperature Threshold : min: " + detaildata
908 - .Low_temperature_alarm + ", max: " + detaildata
909 - .High_temperature_alarm + "</p>" +
910 - "<p>-- Humidity Threshold: min: " + detaildata
911 - .Low_humidity_alarm + ", max:" + detaildata
912 - .High_humidity_alarm + "</p>" +
913 - "<p>-- Battery threshold: min: " + detaildata
914 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
915 -
916 - return {
917 - msg: {
918 - "data": emailstr
919 - },
920 - metadata: metadata,
921 - msgType: msgType
922 - };
923 -} else if (name == "High Temperature" && status ==
924 - "CLEARED_UNACK") {
925 - var emailstr =
926 - "<div><p><span style='color: green; font-weight: bold'>Device " +
927 - label +
928 - " High Temperature Alarm Cleared</span></p>" +
929 - "<p>-- Current Temperature : " + detaildata
930 - .TempC_SHT + "</p><br>" +
931 - "<p>Device Configure:</p>" +
932 - "<p>-- Temperature Threshold : min: " + detaildata
933 - .Low_temperature_alarm + ", max: " + detaildata
934 - .High_temperature_alarm + "</p>" +
935 - "<p>-- Humidity Threshold: min: " + detaildata
936 - .Low_humidity_alarm + ", max:" + detaildata
937 - .High_humidity_alarm + "</p>" +
938 - "<p>-- Battery threshold: min: " + detaildata
939 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
940 -
941 - return {
942 - msg: {
943 - "data": emailstr
944 - },
945 - metadata: metadata,
946 - msgType: msgType
947 - };
948 -} else if (name == "Low Temperature" && status ==
949 - "CLEARED_UNACK") {
950 - var emailstr =
951 - "<div><p><span style='color: green; font-weight: bold'>Device " +
952 - label +
953 - " Low Temperature Alarm Cleared</span></p>" +
954 - "<p>-- Current Temperature : " + detaildata
955 - .TempC_SHT + "</p><br>" +
956 - "<p>Device Configure:</p>" +
957 - "<p>-- Temperature Threshold : min: " + detaildata
958 - .Low_temperature_alarm + ", max: " + detaildata
959 - .High_temperature_alarm + "</p>" +
960 - "<p>-- Humidity Threshold: min: " + detaildata
961 - .Low_humidity_alarm + ", max:" + detaildata
962 - .High_humidity_alarm + "</p>" +
963 - "<p>-- Battery threshold: min: " + detaildata
964 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
965 -
966 - return {
967 - msg: {
968 - "data": emailstr
969 - },
970 - metadata: metadata,
971 - msgType: msgType
972 - };
973 -} else if (name == "High humidity" && status ==
974 - "CLEARED_UNACK") {
975 - var emailstr =
976 - "<div><p><span style='color: green; font-weight: bold'>Device " +
977 - label + " High Humidity Alarm Cleared</span></p>" +
978 - "<p>-- Current Temperature : " + detaildata
979 - .Hum_SHT + "</p><br>" +
980 - "<p>Device Configure:</p>" +
981 - "<p>-- Temperature Threshold : min: " + detaildata
982 - .Low_temperature_alarm + ", max: " + detaildata
983 - .High_temperature_alarm + "</p>" +
984 - "<p>-- Humidity Threshold: min: " + detaildata
985 - .Low_humidity_alarm + ", max:" + detaildata
986 - .High_humidity_alarm + "</p>" +
987 - "<p>-- Battery threshold: min: " + detaildata
988 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
989 -
990 - return {
991 - msg: {
992 - "data": emailstr
993 - },
994 - metadata: metadata,
995 - msgType: msgType
996 - };
997 -} else if (name == "Low humidity" && status ==
998 - "CLEARED_UNACK") {
999 - var emailstr =
1000 - "<div><p><span style='color: green; font-weight: bold'>Device " +
1001 - label + " Low Humidity Alarm Cleared</span></p>" +
1002 - "<p>-- Current Temperature : " + detaildata
1003 - .Hum_SHT + "</p><br>" +
1004 - "<p>Device Configure:</p>" +
1005 - "<p>-- Temperature Threshold : min: " + detaildata
1006 - .Low_temperature_alarm + ", max: " + detaildata
1007 - .High_temperature_alarm + "</p>" +
1008 - "<p>-- Humidity Threshold: min: " + detaildata
1009 - .Low_humidity_alarm + ", max:" + detaildata
1010 - .High_humidity_alarm + "</p>" +
1011 - "<p>-- Battery threshold: min: " + detaildata
1012 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
1013 - return {
1014 - msg: {
1015 - "data": emailstr
1016 - },
1017 - metadata: metadata,
1018 - msgType: msgType
1019 - };
1020 -} else if (name == "Low voltage" && status ==
1021 - "CLEARED_UNACK") {
1022 -
1023 - var emailstr =
1024 - "<div><p><span style='color: green; font-weight: bold'>Device " +
1025 - label + " Low Voltage Alarm Cleared</span></p>" +
1026 - "<p>-- Current Temperature : " + detaildata.BatV +
1027 - "</p><br><br>" +
1028 - "<p>Device Configure:</p>" +
1029 - "<p>-- Temperature Threshold : min: " + detaildata
1030 - .Low_temperature_alarm + ", max: " + detaildata
1031 - .High_temperature_alarm + "</p>" +
1032 - "<p>-- Humidity Threshold: min: " + detaildata
1033 - .Low_humidity_alarm + ", max:" + detaildata
1034 - .High_humidity_alarm + "</p>" +
1035 - "<p>-- Battery threshold: min: " + detaildata
1036 - .Low_voltage_alarm + "</p>" + str2 + "</div>"
1037 -
1038 - return {
1039 - msg: {
1040 - "data": emailstr
1041 - },
1042 - metadata: metadata,
1043 - msgType: msgType
1044 - };
1045 -} else if (name == "Device Disconnected" && status ==
1046 - "CLEARED_UNACK") {
1047 - var time1 = locatime(Number(detaildata.lastActivityTime))
1048 - //var time1 = detaildata.lastActivityTime
1049 - // var chazhi = parseInt((detaildata.inactivityAlarmTime-detaildata.lastActivityTime)/1000/60)
1050 - // var emailstr =
1051 - // "<div><p><span style='color: green; font-weight: bold'>" +
1052 - // "Device " + label + " has Alarm Cleared</span></p><p>Last activity time: "+time1+"</p></div>"
1053 - var emailstr ="Device " + label + " has Alarm Cleared##Last activity time: "+time1
1054 - var newType = "POST_TELEMETRY_REQUEST"
1055 - return {
1056 - msg: emailstr,
1057 - metadata: metadata,
1058 - msgType: newType
1059 - }
1060 -}
1061 -{{/code}}
1062 -
1063 -(% class="wikigeneratedid" %)
1064 -**Generate Report:**
1065 -
1066 -(% class="wikigeneratedid" %)
1067 -[[image:1730865053380-293.png]]
1068 -
1069 -= 5.other =
1070 -
1071 -* If you want to create a similar dashboard, after understanding the case, you can download and import the dashboard, device profiles, rule chains, etc. of the case on GitHub, and make modifications based on them.
1072 -* GitHub address:[[https:~~/~~/github.com/ThingsEye-io/te-platform/tree/main/case/Dragino%20Office%20%26%20Factory>>https://github.com/ThingsEye-io/te-platform/tree/main/case/Dragino%20Office%20%26%20Factory]]
215 += 5. =
1730770392454-317.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -195.6 KB
Content
1730770636230-829.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -290.6 KB
Content
1730770875793-351.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -305.2 KB
Content
1730771103096-522.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -197.9 KB
Content
1730771199343-553.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -108.5 KB
Content
1730771228766-212.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -46.8 KB
Content
1730771256045-238.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -69.1 KB
Content
1730771318657-502.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -60.4 KB
Content
1730771386258-676.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -46.4 KB
Content
1730771441589-122.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -57.6 KB
Content
1730771504586-433.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -151.2 KB
Content
1730857191863-514.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -354.7 KB
Content
1730857537965-184.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -455.1 KB
Content
1730857750749-240.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -285.9 KB
Content
1730862483514-101.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -195.8 KB
Content
1730862584519-902.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -191.1 KB
Content
1730863708259-750.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -220.1 KB
Content
1730863750414-979.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -210.6 KB
Content
1730864045747-876.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -208.9 KB
Content
1730864077395-395.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -201.4 KB
Content
1730864117808-484.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -203.0 KB
Content
1730864159071-895.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -226.6 KB
Content
1730864207037-477.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -215.3 KB
Content
1730864250506-111.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -209.5 KB
Content
1730864293216-991.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -138.5 KB
Content
1730864331859-740.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -134.4 KB
Content
1730864460314-611.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -256.7 KB
Content
1730864617480-221.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -260.8 KB
Content
1730864676542-406.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -227.7 KB
Content
1730864784118-474.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -148.8 KB
Content
1730865053380-293.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -46.7 KB
Content
屏幕截图 2024-11-04 135045.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.hera
Size
... ... @@ -1,1 +1,0 @@
1 -29.4 KB
Content