Logic Machine Forum
Siegenia AEROPAC - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Siegenia AEROPAC (/showthread.php?tid=2265)



Siegenia AEROPAC - gjniewenhuijse - 04.10.2019

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.siegenia/blob/master/lib/siegenia.js


RE: Siegenia AEROPAC - admin - 04.10.2019

See this thread for websocket library: https://forum.logicmachine.net/showthread.php?tid=1294&pid=7823#pid7823


RE: Siegenia AEROPAC - gjniewenhuijse - 29.10.2019

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?


RE: Siegenia AEROPAC - gjniewenhuijse - 30.10.2019

i like to turn this device on/off and set my fanlevel.

Who can help me?


RE: Siegenia AEROPAC - admin - 30.10.2019

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.


RE: Siegenia AEROPAC - admin - 30.10.2019

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
  }
})



RE: Siegenia AEROPAC - gjniewenhuijse - 30.10.2019

(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