Skip to main content

Nilan Connect

An event-driven Python client for Nilan and Genvex ventilation units behind their gateway, over the gateway's local micro_nabto protocol, built on modbus_event_connect.

You subscribe to the values you care about and are told when one changes - with its quality, so "offline", "no reading" and a real value never look alike.

Supported controllers

Controller Status
Nilan CTS400 Tested: every point checked against Nilan's Modbus manual and read from a unit
Genvex Optima 270 Tested: read from a unit
Nilan CTS602, every variant including Geo Untested, apart from four temperatures (T2, T3, T4, T8) read from a unit
Nilan CTS602 Light Untested
Genvex Optima 250, 251, 260, 301, 312, 314 Untested

The gateway's addresses of the untested controllers are derived and calculated from the material we could find online, and have not been tested on those controllers. Values may be wrong or missing; reports of what a unit shows are welcome. connect() raises UnsupportedDeviceError for any other controller.

certainty(point) says how certain it is that a point is right:

Certainty Meaning
VERIFIED Read on a unit of the model.
REPORTED Found in material published online; not read on a unit of the model.
INFERRED Placed from the model's Modbus manual by the order of its register group; not read on a unit of the model, and not found elsewhere.

On a CTS602 the gateway does not use the manual's addresses. Within one of the manual's register groups - blocks of 100, such as the temperatures from input register 200 - it keeps the manual's order and spacing, so a group's other registers follow from one known address in it: those are the inferred points. A setting among them can be written, as a test of it needs to; whether a user is offered that is the consumer's choice. A consumer that wants only what has been seen working leaves the inferred points out:

from nilan_connect import Certainty, certainty

shown = [point for point in client.points.values() if certainty(point) is not Certainty.INFERRED]

Installation

pip install nilan-connect

Everything you use comes from nilan_connect: the client and its values, the errors, discovery, and, in nilan_connect.testing, a simulated gateway for your own tests. modbus_event_connect is installed with it; nothing needs importing from it.

Usage

import asyncio
from nilan_connect import PointKey, create_client

def on_change(key, old, new):
    print(f"{key}: {new.value} ({new.quality.name})")

async def main():
    # The email is the account the gateway is paired with in Nilan's app.
    client = create_client("you@example.com", host="<gateway-ip>")
    await client.connect()              # reads the handshake and chooses the controller's model

    client.subscribe(PointKey.TEMP_OUTSIDE, on_change)
    client.subscribe(PointKey.FILTER_OK, on_change)

    while True:                         # you own the clock; the library owns the plan
        await client.poll()             # reads only what is due - free when nothing is
        await asyncio.sleep(1)

asyncio.run(main())

With only a device_id, the gateway is found by discovery. discover() lists the gateways that answer. port reaches a gateway that does not answer on micro_nabto's standard port.

How often values are read

The controller's readings every 10 seconds, its settings every 180 seconds, and a setting again one second after it is written. What a write changes is read again too: after a filter reset, the filter's status and timers and the alarm status, two seconds later; after a filter interval, the days left, two seconds later; after a fan level, the levels the fans run at and their speeds, three seconds later.

The gateway

The gateway is a device of its own between the network and the controller. It reaches the controller over RS-485 Modbus at 19,200 baud, as the master, and gives the controller's registers addresses of its own.

It answers from what it holds, not from the controller. A CTS602's gateway answered reads of 4 to 31 registers within 7 to 24 ms, the trip over the network included. Asked of the controller over RS-485, one register alone takes about 13 ms, and those reads, which span up to five of the manual's register groups, at least 40 to 95 ms.

The gateway counts as not answering once it has left reads unanswered for 10 seconds: one missed read keeps the last values, and a gateway that stays silent shows as not answering. After a failed handshake it is asked again after 5 seconds, before the next read is due.

What it holds can be empty. A CTS602's gateway answered the first reads of a new session with only zeros, at once and again 18 ms later, and with values 10 s later. The same gateway was reported leaving a read unanswered every 33 minutes and answering the next. Not known yet:

  • whether it empties what it holds when a session begins, when it restarts, or at some interval;
  • how long it takes to fill it;
  • whether every controller's gateway works this way: only a CTS602's has been measured.

modbus_event_connect handles such an answer for any device, also one read directly: the last values are kept while the registers are read again, and the zeros are taken if they stay. It logs, as warnings, why each session began, when the gateway went silent and answered again, and how long it took to answer values. Those lines answer the questions above; please include them in a report.

