Disclaimer: I’m not a developer, so please go easy on me ![]()
I’m looking for a way to get the status of Zipato Zipatile’s internal sensors (PIR, Temp, Humidity, etc), which is possible via REST API and MqTT. It is my understanding the MqTT Vera plugin allows publishing only, so that eliminates the MqTT option.
I found a sample REST API LUA code which looks very promising, but it generates the following 2 errors when I run it on Vera:
luup_require can’t find encdec
luup_require can’t find json
My assumption is that these 2 dependencies are not available on Vera, hence the error? If so, where do I go from there?
Any advise will be greatly appreciated.
I’m posting the entire referenced LUA code below:
[code]username = ‘user@domain.com’
password = ‘pass’
serial = ‘1234’
https = require(‘ssl.https’)
ltn12 = require(‘ltn12’)
sha1 = require(‘encdec’).sha1
json = require(‘json’)
function dorequest(url, headers)
local tbl = {}
local res, err = https.request({
url = url,
headers = headers,
sink = ltn12.sink.table(tbl)
})
if res then
return table.concat(tbl)
else
return nil, err
end
end
res, err = dorequest(‘https://my.zipato.com/zipato-web/v2/user/init’)
log(‘init’, res, err)
if res then
data = json.decode(res)
password = sha1(password)
token = sha1(data.nonce … password)
headers = {
[‘accept’] = ‘application/json’,
[‘cookie’] = ‘JSESSIONID=’ … data.jsessionid … ‘;’,
}
url = ‘https://my.zipato.com/zipato-web/v2/user/login?token=’ … token … ‘&username=’ … username
res, err = dorequest(url, headers)
log(‘login’, res, err)
if res then
url = ‘Login’ … serial
res, err = dorequest(url, headers)
log(‘reboot’, res, err)
end
end[/code]