Missing ItemStateChangedEvent for zwave item defined in item file after upgrade to openhab:3.0.0

Platform information:

  • Hardware: raspberry PI 4 / 32GiB
  • OS: Raspbian GNU/Linux 10 (buster)
  • Java Runtime Environment: docker openhab/openhab:3.0.0
  • openHAB version: openhab/openhab:3.0.0

Issue:

After upgrading to openhab 3.0.0, I noticed that one of my rules was not taking effect. After further investigation, I realized that it’s due to openhab not getting an ItemStateChangedEvent when I turned the light on/off from the light switch on the wall. The rule basically takes the level of the dimmer and copies it to another dimmer. I verified that the rule is operating correctly by setting the level of the Office_Main dimmer from the item page in the GUI, and seeing that the change is reflected in the mirrored device Office_SmartPlug_Dimmer.

If I instead configure the item using the GUI (after removing it from zwave.items), everything behaves as expected (I see ItemStateChangedEvent, and the rule takes effect when operated from the wall switch or the GUI item page).

How would I debug this further, or if not, how would I achieve the same configuration using an items file as from the GUI? Is file-based configuration still suggested / supported?

Please post configurations (if applicable):

Items configuration related to the issue

zwave.items:

Dimmer Office_SmartPlug_Dimmer "Office Lamp" (Light, Sitter) ["Point"] {zwave="zwave:device:3680e6d4:node4:switch_multilevel",  ga="Light"}
Dimmer Office_Main             "Office"      (Light, Sitter) ["Point"] {zwave="zwave:device:3680e6d4:node34:switch_multilevel", ga="Light"}

Rules code related to the issue

Office Link 2:

triggers:
  - id: "1"
    configuration:
      itemName: Office_Main
    type: core.ItemStateUpdateTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      blockSource: <xml xmlns="https://developers.google.com/blockly/xml"><block
        type="oh_event" id="P4h?tVQ/nU=M+yVNJ(Sn" inline="false" x="186"
        y="146"><field name="eventType">sendCommand</field><value
        name="value"><shadow type="text" id="b~}HuBynqAX(;SM9qr]F"><field
        name="TEXT">value</field></shadow><block type="oh_getitem_state"
        id="C[kX~EYfhgTycwK|G+}N"><value name="itemName"><shadow type="oh_item"
        id="(t,,7u?Z#l8,hjF_NOxo"><field
        name="itemName">Office_Main</field></shadow></value></block></value><value
        name="itemName"><shadow type="oh_item" id="]w$kBlx(!$St93G4$3_O"><field
        name="itemName">Office_SmartPlug_Dimmer</field></shadow></value></block></xml>
      type: application/javascript
      script: >
        events.sendCommand('Office_SmartPlug_Dimmer', itemRegistry.getItem('Office_Main').getState());
    type: script.ScriptAction

Item / metdata from console:

Using Items File:

openhab> openhab:items list Office_Main
Office_Main (Type=DimmerItem, State=NULL, Label=Office, Category=null, Tags=[Point], Groups=[Light, Sitter])
openhab> openhab:metadata list Office_Main
Metadata [key=semantics:Office_Main, value=Point, configuration=[]]
Metadata [key=zwave:Office_Main, value=zwave:device:3680e6d4:node34:switch_multilevel, configuration=[]]
Metadata [key=ga:Office_Main, value=Light, configuration=[]]

Using GUI configuration:

openhab> openhab:items list Office_Main
Office_Main (Type=DimmerItem, State=100, Label=Office, Category=DimmableLight, Tags=[Point], Groups=[Light, Sitter])
openhab> openhab:metadata list Office_Main
Metadata [key=semantics:Office_Main, value=Point, configuration=[hasLocation=Office]]
Metadata [key=ga:Office_Main, value=Light, configuration=[roomHint=Office]]

Logs:

When things are working properly, there are no events emitted when I hit the light switch on the wall. When I define the item using the GUI, however, I see the expected:

11:44:11.218 [INFO ] [openhab.event.ItemUpdatedEvent       ] - Item 'Office_Main' has been updated.
11:44:44.969 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Office_Main' changed from NULL to 0
11:44:45.003 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Office_SmartPlug_Dimmer' received command 0
11:44:45.022 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Office_SmartPlug_Dimmer' predicted to become 0
11:44:45.037 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Office_SmartPlug_Dimmer' changed from 100 to 0
11:44:47.331 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Office_Main' changed from 0 to 100
11:44:47.348 [INFO ] [openhab.event.ItemCommandEvent       ] - Item 'Office_SmartPlug_Dimmer' received command 100
11:44:47.362 [INFO ] [openhab.event.ItemStatePredictedEvent] - Item 'Office_SmartPlug_Dimmer' predicted to become 100
11:44:47.374 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Office_SmartPlug_Dimmer' changed from 0 to 100

You are using the old syntax for the zwave version 1 binding.
Version 1 bindings are not supported in openHAB3.

1 Like

Here is a newer syntax example that should work. YThe forum is not a substitute for reading the documentation. I learned this 2 years ago from there.

Switch basement_light "Basement Light [%s]" <light> (basement) { channel="zwave:device:16ddbcdbd38:node12:switch_binary" }

The format I have is from the current “Items” documentation (I started there as my first stop for troubleshooting):

