Nikobus Rule not working

Hi

I want something simple I guess… I want to switch a light when my sensor detects presence. It worked in OH1, but not in OH2. The system is nikobus and z-wave.

//Sensors
Number Garage_Movement “Movement: [%s]” (SENSORS) { zwave=“2:0:command=sensor_binary” }
Number Garage_Alarm “Alarm: [%s]” (SENSORS) { zwave=“2:0:command=sensor_alarm” }
Number Garage_Lux “Lux: [%.2f Lux]” (SENSORS) { zwave=“2:0:command=sensor_multilevel,sensor_type=3” }
Number Garage_Bat “Battery: [%d %%]” (SENSORS) { zwave=“2:0:command=battery” }
Number Garage_Temp “Temperature: [%.1f °C]” (SENSORS) { zwave=“2:0:command=sensor_multilevel,sensor_type=1” }
Switch Garage_Movement_Switch “Movement: [%s]” (SWITCHES) { zwave=“2:0:command=sensor_binary” }

This is my old rule, which was working on OH1, does not work in OH

rule “GarageMovement”

when
Item Garage_Movement_Switch changed
then
sendCommand(light_Garage, Garage_Movement_Switch.state.toString)
end

This is my rule with habmin rule editor

// This rule file is autogenerated by HABmin.
// Any changes made manually to this file will be overwritten next time HABmin rules are saved.

// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

// Global Variables

rule “Garage Aan”
when
Item Garage_Movement changed
then
if ((Garage_Movement.state == ON)) {
sendCommand(light_Garage, ON)
}
end

So I don’t know if it’s me or Nikobus.

I think something is wrong with the Nikobus binding in OH2. Ie feedbacks are also not working properly.

It depends with me… sometimes when i switch one item, another one gets switched, but I’m not sure if this is Nikobus (and flooded bus) related of HabPanel.

In the mean time i found out why my rule was not working…

It had to be Garage_Movement_Switch in stead of Garage_Movement…

rule "Garage Aan"
when
Item Garage_Movement_Switch changed
then
if ((Garage_Movement_Switch.state == ON)) {
sendCommand(light_Garage, ON)
}
end

My item references are correct. The rules worked under 1.8.3.
I now recreated the rules with next-gen rule engine and they are working, but behaving strange from time to time since I do not kno how to apply conncurrency lock in next-gen rules and feedback is still not working when changing an item.
It does an item status update after the config file predefined interval (600s) but not after pressing a physical Nikobus button. This was working under 1.8.3

In the meanwile I did a clean install of OH2 beta5 and in this release feedback is working again (also after pushing a physical button).

Tonight I will test the feedback with 0H2b5

The rules problem has been fixed. more changes are needed to migrate from OH1 to OH2 than indicated in the documentation.
Changes that were needed:

  1. variable defintion changes from

var java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock()

to

var ReentrantLock lock = new ReentrantLock()

  1. Defining the variables globally does not work. All variables need to be in the “then”-block

Rule working in 1.8.3

import org.openhab.core.types.*
import org.openhab.core.library.types.*
import org.openhab.core.library.items.*
import java.util.concurrent.locks.Lock
import java.util.concurrent.locks.ReentrantLock
import org.openhab.model.script.actions.*
import org.openhab.action.squeezebox.*
import org.openhab.model.script.actions.Timer
import org.joda.time.*
import java.lang.Math
import java.util.Calendar
import java.util.Date
import java.util.TimeZone
import java.text.SimpleDateFormat
import org.openhab.core.persistence.*
import org.openhab.core.library.types.PercentType
import org.openhab.core.library.items.SwitchItem
import java.util.HashMap
import java.util.LinkedHashMap
import java.util.ArrayList
import java.util.Map
import org.eclipse.xtext.xbase.lib.*
var java.util.concurrent.locks.ReentrantLock lock  = new java.util.concurrent.locks.ReentrantLock()
rule "Link LPgarageStatus to LP_garage"
when
   Item LPgarageStatus changed
