30.10.2019, 14:40
There's missing id parameter in my example. Use this helper function to send requests:
If you want to keep the connection open then you should send keep-alive every 10 seconds or so:
Code:
function send(data)
reqid = (reqid or 0) + 1
data.id = reqid
data = json.encode(data)
return client:send(data)
end
send({
command = 'login',
user = iUsr,
password = iPwd,
long_life = false,
})
send({
command = 'setDeviceParams',
params = {
devicestate = { deviceactive = false },
fanlevel = 0, -- 0..7
}
})
send({
command = 'logout'
})
If you want to keep the connection open then you should send keep-alive every 10 seconds or so:
Code:
send({
command = 'keepAlive',
param = {
extend_session = true
}
})