Writing

await client.write(PointKey.TEMP_TARGET, 21.5)
await client.write(PointKey.FILTER_REPLACE_RESET, True)   # an action: nothing to read back

A value outside the limits Nilan's manual gives is refused before anything is sent. create_client(..., read_only=True) refuses every write.

A CTS400's gateway answered some writes with a status saying it did not take them, and took the same write on a later try. Such a write is sent again until create_client(..., write_retry_for=...) seconds have passed since it was first sent - WRITE_RETRY_FOR unless given; 0 sends every write once. A newer value for the same setting takes over from it.

A read sent again, as its receipt did not come, and answered with only zeros where the registers held values, is kept open for a later answer: 1 s for a CTS400, and the library's 5 s for the other controllers. create_client(..., later_answer_wait=...) sets it for any controller.

Keys

A key is the stable name of a point, and carries the type of its value. A key string never changes, so what a consumer builds on it keeps working.

Every key is in PointKey. Which keys a controller has, and at which registers, is its model's: client.points lists the points of the unit connected, each with its unit, limits and whether it is read, written or both.

filter_ok is the CTS400 manual's "filter change status" the other way round, and humidity_high_active its "average level humidity 24 hours OK" the other way round.

Controllers share a key wherever a value means the same.

States

A value with named states is an IntEnum, one for all controllers: Alarm, OperationState, OperationMode, Weekday, HeatSource, CompressorPriority, CoolingSetpoint, AirExchangeMode, ControlSensor, CentralHeatMode, CirculationPumpMode, ServiceMode, DamperTestState, FilterReplaceInterval and ExtraSensor. Each controller maps its own numbers onto them, so a state means the same whichever controller reports it: a CTS400's alarm 1 and a CTS602's alarm 19 are both Alarm.CHANGE_FILTER.

  • A key ending in _code holds the controller's own number. What it means is a key of its own: alarm_1 for alarm_1_code, operation_state for state_code.
  • An Optima reports its alarms as bits. Each is a bool key named after its alarm, such as alarm_external_stop; its filter alarm is filter_ok, the other way round.
  • A sensor alarm names the sensor by the controller's T number, as the controller's panel does.
  • When an alarm was raised (alarm_1_time) and when the damper last tested itself (damper_test_last_date) are in the controller's own clock, without a time zone.

Documentation

docs/models holds the manufacturers' manuals for every controller, with every register extracted to CSV.

A note to Nilan

Thank you for publishing the Modbus descriptions of your controllers, and for gateways that answer on their owner's own network. They are what lets an owner fit a Nilan unit into a home the way they want it.

We know a gateway can be updated remotely, and that its local access could be closed. Please keep it open. A local connection needs the email the gateway is paired with in your app, and it reaches the same values your Modbus descriptions give anyone who wires to the controller directly: it adds nothing Modbus does not already allow, and it makes your gateway worth more to the people who own one.

Disclaimer

Not affiliated with Nilan or Genvex. Use at your own risk; no warranty.

License

MIT. See LICENSE.

Metadata

Release files for nilan-connect 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nilan-connect 0.6.4
File Size Uploaded Provenance Actions
nilan_connect-0.6.4.tar.gz 11.7 MB With provenance Details for nilan_connect-0.6.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nilan-connect 0.6.4
File Interpreter ABI Platform Actions
nilan_connect-0.6.4-py3-none-any.whl Python 3 none any Details for nilan_connect-0.6.4-py3-none-any.whl

Total release size: 11.7 MB

Release files / nilan_connect-0.6.4.tar.gz

Download URL nilan_connect-0.6.4.tar.gz
Size 11.7 MB
Tags Source
SHA-256 checksum
How to use checksums
e4ad8a896fe67e63a012c7e62bc720975ad48c4e6f0e7fcbd38d92279168257b
BLAKE2b-256 checksum
How to use checksums
136f7d23174d8178754fbfcf3496870894ab17d2c2acb07e9f2154086aac2fd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / nilan_connect-0.6.4-py3-none-any.whl

Download URL nilan_connect-0.6.4-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d90f599ece4a4bfb5b7223cbb37d22826947c8115b54a064e889bfa03b38a2ed
BLAKE2b-256 checksum
How to use checksums
71c1ddd032b18f5891da92131d0a9c25e3212c9b0dcb2ba399b0e08fb5fc9218
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for nilan-connect 0.6.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nilan_connect-0.6.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page