Changes for page 2 Script

Last modified by Devin Chen on 2025/06/06 14:03

From version 55.1
edited by Hunter
on 2023/08/03 15:02
Change comment: Replaced user [xwiki:XWiki.hunter123] in fields [author, contentAuthor] to user [xwiki:XWiki.Hunter]
To version 50.1
edited by Hunter
on 2023/05/06 10:12
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -27,19 +27,25 @@
27 27  
28 28  == **1.4 Short message** ==
29 29  
30 -The following demo shows that when the alarm condition is reached: temp1 > 5 & temp2 >10 & temp3 < 20(lasts more than 5 seconds) , then send an "alarm trigger" sms.
30 +When the alarm condition is reached: temp1 > 5 & temp2 >10 & temp3 < 20(lasts more than 5 seconds) , then send an "alarm trigger" sms.
31 31  
32 -When the alarm condition is released,then send an  "alarm release" sms. Script is as below:
32 +When the alarm condition is released,then send an "alarm release" sms.
33 33  
34 -{{code language="lua"}}
34 +(% style="text-align:center" %)
35 +[[image:1645535936750-316.png||height="385" width="400" class="img-thumbnail"]]
36 +
37 +Script is as below:
38 +
39 +(% class="box infomessage" %)
40 +(((
35 35  function sms.main()
36 -------send condition------
42 +~-~-~-~-~-~-send condition~-~-~-~-~-~-
37 37  local temp1 = addr_getword("@Temperature1")
38 38  local temp2 = addr_getword("@Temperature2")
39 39  local temp3 = addr_getword("@Temperature3")
40 40  local timer = addr_getword("@Timer")
41 41  local tag = addr_getbit("@Tag")
42 -------lasting time------
48 +~-~-~-~-~-~-lasting time~-~-~-~-~-~-
43 43  if temp1 > 5 and temp2 > 10 and temp3 < 20 then
44 44   timer = timer + 1
45 45   addr_setword("@Timer",timer)
... ... @@ -47,7 +47,7 @@
47 47   timer = 0
48 48   addr_setword("@Timer",timer)
49 49  end
50 -------send sms & output Y0------
56 +~-~-~-~-~-~-send sms & output Y0~-~-~-~-~-~-
51 51  if timer > 5 then
52 52   if tag == 0 then
53 53   send_sms_ira("19859254700","alarm trigger")
... ... @@ -58,7 +58,7 @@
58 58  addr_setbit("@Tag",0)
59 59  end
60 60  end
61 -{{/code}}
67 +)))
62 62  
63 63  == **1.5 Telegram notification** ==
64 64  
... ... @@ -521,7 +521,6 @@
521 521  {{code language="lua"}}
522 522  --MQTT configuration table
523 523  local MQTT_CFG={}
524 ---if there is no need the username and password, please put them as ""
525 525  MQTT_CFG.username = "weconsupport"
526 526  MQTT_CFG.password = "123456"
527 527  MQTT_CFG.netway = 0
... ... @@ -561,7 +561,7 @@
561 561  function mqtt_init()
562 562   print(string.format("mqtt init mqtt_url:%s mqtt_clientid:%s", MQTT_URL, MQTT_CLIENT_ID))
563 563   if g_mq then
564 - mqtt.close(g_mq) --Close mqtt object
569 + mqtt.close() --Close mqtt object
565 565   end
566 566   g_mq, err = mqtt.create(MQTT_URL, MQTT_CLIENT_ID) -- create mqtt object,and declare it as a global variable
567 567   if g_mq then