05.03.2016, 13:15
(03.03.2016, 10:00)domotiqa Wrote: no it was just a question, because I readed this:
http://www.knx.org/fileadmin/downloads/0...ebsite.pdf
And in this doc, Obix looks more open... It was just in order to have your though
Hi Domotiqa,
Here are 2 functions i use to communicate with our SmartStruxure Lite controller with oBIX. Maybe you can use it.
-- function to get data from mpm
function get_data_from_mpm(mpm_settings,object,item)
local url = "http://" .. mpm_settings.username .. ":" .. mpm_settings.password .. "@" .. mpm_settings.ip .. "/obix/network/" .. mpm_settings.node .. "/DEV" .. mpm_settings.instance .. "/" .. object .. "/" .. item
local b, c, h = mpm.request(url)
local value = b:match([[val="(.-)"]])
local value = tonumber(value)
return value
end
-- function to post data to mpm
function post_data_to_mpm(mpm_settings,object,item,value)
local url = "http://" .. mpm_settings.username .. ":" .. mpm_settings.password .. "@" .. mpm_settings.ip .. "/obix/network/" .. mpm_settings.node .. "/DEV" .. mpm_settings.instance .. "/" .. object .. "/" .. item .. "/"
local reqBody = [[<intl val="]] .. value .. [["/>]]
local headers = {["Content-Type"] = "text/xml", ["Content-Length"] = #reqBody}
local respTable = {}
local returnList = {client = {}, code = {}, headers = {}, status = {}}
local source=ltn12.source.string(reqBody)
local sink=ltn12.sink.table(respTable)
local result = mpm.request{url=url, method="POST", source=source, sink=sink, headers=headers}
return result
end
BR,
Erwin van der Zwart