This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Siegenia AEROPAC
#1
Next device to control: the Siegenia AEROPAC Smart

There is one product on the web that supports this device, iobroker:
https://github.com/Apollon77/ioBroker.siegenia

Is it easy to control them with a LM/HL?

I see they use a websocket in: https://github.com/Apollon77/ioBroker.si...iegenia.js
Reply
#2
See this thread for websocket library: https://forum.logicmachine.net/showthrea...23#pid7823
Reply
#3
mmm i only receive a 1006 error

Code:
* arg: 1
  * nil
* arg: 2
  * nil
* arg: 3
  * bool: false
* arg: 4
  * number: 1006
* arg: 5
  * string: wrong state


Code:
iIp  = '192.168.x.x'
iUsr = 'admin'
iPwd = 'xxxxxxxx'

if not ws then
  ws = require('user.websocket')
  url = 'wss://'..iUsr..':'..iPwd..'@'..iIp..':443/WebSocket'
  -- mode is either sync or copas, second parameter sets timeout in seconds
  client = ws.client('sync', 10)
  client:connect(url)
end

log(client:receive())

Anyone a suggestion how to find a detailed error?

30-10-2019: change the protocol from ws to wss gives no error 1006, but how to control the box?
Reply
#4
i like to turn this device on/off and set my fanlevel.

Who can help me?
Reply
#5
From JS code it looks like you don't have to pass user/password via URL but send a login request via WS.

Each request is encoded using JSON:
Code:
login = json.encode({
  command = 'login',
  user = user,
  password = password,
  long_life = false,
})

For On/Off and fan control try this (change deviceactive value as needed):
Code:
req = json.encode({
  command = 'setDeviceParams',
  params = {
    devicestate = { deviceactive = true },
    fanlevel = 3, -- 0..7
    fanpower = 50, -- 0..100  
  }
})
Either fanlevel or fanpower value is needed, AEROPAC probably uses fanlevel.
Reply
#6
There's missing id parameter in my example. Use this helper function to send requests:
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
  }
})
Reply
#7
(30.10.2019, 14:40)admin Wrote: There's missing id parameter in my example. Use this helper function to send requests:
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
  }
})

Many thanks, it works great..  Big Grin
Reply


Forum Jump: