-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript_time_RAC.lua
More file actions
30 lines (18 loc) · 793 Bytes
/
Copy pathscript_time_RAC.lua
File metadata and controls
30 lines (18 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local t1 = os.date("%H") -- get hour time digit
commandArray = {}
-- if t1%23 == 0 then -- only poll at 11pm every day
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
-- API call
local config=assert(io.popen('curl "http://192.168.86.249/api/getRadiation"'))
local Stringjson = config:read('*all')
config:close()
local jsonData = json:decode(Stringjson)
cpm = math.floor(jsonData.cpm)
val = math.floor(jsonData.value)
-- print (Stringjson) -- debug json
-- print (cpm) -- parsed json value
-- print (val) -- parsed json value
commandArray[1]={['UpdateDevice']= 968 .. "|" .. 0 .. "|".. val }
commandArray[2]={['UpdateDevice']= 969 .. "|" .. 0 .. "|" .. cpm }
-- end
return commandArray