then
   lock.lock()
   try {
      if(LP_garage.state != LPgarageStatus.state && SystemStarting.state == OFF) {
         LP_garage.sendCommand(LPgarageStatus.state.toString())
         logDebug("vera", "Vera switch LPgarageStatus has been synced to state " + LPgarageStatus.state.toString() + " with Nikobus switch LP_garage")
      }
} finally{
   lock.unlock()
}
end

Rule adapted and working in OH2B5

import java.util.concurrent.locks.ReentrantLock
rule “Link LPgarageStatus to LPgarage”
when
Item LPgarageStatus changed
then
var ReentrantLock lock = new ReentrantLock()

   lock.lock()
   try {
      if(LPgarage.state != LPgarageStatus.state && SystemStarting.state == OFF) {
         LPgarage.sendCommand(LPgarageStatus.state.toString())
         logDebug("vera", "Vera switch LPgarageStatus has been synced to state " + LPgarageStatus.state.toString() + " with Nikobus switch LPgarage")
      }
} finally{
   lock.unlock()
}
end

I think my issue is solved.
In my items file I had no bindings for all the buttons, therefor button feedback was not recorded.
I defined all buttons in my items file and now feedback is working.

I also noticed that in automation rules switching on a light does behave correctly when giving the ON command through a Nikobus button binding in stead of to the schakelmodule channel.

When giving the ON command to a schakelmodule channel item in a rule, the lights behave strangely (putting on/off different lights), which works correctly when giving the ON command to a Nikobus button item.

bindings for al the buttons? Do you mean items? I don’t have all buttons defined, still have some left…

Nice to hear for you both it’s working too :slight_smile:

I also had probems when directly changing the channel state on the Nikobus modules. Quite often Openhab commands didn’t change the state on the modules and therefore the state in Openhab and the real state didn’t correspond anymore.
Therefore I started using virtual buttons (generieke bedieningspunten) in the Nikobus software. Now an item in my sitemap changes a virtual button and the virtual button changes the real state in the Nikobus module (which also starts the feedback process)
This works very reliable.

I can confirm that @Fdewaele. I defined all Nikobus buttons as separate items (and there are a lot of them :sweat: )
Howebver the feedback is not working anymore since the snapshot version. It was ok with beta5 but I needed to upgrade do to startup rules issues with beta5
https://community.openhab.org/t/solved-rule-when-system-started-executed-more-than-one-time/20016/4?u=stefaanbolle

‘generieke bedieningspunten’. where can i find these in the nikobus software? and how to model these? i have each button as a separate item.

i also want to use my detector in the hallway as trigger for my hue lightstrips, but i can’t get my head around that how to do this. do i need a rule ?

Seems to be only Belgians struggling with Nikobus binding. We should create a “zelfhulpgroep” :sweat_smile:

Ik was thinking the zelfde thing :slight_smile:

10 years later i think nikobus wasn’t the solid investment i thought it would be. I’m for sure happy that openhab exists,I looked at domoticz and home automation because of the learning curve of openhab for an ethusiast like me who lacks the ability of programming (I have a basic if… then… ruleand that’s it, when I see your rules :blush: ) but nothing more. No bindings however for those. I can only be very grateful for the work of @davy because without that I would probably have spent the last year with RF2IR and iRule solutions in stead of ‘serious’ domotics.

I found it in meanwhile, the virt02/04/64 generics. Now time to find out how it works.

Do you have PC-link and PC-logic?You will need 1 serial port to push the virtual button (in the Nikobus software) and 1 serial port to capture at the same time the address of it (by using Openhab debug) …

@bdv: I am very happy with my Nikobus installation because it is a very stable, reliable and programmable with a screw driver and thus quite a simple system. So no regrets about my investment. However it is only thanks to @davy (much appreciiated!!) that we now can control the system with our smartphones/tablets using Openhab. i do this already for more than 2 years. It’s a pity (and shame) that Niko never offered something to make it smartphone controllable.