OpenHAB1/2 Nilan heatpump

Sorry to step in here, but I´m trying to follow this modbus/Nilan thing you´ve going on here.
You all talk about a Nilan heatpump with the CTS 602 control.
I have Nilan ventilation, as well with the CTS 602 control. Does this modbus binding works for that one as well? If yes, how to I connect it to my Rpi3 ? (some USB dongle I suppose, and then some pins).

Btw. I´m using OpenHab 2.2

1 Like

Hi Kim, for me this question is quite offensive. That’s because I put in quite an effort explaining how to achieve a working connection to ones CTS602. On the other hand there is the evidence that you didn’t even take time to read 12 posts inside this very thread.

So… Please… read post #1, there are literally how to’s which should answer your questions.
Best

In the time of writing this the modbus plugin for OH2.2 is in alpha state. Using the legacy modbus_1.11 plugin works ~90% sure.

I wasn´t trying to be offending. I was trying to understand and following this thread, as I have a Nilan Ventilation (Nilan Comfort 300LR) with the CTS 602 control.

This thread seemed to be focused on a Nilan heatpump and a modbus binding for this.
Not a single time is the Nilan ventilation mentioned. I´m not even sure if its the same or not. But reading the cts 602 controle in the thread, it made me think, perhaps this gona work as the Nilan ventilation system I have. I simply wasnt sure, and second could not find any description of how to do this using an Rpi3 and OpenHab2.

Thats why I´d asked. If i knew, or found it obvious, I wouldn´t have asked!

Allright, IMHO as the controller board is the same it could work seamlessly. Sorry, I didn’t get the point that you are owning a ‘Nilan Ventilation’ system.

First: To bring up the communication between your Rpi and the CTS602 please try the link from “How to bring up the modbus communication to the Nilan CTS 602 controller” from above.
Second_Pre: Activate legacy bindings in OH2, Install the modbus 1.11+ addon.
Second: As my suggested solution includes a legacy binding (i.e. from OH1), you need to manually add the items configuration and the modbus ‘things’ configuration to your OpenHAB2 config directory (potentially in /etc/openhab2).

I think I got it covered. I have found an USB to RS485 on amazon. I´ll give it a try when it arrives.
Looking at your screenshot in post #5 above it looks very simular to my Nilan Comfort 300LR readings. My Nilan do have an option to integrate a heatpump as well but its an option and there fore not available right now . So I think its the same CTS 602 controller.

Will post feedback when after testing.

I created a new CTS 700 thread over here.

Where did you get the password, can you tell?

Nickma82
I have received the RS485 USB device today.
Anyway,

I just came to think. I have a picture of the CTS 602 controller print located inside of my Nilan Comfort 300LR.
It´s not quite the same as yours as far as I can tell. Perhaps a newer revision.
So I wondered if you could take a short look at it, and tell me if I´m correct, the interface/pins to use is located at the top left corner of the picture. And there are already 6 wires connected?
(Those wires are probably those connected to a pin interface located on the outside of the Comfort 300. This is where the CTS 602 display panel is connected. And if that is correct the modbus interface is available as well).

I agree.
The datasheet [page 2-3] hasn’t changed since then. I’d check where the wires blue and yellow wire’s (next to the USB plug) are going to.
I guess that they just connected it on the CTS602 board and left it open on the other side.
If that’s the case, check the 12V on the same screw terminal. If that’s ok too I’d give it a go connecting it.

If that’s not the case you can do two things (as the RS485 port is an official one): Call your installing electrician for datasheets or ask at Nilan headquarters.

Got it all wired up now. Trying to setup the connection using nickma´s config file only changig the host IP. But end up with connection and refuse error. Now what?

2018-02-08 23:58:52.350 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Connection refused (Connection refused). Connection TCPMasterConnection@1838ae[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]

2018-02-08 23:58:52.416 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Connection refused (Connection refused). Connection TCPMasterConnection@1838ae[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]

2018-02-08 23:58:52.481 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Connection refused (Connection refused). Connection TCPMasterConnection@1838ae[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]

2018-02-08 23:58:52.485 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Connection refused (Connection refused). Connection TCPMasterConnection@1838ae[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]

