Skip to main content

A library to interface with Nilan Gateway and Genvex Connect enabled ventilation units.

Project description

Nilan Proxy

Library to locally interface with HVAC systems running Nilan or Genvex Connect gateways. Usually, those are only cloud accessible; however, after lots of work, we finally have a local solution ready.

The library is built to be used by the Home Assistant custom component "Nilan Connect".

Supported Controller Models

Controller Gateway Required Supported Tested
Optima 250 Yes, internet gateway
Optima 251 Yes, internet gateway
Optima 260 Yes, internet gateway
Optima 270 Built-in
Optima 301 Yes, internet gateway
Optima 312 Yes, internet gateway
Optima 314 Built-in
Nilan CTS400 Yes, Nilan gateway
Nilan CTS602 Yes, Nilan gateway
Nilan CTS602 Light Yes, Nilan gateway
Nilan CTS602 Geo Yes, Nilan gateway

For any controllers that require a gateway, it is mandatory that the device supports Modbus. Optima controllers delivered before 2014 might not have Modbus.

Obligatory Statement

I am not personally or in any way responsible for any damages should you choose to use the library. No warranty provided.

Special Thanks

This library owes special thanks to superrob; without him, this would not exist.

How Superrob Got the Base Library Developed

Genvex Connect and Nilan gateways both use the proprietary "Micro Nabto" protocol. Any mentions of it are very scarce online, with most official documentation being wiped from the internet after the companies released "Nabto Edge," which is highly incompatible with the older "Micro Nabto."

The usual connection flow is for the user to use the respective dedicated app. The app loads a comically large 6MB+ binary client for Nabto communication. The binary is closed source and seems obfuscated to prevent easy "decompilation." This is also a huge issue as binaries are only available for Win32, Linux, Mac, Android, and iOS. No generic Linux ARM binaries are available, and thus using those to implement a Home Assistant custom component would exclude the most popular hosting devices, such as the Raspberry Pi.

The binary scans for any gateways by sending out a broadcast UDP packet. This packet either has a specific device identifier in it or a star (*) to request any gateway to respond. Any available gateways will respond to the receiver with their unique identifier on the same UDP IP and port the broadcast was sent.

The normal flow is then handled online, with the library using a client certificate encrypted using the password supplied when first using the device. The flow, unfortunately, is where I got stuck for a long time. The client requests a server peer ID from the Nabto server, which, if properly authenticated, is sent back together with a NONCE and a server certificate. The client, using the NONCE, calculates an AES encryption key, which is later used to set up a direct local connection to the device. Next, the client sends a connection request to the Nabto server. This request is encrypted using the server certificate public key and signed using the client certificate private key. The contents of this request are currently not known, as that would require extensive reverse engineering of the Nabto client binary, and thus where I got stuck.

The server replies back, again encrypted. I am guessing the contents to be encrypted using the public RSA key from the client certificate. I have not looked into the contents of the reply, as I currently do not know the contents of the original request. What is clear is that these packets set up the communication on the local device where the encryption context for the connection is set up.

The client then connects locally to the device and is expected to provide all communication forwards in CRYPT payloads, encrypted using the AES keys which the server has set for the connection during the last two phases. Luckily, the Nabto binary has a lot of logging built in and actually displays the AES and HMAC keys during the connection request! Using that key, I was able to decrypt and study the payloads, which matched the "Micro Nabto" device source code I had found a while ago on their GitHub. Their device source code contains details on the protocol used and allowed me to decode and even build my own packets.

However, without understanding the client connection request sent to the server, this is not useful.

That was until I tried using an extremely old version of the Nabto client binary. To my surprise, it talked with the device using cleartext CRYPT payloads! I had seen in the device source code that if an "isLocal" flag is set for the connection, that any encryption can be specified to be used. However, I couldn't figure out how to set the flag. However, this old client binary connected to a different port on the device. To my surprise, using that UDP port instead of the one used by the newer client library, it actually set the isLocal flag and allowed for unencrypted CRYPT payloads!

From here, I only had to implement the "Micro Nabto" protocol in my own portable library. I have only been able to test the Optima 270 implementation as I only have a Genvex ventilation unit with the Optima 270 controller (Has the gateway built-in). However, I have tried implementing the older controllers which should, in theory, be compatible. I have also added the Nilan CTS400 controller as the gateway for Nilan is built by the same company and uses the same command structure.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nilan_proxy-1.0.0.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

nilan_proxy-1.0.0-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file nilan_proxy-1.0.0.tar.gz.

File metadata

  • Download URL: nilan_proxy-1.0.0.tar.gz
  • Upload date:
  • Size: 35.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nilan_proxy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f9b41a1ccd8bde2df5cec3f6c587e5497bbfcc93da52a44003c3d0d165476829
MD5 da4c3c0515dc9447ad5d4e8595877a50
BLAKE2b-256 6f46b156e5f450132519858e8777d8bbfb0fa4a5a1bb1a5fdcc6a9226074bbbe

See more details on using hashes here.

File details

Details for the file nilan_proxy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nilan_proxy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for nilan_proxy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8bf0bc62171fb76b62560def415c969c4d322169c089a47a24285e314530b57
MD5 d0833970bed15984e4d97fc09098551c
BLAKE2b-256 affac5a9c696681a28485591e2e1949fa0c34c11eebd98a274ef155e01538b53

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page