Nikobus v2

There were quite some discussions here regarding the Nikobus (1.x binding) and since it seems it’s not working reliable anymore and one of the sole reasons I started OH at the first place, I decided to give it a try and implement the v2 version of it.

I started a couple of days ago, analysing the v1 binding and started to port it … currently the idea is to have something like:

Bridge nikobus:pc-link-serial:mypclink [ port="/dev/ttyUSB0" ] {
	Thing push-button 1F05F2
	Thing push-button 9D592A
     ...
}

so each button is mapped to a push-button Thing and I’ll add a switch-module Thing with outputs as channels.

I already did a sort of discovery (don’t know if there is a way to actively scan configuration but my implementation adds buttons to Inbox if one presses a button that is not already in the config) so it removes the need to discover buttons using debug output as in v1:

the number next to button is it’s address (without the #N).

Some other sneak-peak images:


Will try to keep it as close as possible to its v1 counterpart - and please keep in mind its still in its super early stages, but still wanted to share the progress here - so stay tuned!

EDIT: Please note this thread contains information from when the binding development started and some data might be out-dated - therefore strongly recommend to check the binding’s documentation first.

3 Likes

Sounds Great!! Much appreciated.
I have all addresses of the buttons in a version 1 text file items config.
What would be the easiest way to integrate those already defined button address-to-name mappings?

I expect that items as

Switch S_1_15_2A 		{nikobus="#N9D592A[4C6C-1]"}

will be mapped to

Bridge nikobus:pc-link-serial:mypclink [ port="/dev/ttyUSB0" ] {
	Thing push-button 9D592A [ impactedModules = "4C6C-1" ]
     ...
}

or something similar so more or less 1:1 mapping.

Thanks, looking forward to give it a try

Please find (pre) alpha release here. In order to test, please have 2.5 version of OH installed, than simply download jar from link above and drop it to addons folder of your OH installation.

Please define all your modules (currently switch and dimmer modules are supported) + all your push buttons as below:

Bridge nikobus:pc-link-serial:mypclink [ portName = "/dev/ttyUSB0", refreshInterval = 30 ] {

    // Modules
    Thing dimmer-module 0700 "Dimmer"
    Thing switch-module FF2A "Switch module #1"
    Thing switch-module 4C6C "Switch module #2"
    ...

    // Buttons
    Thing push-button 9D592A "S_1_15_2A" [ impactedModules = "4C6C-1" ]
    Thing push-button DD592A "S_1_15_2B" [ impactedModules = "4C6C-1" ]
     ...

So if you have in your v1 binding something like

Dimmer Light_FF_Gallery_Ceiling		"Ceiling"		(FF_Gallery, Lights)		[ "Lighting" ]	{ nikobus="0700:1" }

please add this to .thing file

Bridge nikobus:pc-link-serial:mypclink [ portName = "/dev/ttyUSB0", refreshInterval = 30 ] {

    // Modules
    Thing dimmer-module 0700 "Dimmer"
    ...

and use it in .items file as

Dimmer Light_FF_Gallery_Ceiling		"Ceiling"		(FF_Gallery, Lights)		[ "Lighting" ]	{ channel="nikobus:dimmer-module:mypclink:0700:output-1" }

Push buttons like

Switch S_1_15_2A 		{nikobus="#N9D592A[4C6C-1]"}

goes to .thing file

Thing push-button 9D592A "S_1_15_2A" [ impactedModules = "4C6C-1" ]

so please make sure to remove the #N when adding push button things.

Strongly suggest to enable DEBUG output for Nikobus binding and share any problem here. Also please note some things might still change before creating the PR, but did run it for day+ and had no issues so far so would like to collect feedback if anybody is interested.

Thanks in advance,
Boris

I am converting my config now, thanks!
How do you display the status of a swtch channel in a sitemap file
in v1 I have

Switch LP “Licht B” (Schakelmodule) { nikobus="BC00:5” }

In a sitemap the status of a light is given by

Switch item=LP icon=“light”

Great to see! I am currently taking the MQTT approach, allowing nikobus to be abstracted away behind MQTT, making it compatible with all kinds of domotics systems, as well as OH3. Keep kt up, I’ll definitely try it out and compare when I find the time.

Hi!

Actually I haven’t changed my .sitemap at all. Just updated .items file, so item like

Switch LP “Licht B” (Schakelmodule) { nikobus="BC00:5” }

should be mapped to something like

Switch LP “Licht B” (Schakelmodule) { channel="nikobus:switch-module:mypclink:BC00:output-5" }

and you need to add something like

Bridge nikobus:pc-link-serial:mypclink [ portName = "/dev/ttyUSB0", refreshInterval = 30 ] {

    // Modules
    Thing switch-module BC00
}

in your .things file. That should allow you to use the switch as you did before without changing the .sitemap.

Binding supports two Bridges, that is two ways to connect to your Nikobus installation:

  • nikobus:pc-link-serial and
  • nikobus:pc-link-ip

Since v1 did not include the tcp/ip version I guess most will use serial, so start with adding

Bridge nikobus:pc-link-serial:mypclink [ portName = "<serial port>", refreshInterval = 30 ] {
}

to your .things file. portName is the port to use and should be the same as defined in nikobus.cfg, parameter serial.port of your v1 setup, so if you had:

serial.port=/dev/ttyUSB0

in nikobus.cfg than add

Bridge nikobus:pc-link-serial:mypclink [ portName = "/dev/ttyUSB0", refreshInterval = 30 ] {
}

refreshInterval defines how often Nikobus modules are “asked” for their status so having i.e. 30 as above, binding will read one module’s status each 30s, iterating through all defined ones. I’m currently testing with 10s interval and seems to work fine (v1 binding had 600s by default!). Reading module’s state helps OH being in sync with your Nikobus installation.

Binding currently support 2 modules (things):

  • switch-module and
  • dimmer-module

each module has 12 channels:

  • output-1,
  • output-2,
  • output-12

the main difference between switch-module and dimmer-module is that switch-module has outputs (channels) defined as Switch and dimmer-module as Dimmer.

That said, one needs to add each physical Nikobus module to the .things file:

  • using switch-module for switching module i.e. 05-000-02,
  • using dimmer-module for dim-controller i.e 05-007-02.

Address of the modules are the same as it is in v1 binding.

So during v1 -> v2 migration one needs to go through the v1 .items file and for each line like:

Switch LP “Licht B” (Schakelmodule) { nikobus="BC00:5” }

add to your .things file (if not added already):

Thing switch-module BC00

and for each line like:

Dimmer Light_GF_Dining_Ceiling 	"Ceiling" (GF_Dining, Lights) { nikobus="6B00:10" }

add

Thing dimmer-module 6B00

At the end the .things file should look something like:

Bridge nikobus:pc-link-serial:mypclink [ portName = "/dev/ttyUSB0", refreshInterval = 30 ] {

    Thing dimmer-module 6B00
    Thing dimmer-module 0700

    Thing switch-module BC00
    Thing switch-module 4C6C
    Thing switch-module A063
}

Number of things should be the same as the number of modules in your Nikobus installation and make sure the mapping is correct - switch to switch-module and dim-controller to dimmer-module.

Now lets migrate .items file. Entries as:

Switch LP “Licht B” (Schakelmodule) { nikobus="BC00:5” }

should be updated to

Switch LP “Licht B” (Schakelmodule) { channel="nikobus:switch-module:mypclink:BC00:output-5" }

and entries as

Dimmer Light_GF_Dining_Ceiling 	"Ceiling" (GF_Dining, Lights) { nikobus="6B00:10" }

should be updated to

Dimmer Light_GF_Dining_Ceiling 	"Ceiling" (GF_Dining, Lights) { channel="nikobus:dimmer-module:mypclink:6B00:output-10" }

With above in place you can use your existing .sitemap file as before.

All above can be setup through the Paper UI too :wink:

Thanks!

I am trying to add my switch modules via paperUI but get unknown state. I selected the bridge and as name I chose the 4-char address of the module
The PC-Link bridge is online

Apparantly a serial issue.

2019-08-26 13:57:21.055 [WARN ] [nternal.handler.NikobusPcLinkHandler] - Listener for nikobus:pc-link-serial:mypclink had exception: Unable to connect to /dev/ttyUSB0
java.io.IOException: Unable to connect to /dev/ttyUSB0
at org.openhab.binding.nikobus.internal.connection.SerialNikobusConnection.connect(SerialNikobusConnection.java:51) ~[?:?]
at org.openhab.binding.nikobus.internal.handler.NikobusPcLinkHandler.connectIfNeeded(NikobusPcLinkHandler.java:131) ~[?:?]
at org.openhab.binding.nikobus.internal.handler.NikobusPcLinkHandler.listener(NikobusPcLinkHandler.java:149) ~[?:?]
at org.openhab.binding.nikobus.internal.handler.NikobusPcLinkHandler.lambda$1(NikobusPcLinkHandler.java:108) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: gnu.io.PortInUseException: org.openhab.binding.nikobus.internal.connection.SerialNikobusConnection
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:459) ~[?:?]
at org.openhab.binding.nikobus.internal.connection.SerialNikobusConnection.connect(SerialNikobusConnection.java:47) ~[?:?]
… 8 more

I stopped the serial transport binding for v1 but no avail

Yes, there is an issue with restarting the bridge in the current .jar so please restart openhab instance alltogether if you see PortInUseException error. I’m fixing that so should be resolved shortly but now for the time being, just restart the OH. Of course you need to remove the v1 Nikobus binding alltogether so it does not interfere.

Please note bridge will go to ONLINE if it is connected successfully to serial port while switch modules will go online if status was read successfully. You need to have at least one channel per module linked (defined in .items file) in order for module to start reading its status otherwise read will not be triggered (since there is no channel being used/linked). Makes sense?

I removed the v1 serial1 binding and the Nikovus v1 binding.
Now installed Nikobus v2 en serial transport v2
Bridge is up.
Switch modules are is state unknown while there is an items channel link

Can you share you configuration files + logs?

I can PM them but prefer not to put them on plain internet

Sure! I’m only interested in the Nikobus related stuff anyway :wink:

Things start working out.
Bridge online
Switch modules online
and lights going on and off :+1:
Thanks!

Great to hear! Please let me know if there are any issues.