How to specify z-wave commadns in items

Hi!

Beginners question here:

I’m trying to specify commands something like:

my.items
Switch z3sw “My Switch” {zwave=“3:command=switch_binary”}

my.sitemap
sitemap home label=“My Sitemap” {
Frame {
Group item=myRoom label=“My Room” {
Switch item=z3sw label=“My Switch” mappings=[OFF=“Off”, ON=“On”]
}
}
}

This is not working, however looking in the logs if I use this notation:

Switch item=zwave_device_be1078de_node3_switch_binary label="My Switch" mappings=[OFF="Off", ON="On"]

it works.

Is there any way of writing it more generic than the “zwave_device_be1078de_node3_switch_binary”

Thanks in advance,
/S

You don’t want to specify z-wave commands in neither items nor sitemap file.
The mappings part is used solely to override the displayed name in the GUI.
Your items entry is basically correct. If switching doesn’t work, it’s likely because of electrics, zwave parameters or radio issues.
Those parameters you cannot set from within items file [well, there is a way, but that’s for very specific applications only and to explain would probably cause even more confusion].
Use habmin to set parameters and verify radio connectivity.

Sorry, I have to veto.

First, there are in fact two different mappings, one in the .items file, the other in the .sitemap. The mapping in .items is used to display a value or state in a different manner:

Switch MyItem "Mein Item ist [MAP(de.map):%s]" 

and de.map:

ON=An
OFF=Aus
-=-

Will result in displaying the Item like this:

Mein Item ist                An
Mein Item ist                Aus

but the state will be ON or OFF!

If you do a mapping in .sitemap, this will result in a different presentation of the widget:

Switch item=MyItem mappings=[OFF="Aus,ON="An"]

will result in a Switch with two buttons instead of a slide switch, labeled Aus and An, but pressing this buttons will result in a command OFF or ON!

The Name of an item will only be displayed if there is no label defined for this item, regardless if in .items or in .sitemap.
So if you want to override the displayed Name of an Item, you have to use

Switch item=MyItem label="New Label [%s]"

and please don’t forget the dynamic part of the label (the part in square brackets, including the brackets) because the item will not display it’s value if this part is omitted.

In question of defining ZWave items through the .items file, prior to habmin this was the only way to define the item’s binding. See Z-Wave Binding and Z-Wave Examples for more information.

Thanks for the reply.
I take it that writing: “zwave_device_be1078de_node3_switch_binary” as item
is correct then? I was basically aiming to have a shorter item name “Switch z3sw “My Switch” {zwave=“3:command=switch_binary”}”

The problem was not with the z-wave unit, since the “zwave_device_be1078de_node3_switch_binary” commands triggers it correctly, was more looking for a best practice on how to address z-wave units in sitemap and items-files.

Regards, S

You can choose the Item names as you like. the only restrictions are the keywords in openHAB, like Switch, Dimmer, Rollershutter, if, then when and so on. It’s good practice to use a system to remember the function of an item, e.g. I use a scheme like gfLivingLight1 (ground floor, living room, light 1).

Sounds good. How can i change the item name:
zwave_device_be1078de_node3_switch_binary to something shorter? Didn’t find any options in doing so in habmin.

Regards S

Change it in the items file.

You have to configure openHAB not to autogenerate Items. Then you have to unlink the Channel and relink it to the new Item:

  1. Paper UI -> Configuration -> Services -> System -> Item Linking -> Configure -> Simple Mode off
  2. Restart openHAB, I don’t know if this setting will take part immediately
  3. Paper UI -> Configuration -> Things -> Thing -> Select Channel -> Unlink
  4. Paper UI -> Configuration -> Things -> Thing -> Select Channel -> Link -> Select Item from List -> +Create new item… -> set Item name and Item Label -> Link

Step 1 and 2 are needed once only.

You also could configure the Items before linking it, but then you have to know the correct Item Type:
Paper UI -> Configuration -> Items -> + (the big one above the Item list)

If you know what to write in the .items file, it’s way more efficient to do it through text config.
It’s a shame that openHAB 2 doesn’t create the files through autoconfig, though I understand this would be much more complex…

1 Like

A bit late, but thanks for the feedback!