itemtype itemname 
  "labeltext [stateformat]" 
  <iconname> 
  (group1, group2, ...) 
  ["tag1", "tag2", ...] 
  {bindingconfig}
  • Fields must be entered in the order shown
  • itemtype and itemname are mandatory
  • All other fields are optional
  • Fields may be separated by one or more spaces, or tabs
  • An Item definition may span multiple lines

So mine is:

Dimmer Office_Main 
  "Office" 
  (Light, Sitter) 
  ["Point"] 
  {zwave="zwave:device:3680e6d4:node34:switch_multilevel", ga="Light"}

Which means:

  • itemtype Dimmer
  • itemname Office_Main
  • labeltext “Office”
  • groups: Light, Sitter
  • tags: Point
  • bindingconfig: zwave=…, ga=Light

But as @Bruce_Osborne said, the syntax zwave= is the syntax of the old OH1binding. It won’t work in OH3.
You must use the channel syntax.

1 Like

Actually @sihui said that but I posted an example from my system.

Ah, got it, thanks folks.

1 Like

So, thanks for those suggestions, but even with the current / supported syntax:

Dimmer Office_Main 
  "Office" 
  (Light, Sitter) 
  ["Point"] 
  {channel="zwave:device:3680e6d4:node34:switch_multilevel", ga="Light", semantics="Point"}
openhab> openhab:metadata list Office_Main
Metadata [key=semantics:Office_Main, value=Point, configuration=[]]
Metadata [key=channel:Office_Main, value=zwave:device:3680e6d4:node34:switch_multilevel, configuration=[]]
Metadata [key=ga:Office_Main, value=Light, configuration=[]]
openhab> openhab:items list Office_Main
Office_Main (Type=DimmerItem, State=100, Label=Office, Category=null, Tags=[Point], Groups=[Light, Sitter])

I’ve also tried the most basic form:

Dimmer Office_Main {channel="zwave:device:3680e6d4:node34:switch_multilevel"}

and then closer to the provided example:

Switch Office_Main "Basement Light [%s]" <light> (Light) { channel="zwave:device:3680e6d4:node34:switch_multilevel" }

or

Dimmer Office_Main "Basement Light [%s]" <light> (Light) { channel="zwave:device:3680e6d4:node34:switch_multilevel" }

None of those fixed the issue. I tried both directly and with restarting Openhab in between attempts (waiting for it to be fully online/started with each attempt).

Beside that, it’s not that the item was not showing up - it’s always a part of the system - it’s just somehow missing the connection from the zwave binding back into openhab for the event.

Does it seem like a problem in the zwave binding code, or in the core somewhere? I’m trying to see what else I could investigate, either reading code to see what might be missing, or debug traces to watch out for.

What type of device is node 34? If it does not have that channel the item linkage would fail.

A channel with that name does not exist, please use the channels provided from autodiscovery for your Thing.

2 Likes

Good catch! We definitely need the information for the Thing to check in the database.

1 Like

Yes, that makes sense - thanks for spotting it, and for your continued help!

The Thing is a Leviton DZ6HD, so I switched to switch_dimmer per the description there (and per the Things GUI page):


Dimmer

The brightness channel allows to control the brightness of a light. It is also possible to switch the light on and off.

The switch_dimmer channel is of type switch_dimmer and supports the Dimmer item and is in the DimmableLight category.


After changing to switch_dimmer, I’m still seeing the same problem, however.

Dimmer Office_Main
  "Office"  
  (Office,Light,Sitter)
  ["Point"]
  {channel="zwave:device:3680e6d4:node34:switch_dimmer", ga="Light"}

What version of OH did you upgrade from?

If prior to 2.5.0 you may need to delete the Thing from OH & re-add to get the latest binding settings. That database entry was last updated just before the 2.5.0 release.

1 Like

It was 2.5.7 before this.

I’ll try deleting the Thing anyway to see if that helps :slight_smile:

1 Like

Deleting and re-adding the Thing seems to have done the trick. Thanks folks!

1 Like

I was just guessing. I know that is needed when Things are added from the UI. I was just trying to translate that to the text file implementation.

Yeah, I didn’t think of this initially because I had tried a clean slate completely (starting from scratch with 3.0.0 and only my zwave.items, but of course that was in the wrong format completely so it wasn’t working for other reasons :man_facepalming:

1 Like

So, I noticed that after deleting & re-adding, every time I restart the container, I’d have to, again delete and re-add the item.

I wanted to see if it was something in my configuration, so I created a fresh setup using docker openhab:3.0.1.

After initial setup, I installed the z-wave add-on, added the Thing on the z-wave controller, created the item, and verified I was seeing the openhab.event.ItemStateChangedEvent from the client via log:tail. It was working, so I restarted the container, and when it came up, I was, again, missing the events.

The reason I notice is that I have a rule I created to control one light when this one is turned on/off, and I noticed that the rule wasn’t doing anything. When I updated this Item’s state using the UI, however, it would turn on/off the secondary device as expected.

So, my initial theory in my first post that it only happened when creating items using the .items file was definitely wrong, as well, and this certainly appears to be a bug.

At this point, how would I debug further? I don’t really know enough about the internals of openhab to even know where to start on this one. I can certainly reproduce it easily enough.

I can also reproduce the workaround using an Items file by just commenting out, saving, and then uncommenting the item.

21:27:57.115 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'zwave.items'
21:28:14.216 [INFO ] [del.core.internal.ModelRepositoryImpl] - Loading model 'zwave.items'
21:28:22.225 [INFO ] [openhab.event.ItemStateChangedEvent  ] - Item 'Office_Main' changed from NULL to 100