Openhab / Nilan EC9 (VP18CEK) / Modbus binding

Hi,

I’ve been trying to get Openhab and Nilan EC9 (VP19CEK) communicating but so far without any real results.

My current setup is:

Modbus binding:
modbus:serial.nilan.connection=COM2:19200:8:even:1:rtu
modbus:serial.nilan.id=30

modbus:serial.nilan.start=200
modbus:serial.nilan.length=16
modbus:serial.nilan.type=input
modbus:serial.pollinterval=2000

modbus:serial.nilan.valuetype=int16

write out nilan connection

modbus:writemultipleregisters=true
modbus:serial.nilan2.connection=COM2:19200:8:even:1:rtu
modbus:serial.nilan2.id=30
modbus:serial.nilan2.start=1001
modbus:serial.nilan2.length=4
modbus:serial.nilan2.type=holding

Modpoll with command “Modpoll COM2” doesn’t seem to find anything.

It’s a little suspicious that TX/RX lights blink only when I plug in the USB-interface
After couple of weeks the great ideas are coming to end. Any help from professionals? :slight_smile:

Sources
https://groups.google.com/forum/#!topic/openhab/LDLtD2rJN1w


http://shop.in-circuit.de/product_info.php?cPath=38&products_id=81

The logs:

2016-12-10 18:40:15.953 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.8.3).
2016-12-10 18:40:20.500 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
2016-12-10 18:40:21.078 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
2016-12-10 18:40:29.125 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'demo.sitemap’
2016-12-10 18:40:29.593 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
2016-12-10 18:40:34.953 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /classicui/openhab.app
2016-12-10 18:40:40.109 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'nilanrules.rules’
2016-12-10 18:40:42.468 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob] - Error during the execution of rule nilan t0-15 sensor division
java.lang.RuntimeException: The name ‘heat_nilan’ cannot be resolved to an item or type.
at org.openhab.model.script.interpreter.ScriptInterpreter.internalFeatureCallDispatch(ScriptInterpreter.java:67) ~[na:na]
at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._evaluateAbstractFeatureCall(XbaseInterpreter.java:658) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_111]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_111]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_111]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_111]
at org.eclipse.xtext.util.PolymorphicDispatcher.invoke(PolymorphicDispatcher.java

etc…

Modbus problem or something else?

Please follow the trouble shooting steps in the wiki https://github.com/openhab/openhab/wiki/Modbus-Binding#troubleshooting-1

Hope it works for you!

Best
Sami

For serial, it is really worth using Modbus binding version 1.9 not the bundled 1.8.3 version

Lights on which end? But yes, if Modpoll doesn’t work either you need to look at basics - baud settings, wiring, COM port etc.

RS485 markings for A/B wires can be inconsistent sometimes, worth swapping to try?
Using an old mains cable as RS485 really isn’t going to work well, this ought to be twisted pair - a pair in a Cat5 cable do.
Please try to keep signal cables away from mains power cables, for safety as well as interference.

Thanks for good tips!

Made some changes and updates based on your comments:

Changes

  • Changed the cable to CAT5e
  • Updated modbus binding to 1.9
  • Tested connection with Nickma82 connection tester: http://pastebin.com/XvCm3VrE seems to work?

Results

Something is still broken but I can’t figure out what.

This is maybe the biggest question:
18:11:47.494 [ERROR] [.o.m.r.i.engine.ExecuteRuleJob:57 ] - Error during the execution of rule nilan t0-15 sensor division
java.lang.RuntimeException: The name ‘heat_nilan’ cannot be resolved to an item or type.

Thanks for the update!

It looks like the items are not parsed or what? Can you paste the configurations as is, without combining different configurations to same file. I’m thinking of syntax issue preventing anything working??

At least there is no modbus mentioned in the logs so it’s something with the actual configurations

Perhaps you should try to continue the troubleshooting and have minimal configuration.

Best
Sami

Changes

  • Renamed nilan.item -> nilan.items like it should be.

Configuration
openhab.cfg http://pastebin.com/VgCusA13
demo.rules http://pastebin.com/EDJ7W2im
nilan.item http://pastebin.com/4fFTjMKs //BIG error here. Should be nilan.items not nilan.item FIXED
kallio.sitemap http://pastebin.com/miBJbv6u

Logs
openhab.log http://pastebin.com/kYx4hXAm

19:57:10.002 [DEBUG] [.o.m.r.i.engine.ExecuteRuleJob:53   ] - Executing scheduled rule 'nilan t0-15 sensor division'
19:57:10.934 [ERROR] [o.u.i.items.ItemUIRegistryImpl:438  ] - Cannot retrieve item nilan for widget org.openhab.model.sitemap.Text

Result

  • Sitemap loads icons.
  • No data in sitemap

you might want to remove the default openhab cfg as it is being loaded as well

 19:56:26.693 [DEBUG] [o.config.core.ConfigDispatcher:146  ] - Processing openHAB default configuration file 'c:\NILAN\configurations\openhab_default.cfg'.
 19:56:26.783 [DEBUG] [o.config.core.ConfigDispatcher:168  ] - Processing openHAB main configuration file 'c:\NILAN\configurations\openhab.cfg'.

Also, as far as I can see there is no item called ‘nilan’, so the error is expected? Perhaps the sitemap is wrong?

Also, the modbus configuration is wrong in openhab cfg :

modbus:serial.pollinterval=2000

There is no such parameter. See wiki for the “poll” parameter

Sami

The connection to the device (instrument) looks good. Reading from and writing to the device is successful.
Best

Link to the connection tester

Alllrightey… Things go forward step-by-step. I’ve been watching Notepad++ for like 6hrs today :slight_smile:

After couple of tests/changes I think I managed to fix some things.

Changes

  • Fixed the modpoll (modbus:poll=2000) Still a bit open what it should be.
  • Fixed settings for RS485-USB converter (see pictures attached at bottom)
  • Copied once again accidentally deleted org.openhab.binding.modbus-1.9.0-SNAPSHOT.jar

Situation:

  • I can change fan speed in Nilan
  • I can change operation mode in Nilan
  • No temperatures showing in sitemap
  • Modbus related error in logs

Configuration
openhab.cfg http://pastebin.com/VgCusA13
demo.rules http://pastebin.com/EDJ7W2im
nilan.items http://pastebin.com/4fFTjMKs
kallio.sitemap http://pastebin.com/miBJbv6u

Error in log

22:32:49.003 [DEBUG] [.o.m.r.i.engine.ExecuteRuleJob:53 ] - Executing scheduled rule ‘nilan t0-15 sensor division’
22:32:49.891 [ERROR] [i.modbus.io.ModbusRTUTransport:171 ] - Last request: 1e 04 00 c8 00 10 72 57
22:32:49.892 [ERROR] [i.modbus.io.ModbusRTUTransport:172 ] - failed to read: Error reading response (EOF)
22:32:49.910 [ERROR] [w.m.io.ModbusSerialTransaction:199 ] - execute try 1/3 error: I/O exception - failed to read. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@18894 (unit id 30 & transaction 8). Serial parameters: SerialParameters@1398d43[portName=COM3,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
22:32:49.980 [INFO ] [w.m.io.ModbusSerialTransaction:213 ] - execute eventually succeeded with 1 re-tries. Request: net.wimpi.modbus.msg.ReadInputRegistersRequest@18894. Serial parameters: SerialParameters@1398d43[portName=COM3,baudRate=19200,flowControlIn=none,flowControlOut=none,databits=8,stopbits=1,parity=even,encoding=rtu,echo=false,receiveTimeoutMillis=1500]
22:32:50.004 [DEBUG] [.o.m.r.i.engine.ExecuteRuleJob:53 ] - Executing scheduled rule ‘nilan t0-15 sensor division’

Pictures
Should the “Receive (Bytes)” be lower? Nilan manual says “Packet size: Max. 255 bytes”

These are as described in Nilan manual

Hopefully I can write a short wiki if this thing gets working. I have feeling that we have other Nilan EC9 users also here in Finland.

Nice progress!

Regarding error in the logs: Note that read is eventually successfull on second try.

Does the log reveal cases where three retries is not enough?

Do not know what the usb parameter means, have not worked with these really… It’s possible that tuning those parameters help but not sure really. Remember to restart openhab if you change parameters.

Do you have anything in the events log? I wonder why the temperatures are missing if the modbus reads successfully. Do you have any other errors in the logs?

I would like you to try out an experimental modbus binding that tries to read again even though the serial library returns EOF (end of file). I will come back to this next week.

Best
Sami

New day, new changes:

Changes

  • No changes to configuration except logging:
  • Added to logback_debug.xml:
<logger name="net.wimpi.modbus" level="TRACE" />
<logger name="org.openhab.binding.modbus" level="TRACE" />

Logs

No win today.

Actually if you read the log carefully you can note that reads are successful.

execute eventually succeeded with 1 re-tries.

What do you get in the events log?

Best
Sami

Hmm…

Seems to be ok

2016-12-12 18:35:31 - nilan_onoff state updated to ON
2016-12-12 18:35:31 - nilan_user_operation_mode state updated to 3
2016-12-12 18:35:31 - nilan_vent state updated to 1
2016-12-12 18:35:31 - nilan_user_tempset state updated to 3000
2016-12-12 19:09:46 - nilan_onoff state updated to ON
2016-12-12 19:09:46 - nilan_user_operation_mode state updated to 3
2016-12-12 19:09:46 - nilan_vent state updated to 1
2016-12-12 19:09:46 - nilan_user_tempset state updated to 3000
2016-12-12 19:16:16 - nilan_vent state updated to 2

I have a feeling that it might be something to do with items or the sitemap maybe.It’s still a bit mystery why it shows everything except none of the temperatures.

Are these in sync?

SITEMAP
Text item=nilan_t8_div

ITEMS
Number nilan_t8_div “Outdoor (t8) [%2.2f °C]” (nilan_aggregated)

I don’t see any div item updates? Perhaps it helps to add logging statements to the rule file?

Best
Sami

Is that supposed to linked to a Modbus device, or is it updated by some rule we cannot see?

Rossko57: here’s my configuration currently. Strange that it shows everything except measured temperatures.

Configuration:
Rules: http://pastebin.com/EDJ7W2im
Items: http://pastebin.com/4fFTjMKs

/* nilan computations */
rule "nilan t0-15 sensor division"
when 
    Time cron "0/1 * * * * ?" or
    System started
then
    heat_nilan?.members.forEach(sourceEl| {
            var Number temp = (sourceEl.state as DecimalType) 
            if(temp > 0x8000) {temp = temp - 0xFFFF }
            temp = temp / 100

            nilan_aggregated?.members.forEach[targetEl |
                if(targetEl.name.toString == sourceEl.name.toString + "_div"){
                    postUpdate(targetEl, temp)
                } ]
        }
    )
end

I’m no professional coder and the rules are pure copy from Nickma82 great work done here in Modbus binding sample config: https://github.com/openhab/openhab/wiki/Samples-Binding-Config#serial-modbus-nilan-heatpump-configuration

One forEach has a ( bracket, one a [ bracket, not sure what the effect of that is.

As Sami said, add some logging in your rule

Hi Sami @nodeco,
how is your status?

A lot of changes found their way, please see:

Best, Nick