2018-02-08 23:58:52.490 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection TCPMasterConnection@1838ae[socket=Socket[unconnected]] for endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]: Connection refused (Connection refused)

2018-02-08 23:58:52.503 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (nilan_fans): Error getting a new connection for endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]. Error was: Unable to validate object

2018-02-08 23:58:52.507 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (nilan_fans) not connected -- aborting read request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@15e915a. Endpoint ModbusTCPSlaveEndpoint@12d9e4f[address=10.4.28.237,port=502]

Changed to use serial insted. Got a new problem. Seems like something hangs or something… baud rate is wrong. But according to my cfg, it´s set to 19200.
Will follow up tomorrow.

2018-02-09 00:55:22.536 [ERROR] [inding.modbus.internal.ModbusBinding] - Exception when parsing configuration parameter tcp.nilan.connection = 10.4.28.237:502:60:0:0:3  --  java.lang.IllegalArgumentException invalid baud rate: 502

==> /var/log/openhab2/openhab.log <==

2018-02-09 00:55:22.542 [ERROR] [org.apache.felix.configadmin        ] - [org.osgi.service.cm.ManagedService, org.osgi.service.event.EventHandler, id=367, bundle=234/mvn:org.openhab.binding/org.openhab.binding.modbus/1.11.0]: Updating property tcp.nilan.connection of configuration org.openhab.modbus caused a problem: Exception when parsing configuration parameter tcp.nilan.connection = 10.4.28.237:502:60:0:0:3  --  java.lang.IllegalArgumentException invalid baud rate: 502

org.osgi.service.cm.ConfigurationException: tcp.nilan.connection : Exception when parsing configuration parameter tcp.nilan.connection = 10.4.28.237:502:60:0:0:3  --  java.lang.IllegalArgumentException invalid baud rate: 502

	at org.openhab.binding.modbus.internal.ModbusBinding.updated(ModbusBinding.java:702) [234:org.openhab.binding.modbus:1.11.0]

	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updated(ManagedServiceTracker.java:189) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.updateService(ManagedServiceTracker.java:152) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.helper.ManagedServiceTracker.provideConfiguration(ManagedServiceTracker.java:85) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.provide(ConfigurationManager.java:1479) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.ConfigurationManager$ManagedServiceUpdate.run(ConfigurationManager.java:1435) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.UpdateThread.run0(UpdateThread.java:141) [7:org.apache.felix.configadmin:1.8.16]

	at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:109) [7:org.apache.felix.configadmin:1.8.16]

	at java.lang.Thread.run(Thread.java:748) [?:?]

Hi Kim,
you bought an USB->RS485 dongle right? If true you can NOT connect to that device via TCP/IP, you have to use the serial version!
I would recommend you give my bringup (via python). Ultimatelly you probably need a config like this.

Nick

Hi NickMa.

Yeah, I bought the InCircut RS485 dongle. (simular to the one you have with the four dip-switches)
I figured out that it couldnt do the TPC/IP connection, så I changed the config to using serial insted. But that just gave me a new, another error.

I have no idea how to execute this .py script you referering to. I´m relative new to Rpi, Linux and OpenHab2. Infact I´m not even sure if the Rpi is plug&play ready regarding the RS485 dongle, and have no idea how to test it.
I just, wired the Nilan to the dongle according to the explanation, pluged in the dongle, installed the binding, and then trying to set it up ind the modbus.cfg with a few test items in the nilan.items file.

My modbud.cfg looks like this:

serial.nilan.connection=/dev/ttyUSB0:19200:8:even:1:rtu
serial.nilan.id=30
serial.nilan.start=200
serial.nilan.length=16
serial.nilan.type=input
serial.pollinterval=2000

serial.nilan.valuetype=int16

# write out nilan connection
writemultipleregisters=true
serial.nilan2.connection=/dev/ttyUSB0:19200:8:even:1:rtu
serial.nilan2.id=30
serial.nilan2.start=1001
serial.nilan2.length=4
serial.nilan2.type=holding

And this is my nilan.items

