GithubHelp home page GithubHelp logo

pjuzeliunas / nilan-hk Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 520 KB

Nilan CTS700 heatpump accessory for Apple HomeKit

License: MIT License

Go 100.00%
apple-homekit homekit modbus modbus-tcp nilan raspberry-pi

nilan-hk's Introduction

Nilan-HK is experimental HomeKit accessory implementation for Nilan (R) CTS700 heatpump. It communicates with Nilan heatpump via Modbus protocol and exposes various readings and settings using Apple HomeKit Accessory Protocol (HAP). Nilan can be accessed and controller from HomeKit-enabled apps, such as Apple Home or Eve.

Software is implemented in Go and is based on hc framework.

Nilan settings in Eve app:

Hardware setup

Accessory software is designed for Raspbery Pi computer connected to Nilan heatpump via Ethernet cable. For complete hardware setup, refer to this wiki page.

Software setup (quick guide)

  1. Install Go
  2. Configure environment variables:
    • HK_PIN: 8 digit PIN code which must be used to authenticate iOS device against accessory. E.g. "00102003".
    • NILAN_ADDRESS (optional): Address and port (default 502) of Nilan heatpump. If variable is not provided, accessory software uses factory address of Nilan, which is "192.168.5.107:502".
  3. Build and run the app with:
go build -o nilan-hk nilan.go
./nilan-hk

Software setup (verbose guide)

  1. Install Go (minimum version 1.11). For Raspbian, run the following commands:
wget https://storage.googleapis.com/golang/go1.11.8.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.11.8.linux-armv6l.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
source ~/.profile
  1. Clone this repo
git clone pjuzeliunas/nilan-hk
cd pjuzeliunas/nilan-hk
  1. Install dependencies
go get all
  1. Build accessory software:
go build -o nilan-hk nilan.go
  1. Provide environment variables and run the software:
export HK_PIN=00102003
export NILAN_ADDRESS=192.168.1.20:502
./nilan-hk
  • HK_PIN: 8 digit PIN code which must be used to authenticate iOS device against accessory.
  • NILAN_ADDRESS (optional): Address and port (default 502) of Nilan heatpump. If variable is not provided, accessory software uses factory address of Nilan, which is "192.168.5.107:502".

If various Nilan readings start being logged, then your software is running as it should. You should now be able to add the accessory to HomeKit-enabled app.

Set nilan-hk up as a service

If you want Nilan-HK to be running in background and to start automatically after every reboot, then you have to make it a service. Steps are for Raspbian OS, but you can use them for inspiration on other OS too.

  1. First of all, build nilan-hk binary as described in the previous steps.
  2. Copy nilan-hk to /usr/bin/
  3. Create /etc/systemd/system/nilan-hk.service text file with the following content:
[Unit]
Description=Serve Nilan HomeKit via HAP

[Service]
Environment=NILAN_ADDRESS=192.168.1.20:502
Environment=HK_PIN=00102003
ExecStart=/usr/bin/nilan-hk
Restart=on-failure

[Install]
WantedBy=multi-user.target 

Remember to adjust environment variables in the file. NILAN_ADDRESS variable is optional.

  1. Start the service:
sudo systemctl start nilan-hk.service
  1. Enable the service after every reboot:
sudo systemctl enable nilan-hk.service

Limitations and notes

  • Room temperature thermostat will always show OFF state when it is set to AUTO mode. That doesn't mean that heating/cooling is actually off. It just runs is auto mode. This limitation is twofold:

    • Apple HAP does not permit having other thermostat (actual) state values than off/heating/cooling.
    • In the world of Nilan, "heating" means normal operation without cooling, "cooling" means normal operation without heating and "auto" means just normal operation, in which heating and cooling can be done at the same time. There is no easy way of knowing wether Nilan is heating or cooling at the moment, as it can be doing both in parallel.
  • Switching Central Heating off will simply put it to standby mode (aka pause) for 180 days. After 180 days it will turn on automatically. Swithing it back on will resume normal operation. You can always prolong standby mode by 180 days by turning the switch on and off again.

  • Same logic applies for Hot Water Production switch: off means 180 days pause.

  • Some HAP characteristics of Nilan have non-standard read/write permission attribute, which means that UI in some apps (like Apple Home) might appear distorted. The following services are affected by non-standard access permission attribute on some characteristics:

    • Fan:
      • Active: is read-only.
      • According to HAP, Active characteristing should be writable. However, Nilan made it pretty difficult to switch the ventilation off in its own CTS700 console (most likely because the ventilation system is designed for running 24/7). With full respect to Nilan design, author made a deliberate choice not to allow switching the ventilation off using HomeKit protocol.
      • In Apple Home app: switching the Fan off will have no effect.
    • Supply Flow thermostat:
      • TargetHeatingCoolingState is read-only.
      • According to HAP, TargetHeatingCoolingState of thermostat should permit write operation with one of the 4 possible values: auto, cool, heat or off. Some values are not logical in Nilan supply flow settings, and therefore author decided to disable write access.
    • Hot Water thermostat:
      • TargetHeatingCoolingState is read-only.
      • Same reasoning as in supply flow thermostat.

Disclaimer

This initial version of software is developed by home automation enthusiast (outside Nilan company) and is based on open Nilan CTS700 Modbus protocol.

Nilan is a registered trademark and belongs to Nilan A/S.

nilan-hk's People

Contributors

pjuzeliunas avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

matej

nilan-hk's Issues

Services switching to "No Response" mode

Thank you for sharing this! I was really surprised to find somebody already made the effort to connect Nilan devices to HomeKit. Great stuff!

I have a Compact P and wanted to give this a try. I have the (older) non-touch CTS700, which might be the reason that the registers you used don't work with my device. But I managed to adapt those by following the documentation from 2016-02-17_CTS700_Modbus_protokol.pdf.

Both device updates and the HomeKit to Nilan communication work great. There is however a problem I can't figure out. Some of the services frequently display a "No Response" status, despite still showing correct values and correctly processing input.

I wonder if you encoundered anything like this?

IMG_0088

IMG_0089

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.