[Solved] Can't use Category <Switch> in .items file definition

I was trying to setup a Zwave switch in a litems file.

`Switch  Switch_GF_Garage_DogKennel  "Dog Kennel Switch" <Switch>   (GF_Garage)  ["iss:room:Garage", "iss:type:DevSwitch"]  {channel="zwave:device:54545887:node43:switch_binary",  mqtt="<[mqttloc:home/garage/dogKennelSwitch/set:command:default],>[mqttloc:home/garage/dogKennelSwitch:state:*:default]"}`

Which generates the following errors:

[38,65]: mismatched input '>' expecting RULE_ID
[38,78]: mismatched input ')' expecting RULE_ID
[38,132]: mismatched input '=' expecting RULE_ID
[38,184]: mismatched input '=' expecting RULE_ID
[59,36]: no viable alternative at input 'Switch'

If I use a lower case the error go away but the item won’t connect to the Thing’s switch channel. I can leave out the all together and then it works. For all other category types I don’t have any issue, it just seems to be an issue with Switch’s.

Before I submit it as a bug, just wanted to make sure there wasn’t something I was missing?

interesting…
I always use lowercase for <iconname>. I think that using Switch instead of switch is wrong (and that’s why you are getting this error). openHAB gets stuck at the first error in column 65 and then complaints about the other columns also since it is trying to find a RULE_ID (?)

that part is strange… it may be a bug… not sure.
what do you mean “the item won’t connect to the Thing’s switch channel” ? The link is not established? (does the link show in PaperUI?) or that the zwave channel is not triggered when the switch gets a command?

I was as well until I realized by looking at HABmin (and just confirmed in PaperUI) that the “Category” is pulling from the iconname but is Propercase in both UI’s so if I specify them with a lowercase Icon/Category then it doesn’t show up in the HABmin Category.

When I first defined the item it wasn’t linking to the Thing Channel in HABmin. Now it seems to be working so not sure if I can replicate again. Might of just been the need tor refresh my browser. I’ll try to test with the next item I setup.

1 Like

works fine here (both UIs show lowercase for category). Using OH 2.2.0 Snapshot Build #991
The Type is Switch (Propercase). The Category is switch (lowercase) (this is coming from the iconname)

----------------------

I see the lower case in PaperUI as well. Maybe it’s just an HABmin issue. If I don’t use a Propercase Switch it doesn’t show up and as you can see in the dropdown list all “Categories” are Propercase:

For this piece I just had it happen with another item where it didn’t link at first but then when I was messing around with it it eventually did. I’ll try to test this further to see if I can figure out what is causing it.

The fundamental issue that a Propercase causes an error is there. Just not sure how important it is since lowercase seems to work ok, you just can’t see them in HABmin.

Is that item a managed item or a statically defined item in a flat file?

I can’t edit my static items using HABmin…

Static item from text cfg file. You can’t edit them but the Category/Item doesn’t show up in HABmin if it’s lowercase.

Ok.
By the way: I can’t even get to the page that you have posted (Edit Item) in HABmin :slight_smile:

Using: HABmin Version 2.0.0 2017-07-25 (included in OH2.2 S991)

Go to Configuration | Things | Channels and click on the little blue paper/pen edit icon to the left of the thing name:

1 Like

Got it! Thanx :slight_smile:
Anyway… since these are static items: I don’t use UIs to modify them.
what you have found seems to be a HABmin bug :slight_smile: (with the Category)
but not many people use HABmin to edit their managed items… most use PaperUI I think

I don’t edit things like Categories but I still use HABmin to configure things like setting temperature scale since you can’t do it through the channel definitions (or that I’ve found how to) so from that side it’s more of an annoyance then a show stopper.

There is also the parsing bug in Openhab where it things it’s parsing an item type instead of the iconname (once again low impact and can be worked around). I submitted a bug report:

https://github.com/openhab/openhab-distro/issues/494

Edit: From Kai:

This isn’t a bug, you simply have to escape keywords.
This is done by prepending a ^. This is true for ALL DSL files, so you will have the same in sitemaps, rules, etc.

1 Like

I don’t understand the “prepending a ^” part, but anyway :slight_smile: (what should we use and where to avoid the issue that you identified?). By the way: for me it has been always clear that we need to use lowercase for the iconname. Anything else is just wrong (not a bug)

By the way… I was referring to another (HABmin related) bug: In case I have a correctly configured item (e.g.:

Switch		mP6_02_02_O	"mP6_02_02 Outlet"		<switch>	(gmPower)	{channel="mpower:socket:04_18_D6_59_FD_EA:2:outlet"}

HABmin does not show the Category (or the parent groups) when you edit the item:

It simply means that you need to write:

Switch		mP6_02_02_O	"mP6_02_02 Outlet"		<^Switch>

ok, thanx!

I still think that using Propercase within the <iconname> is an error (for me) and I always use lowercase :slight_smile:

all the icons listed here: http://docs.openhab.org/addons/iconsets/classic/readme.html are using lowercase also

The category part is due to lowercase vs. propercase iconname. If you change one to propercase it will show up. Though I am finding I need HABmin less and less so not that big of a deal.