Number nilan_t0		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:0"}
Number nilan_t1		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:1"}
Number nilan_t2		"t2_tmp variable [%2.2f °C]" 		<temperature> (heat_nilan)		{modbus="nilan:2"}
Number nilan_t3		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:3"}
Number nilan_t4		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:4"}
Number nilan_t5		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:5"}
Number nilan_t6		"temporary variable will be processed in .rules file[%2.2f °C]" 		<temperature> (heat_nilan)	{modbus="nilan:6"}
Number nilan_t7		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:7"}
Number nilan_t8		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:8"}
Number nilan_t9		"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:9"}
Number nilan_t10	"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:10"}
Number nilan_t11	"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:11"}
Number nilan_t12	"temporary variable will be processed in .rules file[%2.2f °C]" 		<temperature> (heat_nilan)	{modbus="nilan:12"}
Number nilan_t13	"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:13"}
Number nilan_t14	"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:14"}
Number nilan_t15	"temporary variable will be processed in .rules file" 		<temperature> (heat_nilan)		{modbus="nilan:15"}

Both examples have been copied from https://github.com/openhab/openhab1-addons/wiki/Samples-Binding-Config#serial-modbus-nilan-heatpump-configuration

Check the dongle - open a terminal and execute the following four commands

sudo dmesg | grep ttyUSB

wget https://raw.githubusercontent.com/nickma82/nilan_communication_bringup/master/src/nilan.py
chmod u+x ./nilan.py
./nilan.py

post all output here

Ahh that simple…
Thx NickMa… Will give it a try as soon as I get home this evening.

What I´m trying to achieve isn´t quite rocketscience :slight_smile: Or at least, I think it isn´t :grin:

This is the output of your .py:

[18:30:10] openhabian@openHABianPi:~$ sudo dmesg | grep ttyUSB
[    3.938890] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
[18:30:24] openhabian@openHABianPi:~$
[18:30:24] openhabian@openHABianPi:~$ wget https://raw.githubusercontent.com/nickma82/nilan_communication_bringup/master/src/nilan.py
--2018-02-09 18:30:24--  https://raw.githubusercontent.com/nickma82/nilan_communication_bringup/master/src/nilan.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.36.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.36.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2065 (2.0K) [text/plain]
Saving to: ‘nilan.py’

nilan.py                             100%[=====================================================================>]   2.02K  --.-KB/s   in 0s

2018-02-09 18:30:24 (10.2 MB/s) - ‘nilan.py’ saved [2065/2065]

[18:30:24] openhabian@openHABianPi:~$ chmod u+x ./nilan.py
[18:30:24] openhabian@openHABianPi:~$ ./nilan.py
Traceback (most recent call last):
  File "./nilan.py", line 4, in <module>
    import minimalmodbus
ImportError: No module named minimalmodbus

Looks very good, your USB dongle is attachted to /dev/ttyUSB0

That was correct too, you are just missing the module minimalmodbus. Install it and run nilan.py again…

sudo apt-get -y install python-pip
sudo pip install pyserial minimalmodbus
./nilan.py

You should see something like that

TESTING Nilan Connection
__main__.Nilan<id=0xb6c779e0, address=30, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=True, serial=Serial<id=0xb6c7b3b0, open=True>(port='/dev/ttyUSB0', baudrate=19200, bytesize=8, parity='E', stopbits=1, timeout=1.0, xonxoff=False, rtscts=False, dsrdtr=False)>

MinimalModbus debug mode. Writing to instrument (expecting 7 bytes back): '\x1e\x03\x03\xeb\x00\x01\xf6\x15'
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1518207950131.8 ms, minimum silent period: 2.01 ms.
MinimalModbus debug mode. Response from instrument: '\x1e\x03\x02\x00\x01\xecF' (7 bytes), roundtrip time: 18.1 ms. Timeout setting: 1000.0 ms.

old userVentSet:             1
new userVentSet:             2
Connection to the Nilan instrument looks good!

Get some errors when trying to install pyserial minimalmodbus

[00:58:28] openhabian@openHABianPi:~$  sudo apt-get -y install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

[00:58:49] openhabian@openHABianPi:~$ sudo pip install pyserial minimalmodbus
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
    from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead

Never saw that before, quick lookup; Just following them doing:

sudo apt-get remove python-pip
sudo easy_install pip

# and then once again
sudo pip install pyserial minimalmodbus
./nilan.py