I am reading xml from IPX800 http://192.168.1.125/status.xml
Code: Select all
<response>
<led0>0</led0>
<led1>0</led1>
<led2>0</led2>
<led3>0</led3>
<led4>0</led4>
<led5>0</led5>
<led6>0</led6>
<led7>0</led7>
<btn0>up</btn0>
<btn1>up</btn1>
<btn2>up</btn2>
<btn3>dn</btn3>
<an1>0</an1>
<an2>0</an2>
<time0>19:16:16</time0>
</response>
Code: Select all
commandArray = {}
function XML_Capture(cmd,flatten)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if flatten then
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
end
return s
end
debug = true
-- DOMOTICZ IDX
IDX1=117 --motion sensor 1
IDX2=118 --motion sensor 2
Device_IPX800 = "192.168.1.125"
if debug == true then
print("Reading values from: 'http://"..Device_IPX800.."/status.xml'")
end
-- Read the XML data from the device IPX800
XML_string=XML_Capture("curl -s 'http://"..Device_IPX800.."/status.xml'",1)
valid = string.find(XML_string, "<response>") -- check we are looking in the right place
if debug == true then
print(XML_string)
end
return commandArray
LOG:
Code: Select all
2019-06-05 19:59:26.808 Status: LUA: Reading values from: 'http://192.168.1.125/status.xml'
2019-06-05 19:59:26.858 Status: LUA: <response> <led0>0</led0> <led1>0</led1> <led2>0</led2> <led3>0</led3> <led4>0</led4> <led5>0</led5> <led6>0</led6> <led7>0</led7> <btn0>up</btn0> <btn1>up</btn1> <btn2>up</btn2> <btn3>dn</btn3> <an1>0</an1> <an2>0</an2> <time0>19:26:51</time0> </response>
I need to write the motion sensor value to IDX1:
<btn3> dn </btn3> switch open
<btn3> up </btn3> switch closed
Can anyone help me? Well thank you.