Connecting Velux Active KIX 300

Found a much better way of how to interact with KIX-300, the answer is HomeKit.
It has several advantages over the reverse engineered solution used by velux-cli:

  • easier to setup
  • future proof as it uses a standard protocol to interact with the KIX-300
  • works locally, no cloud
  • works with windows as well
  • get all values from sensors

So this is what I did:

  1. install
  2. create pairing file
  3. run discovery (within the same network!)
  4. run pairing (you find the pairing code of the KIX-300 on the backside of the gateway) - use ``velux` as alias
  5. list accessories with python3 -m homekit.get_accessories -f pairing.json -a velux
  6. get characteristics or put characteristics

Basically it’s just following the instructions from the link above :wink:

Example how to open a window (11.10 is the characteristic id you get from list accessories):

python3 -m homekit.put_characteristic -f pairing.json -a velux -c 11.10 50

Have fun!


Hi Bernhard
I just implemented your homekit solution. It works perfectly!! Thanks so much!

Is there a nice way to link the python commands directly to openhab?

Kind regards

did you implemented an binding module?

Hi Rafael,
i just followed the steps described by Bernhard. The commands via console work fine so far.
But I’m not sure how to make items and things from the python commands.

Kind regards


i’ve created following protoype. (i didn’t test the UP/DOWN/STOP commands for the blinds, could be that they are inverted and that the stop command doesn’t work at all). Using a slider for the blinds works pretty well.

you need to adjust the id’s (e.g. 5.10) and the path to the paring file (this file need’s to be owned by the openhab user, (not the openhabian user))


Thing exec:command:velux [command="python3 -m homekit.get_characteristic -f /openhab/conf/homekit.json -a velux -c 5.10 -c 5.13 -c 5.17 -c 2.10 -c 3.10 -c 4.10", interval=30, timeout=20]


String VeluxExec "velux status update" {channel="exec:command:velux:output"}

Number Flur_temperatur "Temperature [%.1f °C]" <temperature> 
Number Flur_Co2 "CO2 [%.1f]"
Number Flur_luftfeuchtigkeit "Luftfeuchtigkeit [%d]"
Number Flur_luftquali "Luft Qualität [%d]"
Number Flur_lux "Lux [%d]"

Group veluxshutters <rollershutter>
Rollershutter Galerie_Rolladen (veluxshutters)
Rollershutter Badezimmer_Rolladen (veluxshutters)
Rollershutter Galerie_Fenster <window> (veluxshutters)


rule "velux item update"
   Item VeluxExec changed
  val jsonstate = triggeringItem.state.toString
  //logInfo("Received Json", jsonstate)

  val temp = transform("JSONPATH", "$['5.10']['value']", jsonstate)

  val co = transform("JSONPATH", "$['5.17']['value']", jsonstate)

  val humidity = transform("JSONPATH", "$['5.13']['value']", jsonstate)

  val prozent = Integer::parseInt(transform("JSONPATH", "$['3.10']['value']", jsonstate).toString())
  Galerie_Rolladen.postUpdate(100 - prozent)

  prozent = Integer::parseInt(transform("JSONPATH", "$['4.10']['value']", jsonstate).toString())
  Badezimmer_Rolladen.postUpdate(100 - prozent)

  prozent = Integer::parseInt(transform("JSONPATH", "$['2.10']['value']", jsonstate).toString())
  Galerie_Fenster.postUpdate(100 - prozent)

rule "shutters command"
  Member of veluxshutters received command
  logInfo("shutters", + ": " + triggeringItem.state.toString + " - " + receivedCommand)

  var String veluxShutter
  switch (triggeringItem) {
    case Galerie_Rolladen: veluxShutter = '3.11'
    case Badezimmer_Rolladen: veluxShutter = '4.11'
    case Galerie_Fenster: veluxShutter = '2.11'

  var int position
  if (receivedCommand == UP) {
    position = 0
  } else if (receivedCommand == DOWN) {
    position = 100
  } else if (receivedCommand == STOP) {
    val StringBuilder readCommand = new StringBuilder
    readCommand.append("python3@@-m@@homekit.get_characteristic@@-f@@/openhab/conf/homekit.json@@-a@@velux@@-c@@" + veluxShutter)
    val String result = executeCommandLine(readCommand.toString, 10000)
    position = transform("JSONPATH", "$.['" + veluxShutter + "'].value", result)
  } else if (receivedCommand instanceof Number) {
    position = 100 - receivedCommand.intValue

  logInfo("shutters",  "moving " + veluxShutter + " to " + position)

  val StringBuilder myCommand = new StringBuilder
  myCommand.append("python3@@-m@@homekit.put_characteristic@@-f@@/openhab/conf/homekit.json@@-a@@velux@@-c@@" + veluxShutter + "@@" +  position)

  logInfo("shutters", myCommand.toString, 1000)

  val String Answer = executeCommandLine(myCommand.toString, 10000)
  logInfo("shutters", "Result:" + Answer)
1 Like

hi all,

i did already something with openhub and it went so far so good.

But with this i have a problem in creating the “pairing file”.
what information are needed and where can i find it?

I followd the link and installed the homekit_pyton and i can discover the bridge.
But thats it…

thanks for support


hi all,

i found a good step by step guide

no it is working perfect for me


I have extracted the client_id and client_secret from the VELUX active APK using JADX. Those two information are returned by some methods, located all in the same class file.

# client_id: 5931426da127d981e76bdd3f
# client_secret: 6ae2d89d15e767ae5c56b456b452d319
# mgtkey: f3748d873c62f30ef6f7b61b7e725ac6

How to get your oauth2 token?

$ curl --location --request POST '' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'client_id=5931426da127d981e76bdd3f' \
--data-urlencode 'client_secret=6ae2d89d15e767ae5c56b456b452d319' \
--data-urlencode '' \
--data-urlencode 'password=mypassw' \
--data-urlencode 'app_version=1108002' \
--data-urlencode 'user_prefix=velux'

Hi Hubert,

Thanks for extracting and sharing that. Now working for me. :slight_smile: To get token:

curl -d “grant_type=password&client_id=5931426da127d981e76bdd3f&client_secret=6ae2d89d15e767ae5c56b456b452d319&”

As documented here:

Did anyone succeed in setting state for Departure Switch (NXD)?


curl -s -H “Content-Type: application/json; charset=utf-8” -H “Authorization: Bearer mytoken” -X POST -d “${JSON}” “

with $JSON set to:

“home”: {
“id”: “myhomeid”,
“modules”: [
“id”: “xx:xx:xx:xx:xx:xx”,
“locked”: true

But get this response:

{“error”:{“code”:21,“message”:“cannot set property locked for module xx:xx:xx:xx:xx:xx”}}

Best regards,
Jacob Laursen

@nougad - I may have somehow missed it, but how do you create a request for locking or unlocking your home?


Hi. Thank you very much for all info present in this thread.

I was able to install and run as openhabian the Homekit python version suggested by Bernhard and to define Things/Items as suggested by Rafael.

When I run the command as openhab I get below error:

/usr/bin/python3: Error while finding module specification for ‘homekit.get_characteristic’ (ModuleNotFoundError: No module named ‘homekit’)

The same command executed by openhabian work smoothly.

Python modules owner and group looks fine.

I have tried to move Homekit python site-packages in PATH to /usr/lib/bin but without success.

I have googled the error but without success (I’m not a python programmer nor a linux/raspberry expert).

Could you please give me some suggestions?

Release = Raspbian GNU/Linux 10 (buster)
Kernel = Linux 5.10.11-v7+
Platform = Raspberry Pi 3 Model B Plus Rev 1.3

Thank you in advance for your help.

Hi again. I’m going to answer myself :slight_smile:

To install homekit for openhab user the command is: sudo -u openhab pip3 install --user homekit[IP]

Probably also this command should work but I have not tested it: pip3 install --system homekit[IP]

To be honest I’m not able to understand if this can create problems on the raspberry installation or if it is ok.



I have created a small instruction to patch the APK file and get all required info to interact with windows and unlock your home.
The app is only required once to get the all the keys.

I was able to generate and exchange all other keys via web API except for the HashSignKey which seems to be generated when the app connects directly to the gateway. I could log that exchange with wireshark (~9 requests and responses between app + local gateway) but data seems to be encoded/encrypted.

But having all the keys allows to create own APIs (eg Node-RED).

Maybe this is useful to some people, like everything here was for me.

1 Like

Hi there, I have an OpenHAB setup with a KLF200 to control my windows and rollershutters. It works fine apart from the KLF 200 being a pain to work with (login via its own WI-FI only!). However, whenever I need to restart the OpenHAB service the KLF200 refuses any incoming connection and I have to keep unplugging it completely several times for long periods of time until it hopefully starts working agains. This seems totally random and sometimes takes days.
As this is not acceptable I was hoping the KLX300 could be a solution. Will there be a binding for OpenHAB eventually? I am also happy to tinker with copy-pasting code to make it work. Thanks!

Newer KLF200 devices work reliable only over LAN access. The internal WiFi access point should be disabled automatically 10 minutes after power connection. This has been added to the latest Pull Request documentation.
My setup is running fine for 2 month now.

I have 7 velux integra windows that i need connected to my openhab, but i dunno what solution to use klf200 or kix300.

and i rather not have netamo/velux active controls/sensors honing around the house.
My solution only to have one control in each room for windows/heating/etc…

I’m using a KIX300 (only gateway, no sensors) to manage three windows in different rooms, including curtains and shutters. It has been integrated in OH3 using the approach described in this thread. For my needs, it works well and in fact, I have completely forgotten the velux app :-).
In case, try to further elaborate on your requirements and use cases in order to get more detailed suggestions.

Hi Manuel, which approach did you succeed with - the homekit_python one?

Yes, correct, the homeKit version (actually there were at least two solutions in the thread, sorry… :slight_smile: ). Specifically this post and the related ones (such as this one).

Hi, is there any update on the KIX 300 syntax, as stated by Jacob? I am able to get the access tokens and the homesdata, but it looks like that the setstate syntax for the json data parameter has been changed. I played around with some options but with no luck. Can any control the shutters using the “syncapi/v1/setstate” url?