OpenHAB1/2 Nilan heatpump

To be honest. I think it is. As all pins are wired inside the CTS controller, are the same pins wired on the outher interface/ green pin interface, (and this is where the User Panel is connected as well). I really assume this is where the connection is suppose to be established. I also read about it in the Nilan doc. However, Nilan has changed the documentation as of January 2018. Now they have changed it to a grey pin interface where you have to use a plug on the cable. (http://reader.livedition.dk/nilan/70/html5/ page 12-13 showing the location, and page 14-15 showing the pins).

On my Nilan Comfort 300LR (previous to the January 2018 version), the pin interface is green as showing in the picture.
Others have been using the green interface on the outside of the Nilan as well to connect modbus connection, (Visility, an IHC optional, according to this link http://www.visility.com/applikationer/nilan-ventillation.aspx).

So in short - I really assume all pins have been wired from the outside interface to the inside CTS controller board.

And it seems removing alle tcp.nilan from the modbus.config file did something (after an reboot). Now I start getting readings in the log, and guess what… No errros :grin:

2018-02-10 14:57:13.119 [INFO ] [b.core.service.AbstractActiveService] - Modbus Polling Service has been started
2018-02-10 14:57:14.360 [vent.ItemStateChangedEvent] - nilan_onoff changed from NULL to ON
2018-02-10 14:57:14.371 [vent.ItemStateChangedEvent] - nilan_user_operation_mode changed from NULL to 3
2018-02-10 14:57:14.374 [vent.ItemStateChangedEvent] - nilan_vent changed from NULL to 2
2018-02-10 14:57:14.378 [vent.ItemStateChangedEvent] - nilan_user_tempset changed from NULL to 2300
2018-02-10 14:57:15.287 [vent.ItemStateChangedEvent] - nilan_t8 changed from NULL to 177
2018-02-10 14:57:15.291 [vent.ItemStateChangedEvent] - nilan_t7 changed from NULL to 1474
2018-02-10 14:57:15.301 [vent.ItemStateChangedEvent] - nilan_t9 changed from NULL to -4000
2018-02-10 14:57:15.303 [vent.ItemStateChangedEvent] - nilan_t4 changed from NULL to 353
2018-02-10 14:57:15.307 [vent.ItemStateChangedEvent] - nilan_t3 changed from NULL to 1533
2018-02-10 14:57:15.322 [vent.ItemStateChangedEvent] - nilan_t6 changed from NULL to 0
2018-02-10 14:57:15.330 [vent.ItemStateChangedEvent] - nilan_t5 changed from NULL to 0
2018-02-10 14:57:15.336 [vent.ItemStateChangedEvent] - nilan_t13 changed from NULL to 0
2018-02-10 14:57:15.338 [vent.ItemStateChangedEvent] - nilan_t12 changed from NULL to 0
2018-02-10 14:57:15.345 [vent.ItemStateChangedEvent] - nilan_t15 changed from NULL to 1624
2018-02-10 14:57:15.369 [vent.ItemStateChangedEvent] - nilan_t14 changed from NULL to 0
2018-02-10 14:57:15.372 [vent.ItemStateChangedEvent] - nilan_t11 changed from NULL to 0
2018-02-10 14:57:15.375 [vent.ItemStateChangedEvent] - nilan_t10 changed from NULL to -4000
2018-02-10 14:57:15.378 [vent.ItemStateChangedEvent] - nilan_t0 changed from NULL to 1766
2018-02-10 14:57:15.381 [vent.ItemStateChangedEvent] - nilan_t2 changed from NULL to 0
2018-02-10 14:57:15.385 [vent.ItemStateChangedEvent] - nilan_t1 changed from NULL to 0

Now onto, what the heck are those reading?

and second…

How should my modbus.cfg in /services/modbus.cfg look like? I´m totally lost now after changing the modbus.config which seem to do something, and then having my modbus.cfg showing something totally different. I thought they would/should be the same.

Congratulations!

  • See here
    -> Technical Data -> Automation … Which nilan_t* sensor is what?
    -> Downloads -> CTS602 Modbusprotokol … for a list of all modbus addresses available with the CTS602

From now on you keep edition the /etc/openhab2/services/modbus.cfg and leave the other one alone.

Start reading the configs posted here by starze and myself (follow the links) and check those out. Understand them! Start understanding the item-configuration.

Most of the values are times 100 (e.g. your room target temperature is set to 23°C nilan_user_tempset==2300, fresh-air intake t8 is 1.77°C). How do I know which value is what - again I gave it 10minutes and followed the links I’m just about to post. If you want to know how to divide them - follow the examples.

Give the links a couple of hours and read everything you can find; Afterwards more is going to get clear for you. No, it’s not rocket science; that’s why I wrote “a couple of hours” and not years :wink:

Best, Nick

Hi Nickma…

I´m back :slight_smile: I have read alot, I have learned alot, and i´m almost there…
But there is a small thing nagging me…
I can´t seem to find the correct status of the Bypass (no items for the actual Bypass status)…

Nilan_output_BypassOpen and Nilan_output_BypassClose is the status while the Bypass is on the move. It will only be OPEN in 4 minutes, then both are closed.

When BypassOpen has run (been OPEN) for 4 minutes, it will change to the state of CLOSE, even though my wall-panel says, Bypass is open. (which is the actual state after it has been closing or opening for 4 minutes).

In you message #5 on the screenshot, I see you have this Bypass status… I can´t seem to find this in the list of items from the original items file, either from you´re example or starze´s files on github…

Can you/anyone tell me, how to get the actual status of the Bypass from the CTS602 ?

Hey guys.
I got a question.
I recently got a new Nilan VP18 heatpump, and I’ve installed openhabian on RPi, using Starze’s config files.
It work quite nicely for the most part - however, one thing is really bothering me.
In the CTS602 documentation it states that all the models should be able to report the various software versions.
I can’t seem to get this to work. In Basic UI they show a value of “-”, and in HabPanel they show a value of “Null”.
Any help?

Hi @Kim_Andersen and @arjepsen in both of your cases, most likely is that you are receiving the wrong register with your openhab conifg.

You got to look at the Modbus Datasheet (of your device) for the correct register of what you wanted to read. After having that information look up what your modbus config says and if that’s the register you are reading from the instance (device).

Well, I never got the strings to work. But it hasn´t been on my first priority list, so I might take another look at it again some day.

Hallo,

I have a lite problem

connectin betwen CTS602 and Server OK

TESTING Nilan Connection
__main__.Nilan<id=0x7f24bXXXXXXXX, address=30, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=True, serial=Serial<id=0x7f24b724fd90, 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' (1E 03 03 EB 00 01 F6 15)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1532782932550.3 ms, minimum silent period: 2.01 ms.
MinimalModbus debug mode. Response from instrument: '\x1e\x03\x02\x00\x02\xacG' (1E 03 02 00 02 AC 47) (7 bytes), roundtrip time: 17.0 ms. Timeout setting: 1000.0 ms.

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

but the test side is empty

I have installed:
OpenHAB1/2 Nilan heatpump

Bindings:

-Astro Binding
binding-astro - 2.3.0

-Modbus Binding
binding-modbus1 - 1.12.0

Persistence:

-RRD4j Persistence
persistence-rrd4j - 1.12.0

Transformations

-Javascript Transformation
transformation-javascript - 2.3.0

-Map Transformation
transformation-map - 2.3.0

Hi what does the console command openhab-cli showlogs say?
(Hint: You can pipe the output into a file with openhab-cli showlogs | tee openhab.log, break with Ctrl+C)

Hello,

I solved the problem a few days later.
There was a problem in the nilan.itmes list.

Hi Daniel, sharing your problem plus solution would be nice for those struggling with the same issue. :wink:
Best, Nick

Need some serious help here.
I just added a new USB device to my Rpi, and then my Nilan modbus communication doesn´t work anymore… It looks like adding this new USB device made some changed for the RS486 InCircet dongle. I suspect it no longer is connected to tty/USB0…

[23:10:55] openhabian@openHABianPi:~$ sudo dmesg | grep ttyUSB
[sudo] password for openhabian:
[    7.046689] usb 1-1.4: cp210x converter now attached to ttyUSB0
[    7.050816] usb 1-1.3.2: FTDI USB Serial Device converter now attached to ttyUSB1
[23:11:03] openhabian@openHABianPi:~$ wget https://raw.githubusercontent.com/nickma82/nilan_communication_bringup/master/src/nilan.                          py
--2018-11-04 23:12:47--  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.2’

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

2018-11-04 23:12:47 (9.14 MB/s) - ‘nilan.py.2’ saved [2065/2065]

[23:12:47] openhabian@openHABianPi:~$ chmod u+x ./nilan.py
[23:12:47] openhabian@openHABianPi:~$ ./nilan.py
TESTING Nilan Connection
__main__.Nilan<id=0x76897d28, address=30, mode=rtu, close_port_after_each_call=False, precalculate_read_size=True, debug=True, seri                          al=Serial<id=0x768bb470, open=True>(port='/dev/ttyUSB0', baudrate=19200, bytesize=8, parity='E', stopbits=1, timeout=1.0, xonxoff=F                          alse, rtscts=False, dsrdtr=False)>

MinimalModbus debug mode. Writing to instrument (expecting 7 bytes back): '\x1e\x03\x03\xeb\x00\x01\xf6\x15' (1E 03 03 EB 00 01 F6                           15)
MinimalModbus debug mode. No sleep required before write. Time since previous read: 1541369578750.3 ms, minimum silent period: 2.01                           ms.
MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 1001.3 ms. Timeout setting: 1000.0 ms.

Traceback (most recent call last):
  File "./nilan.py", line 60, in <module>
    old_userVent_value = n.get_userVent()
  File "./nilan.py", line 38, in get_userVent
    return self.read_register(1003, numberOfDecimals=0, signed=False, functioncode=3)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 258, in read_register
    return self._genericCommand(functioncode, registeraddress, numberOfDecimals=numberOfDecimals, signed=signed)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 697, in _genericCommand
    payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 795, in _performCommand
    response = self._communicate(request, number_of_bytes_to_read)
  File "/usr/local/lib/python2.7/dist-packages/minimalmodbus.py", line 930, in _communicate
    raise IOError('No communication with the instrument (no answer)')
IOError: No communication with the instrument (no answer)

I modified the:
/ etc/opehba2/services/modbus.cfg file to tty/USB1 as well as the /var/lib/openhab2/config/org/openhab/modbus.cfg to USB1
I cleared cache and tmp…

But I end up with tons of errors like this:

2018-11-04 23:26:49.166 [ERROR] [et.wimpi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.169 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@163e252[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@a5ddf9[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.171 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@163e252[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@a5ddf9[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.174 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@163e252[portName=/dev/ttyUSB1,port=<null>] for endpoint ModbusSerialSlaveEndpoint@a5ddf9[portName=/dev/ttyUSB1]: Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.177 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (nilan_holding_user2functions): Error getting a new connection for endpoint ModbusSerialSlaveEndpoint@a5ddf9[portName=/dev/ttyUSB1]. Error was: Unable to validate object
2018-11-04 23:26:49.179 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (nilan_holding_user2functions) not connected -- aborting read request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@858a77. Endpoint ModbusSerialSlaveEndpoint@a5ddf9[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.191 [ERROR] [et.wimpi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.193 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@1195458[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.235 [ERROR] [et.wimpi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.238 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 2/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@1195458[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.280 [ERROR] [et.wimpi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.283 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 3/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@1195458[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.286 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 3, throwing last error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@1195458[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.289 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@1195458[portName=/dev/ttyUSB1,port=<null>] for endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]: Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.293 [WARN ] [.binding.modbus.internal.ModbusSlave] - ModbusSlave (nilan_holding_user1functions) not connected -- aborting read request net.wimpi.modbus.msg.ReadMultipleRegistersRequest@1d25f5c. Endpoint ModbusSerialSlaveEndpoint@1d2a223[portName=/dev/ttyUSB1]
2018-11-04 23:26:49.301 [ERROR] [et.wimpi.modbus.net.SerialConnection] - Could not get port identifier, maybe insufficient permissions. null
2018-11-04 23:26:49.303 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Could not get port identifier, maybe insufficient permissions. null. Connection SerialConnection@1b55d46[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@5466b8[portName=/dev/ttyUSB1]

Can someone help here??

Arrgh!

I just ran

[00:02:10] openhabian@openHABianPi:~$ sudo dmesg | grep ttyUSB
[sudo] password for openhabian:
[    7.072413] usb 1-1.3.2: FTDI USB Serial Device converter now attached to ttyUSB0
[    7.094748] usb 1-1.4: cp210x converter now attached to ttyUSB1
[00:02:19] openhabian@openHABianPi:~$

And now the RS486 dongle is back to USB0.
I changed the cfg and config file back to USB0, and now it seems like it´s running again…
What the heck is going on??

Check out these instructions… You might want setup udev rules to have fixed name for some specific device https://www.openhab.org/addons/bindings/modbus/#serial-port-configuration

I have succesfully configured the configured the modbus connection to a raspberry pi zero locked inside the heatpump enclosing. I want to get a connection from that PI to another machine running openhab, has anyone had any success accomplishing this? I’ve tried to set up a virtual comport using socat, but all i get is an ‘invalid argument’ error.

Traceback (most recent call last):
  File "test.py", line 5, in <module>
    m = CTS602API('/dev/pts/1') # change appropriately
   File "/home/user/pycts602/pycts602api.py", line 19, in __init__
     self.serial.parity = serial.PARITY_EVEN
   File "/home/pi/.local/lib/python2.7/site-packages/serial/serialutil.py", line 335, in parity
      self._reconfigure_port()
   File "/home/user/.local/lib/python2.7/site-packages/serial/serialposix.py", line 438, in _reconfigure_port
      [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
termios.error: (22, 'Invalid argument')

Hi @epqr ,
this seems like the module you use pycts602 is using minimalmodbus which is using pyserial, which produces that error see github::pyserial::issue196.
Seems to be a RaspberryPi specific issue, which is a little bit off-topic here. Please get yourself involved in the termios ticket/issue.

However: you can consider using mbusd which is a Modbus_Serial->Modbus_TCP software gateway (working on RPi) if Modbus TCP is an option on your client/consumer side.

I just updated my openhab from 2.3 stable to 2.4.0 M8 last night… I did fear that I would run into trouble with the modbus connection to my Nilan Ventilation system with CTS602 interface. And so I did :tired_face:

The old modbus binding is gone, and now there is this new one (i believe they call it modbus2 binding). And its alot different than the old one…

I wonder if anyone could help me or guide me on how to get from the old to the new modbus binding? I´m honestly no good at modbus at all. I understand very little, though I have tried several times. And this new binding didnt make my understanding much better. Infact it got alot worse now, as it seems it requires deep knowlegde of the way modbus is working.

I would highly appreciate any help I can get on this one.

Just (at the morning 20.12.2018) made upgrade from openhab2 to newer version and Nilan sitemap stopped showing data. At the sametime Grafana graphs stoppped.

Tests done

  • Nilan.py = “Connection to the Nilan instrument looks good!”

Troubleshooting

  • Installed/reinstalled: Map Transformation transformation-map - 2.4.0 (mapping errors in logs)

The Openhab logs doesn’t show (or I don’t watch correct things) nothing special. Will continue and will inform as soon I found something. Open ideas are welcom :grinning:

Which newer openhab version… 2.4 ?
In that case, you´ll need to start all over, cause the old modbus binding is no longer supported in openhab 2.4. You need to use the new modbus binding, which requires alot of changes to your seup…

This thread might give you a clue:

In this thread you´ll be able to follow my transistion from old modbus to the new one with my Nilan Comfort 300LR (Ventilation system), with CTS602 interface.

Thanks! Actually it’s fun to have a little configuration puzzle for holidays.