Changes for page 2 Script
Last modified by Devin Chen on 2025/06/06 14:03
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. Hunter1 +XWiki.Stone - Content
-
... ... @@ -135,85 +135,7 @@ 135 135 end 136 136 {{/code}} 137 137 138 -== **1.6 LINE Notify** == 139 139 140 -This example shows how to use the LINE Notify to send message into LINE group. When monitoring bit "@test" changes, it will trigger and send the message. Please replace with your own Token. 141 - 142 -{{code}} 143 -local tempBit = 0 144 -local tempWord = 0 145 - 146 -local LineToken = "08XCpubkOdwGdGgRTXF0x8umiyrALtoM0v6lBFUV6PC" 147 - 148 -local https = require("https") 149 -local json = require("json") 150 -local ltn12 = require("ltn12") 151 - 152 --- Send http.get request and return response result 153 -function getHttpsUrl(url,header,reqbody) 154 - local body = {} 155 - local bodyJson = json.encode(body) 156 - local result_table, code, headers, status = https.request{ 157 - method = "POST", 158 - url = url, 159 - source = ltn12.source.string(reqbody), 160 - headers = header, 161 - sink = ltn12.sink.table(body) 162 - } 163 - print("code:"..code) 164 - if code~= 200 then 165 - return 166 - else 167 - return body 168 - end 169 -end 170 - 171 -function getMessageUrl(lineMessage) 172 - local url = "https://notify-api.line.me/api/notify" 173 - local reqMess = "message="..lineMessage 174 - local headers = 175 - { 176 - ["Authorization"] = "Bearer "..LineToken, 177 - ["Content-Type"] = "application/x-www-form-urlencoded", 178 - ["Content-Length"] = #reqMess 179 - } 180 - 181 - print("Get the link:"..url) 182 - getHttpsUrl(url, headers, reqMess) 183 -end 184 - 185 - 186 -function linenotify.main() 187 - local bitValue = addr_getbit("@test"); 188 - local message = '' 189 - print("b=="..bitValue) 190 - if bitValue == 1 and bitValue ~= tempBit then 191 - message = 'Alarm V-Box triggered, the output is '.. bitValue 192 - getMessageUrl(message) 193 - print("Notification pushed of triggering alarm,"..bitValue) 194 - elseif bitValue == 0 and bitValue ~= tempBit then 195 - message = 'Alarm V-Box dismissed, the output is '.. bitValue 196 - getMessageUrl(message) 197 - print("Notification pushed of dismissing alarm,"..bitValue) 198 - end 199 - tempBit = bitValue----Prevent monitoring values from continuous being sent to the platform 200 - 201 - local wordValue = addr_getword("@t2") 202 - print("w=="..wordValue) 203 - --dosomething 204 - if wordValue >= 100 and wordValue ~= tempWord and tempWord <= 100 then 205 - message = 'Alarm V-Box triggered, the temperature is '.. wordValue 206 - getMessageUrl(message) 207 - print("Notification pushed of triggering alarm,"..wordValue) 208 - elseif wordValue < 100 and wordValue ~= tempWord and tempWord >= 100 then 209 - message = 'Alarm V-Box dismissed, the temperature is '.. wordValue 210 - getMessageUrl(message) 211 - print("Notification pushed of dismissing alarm,"..wordValue) 212 - end 213 - tempWord = wordValue----Prevent monitoring values from continuous being sent to the platform 214 -end 215 -{{/code}} 216 - 217 217 = **2 V-Box connect with third part server** = 218 218 219 219 V-Box have two mode.One is for V-Net,User need to use WECON server to store data.We call this V-NET platform.