Switch item with no associated binding

Hello all,
I am trying to use a Kmtronic 8 channel RS-485 relay board to control various itemes. It responds to Hex codes sent via ttyS00 on my linux box. As a single serial port can control up to 32 of these boards I need to develop items, sitemaps, and rules using “dummy” swtiches that trigger the appropriate sendCommand event to cycle a relay open or closed. I haved searched the forums to find a good example. The only one I found uses case statements and is from 2013. It has the same error I currently have trying to use a Switch Item on my sitemap to trigger a rule that uses the sendComand function. I copied this particular example https://groups.google.com/forum/#!topic/openhab/QXEDY3DbJSA and the error is the same as using the dummy switch example here: Dummy Switch without a hardware thing . That is

[DEBUG] [o.i.r.i.resources.ItemResource:235 ] - Item ‘UP_GR_TV’ could not be found in the item registry
[ERROR] [o.u.i.items.ItemUIRegistryImpl:438 ] - Cannot retrieve item UP_GR_TV for widget org.openhab.model.sitemap.Switch

Without the ability to map numerous “dummy switches” in the sitemap i have reached an impass. How can I properly institute a Switch item that when selected generates a hex string to ttyS00? Thanks for any feedback

Post a sampling of your Items and Sitemap and rules. There is nothing I know of that should prevent you from using dummy switches (@bob_dickenson calls them proxy switches) and both he and I use them successfully.

I’ve also used case statements successfully. Whenever I see the “could not be found in item registry” it is usually because there was a typo in my items file or sitemap.

Are you using OH1 or OH2?

RIch,
Thanks for the quick reply, I am using OH V 1.7 on an Ubuntu 14.04 headless server. My Items:
Number NorthAttic “North Attic [%.1f °F]” {onewire=“deviceId=28.FFC3136504003F;propertyName=temperature;refreshinterval=10;multiply=1.8;add=32”}
Number SouthAttic “South Attic [%.1f °F]” {onewire=“deviceId=28.FFB5752D040043;propertyName=temperature;refreshinterval=10;multiply=1.8;add=32”}
Number SouthHouse “South House [%.1f °F]” {onewire=“deviceId=28.1D900B060000FD;propertyName=temperature;refreshinterval=10;multiply=1.8;add=32”}
Number SouthOutside “South Outside[%.1f °F]” {onewire=“deviceId=28.FF868D2C04004F;propertyName=temperature;refreshinterval=10;multiply=1.8;add=32”}
Number Garage “Garage [%.1f °F]” {onewire=“deviceId=28.FF100864040028;propertyName=temperature;refreshinterval=10;multiply=1.8;add=32”}
String HDMI_Matrix “HDMI Matrix” (All) { serial="/dev/ttyS00" }

Sitemap:
sitemap aahome
Frame label=“Temperatures”{
Text item=NorthAttic
Text item=SouthAttic
Text item=SouthHouse
Text item=SouthOutside
Text item=Garage
Switch item=UP_GR_TV mappings=[1=‘BluRay’, 2=‘Dune’, 3=‘Wii’]
}

Rules:
rule “Great Room TV Source”
when
Item UP_GR_TV received command
then
switch(receivedCommand) {
case 1 : sendCommand(HDMI_Matrix, “0x00,0xff,0xd5,0x7b”)
case 2 : sendCommand(HDMI_Matrix, “0x010xfe0xd50x7b”)
case 3 : sendCommand(HDMI_Matrix, “\x02\xfd\xd5\x7b”)
}
end

The onewire items all work with no issues. Thanks again.

-Tony

Well, the big missing piece is the definition for UP_GR_TV. Even if you don’t have it bound to anything, you have to define it in your items file.

Did you just leave that out or do you truly not have the item defined in the items file?

Rich,
Nope I truly do not have it defined, I copied this from a posting in 2013, and have tried and failed numerous times to come up with a defination for a “dummy” or proxy item. No matter what I tried I keep getting the “item not found error” please see the second hyperlink. i tried the Switch Item_name “Item display name” but with no {binding} I think it errors out and fails to fire off the rule. At least that’s my suspicion, I couldn’t find an example of a proxy item that has no hardware assigned. I don’t want to bind the switch to the serial port as many strings will roll across the serial port for a theoretical max of (32x8) 256 different relays. I tried a {%s} after the quotes and still found no success. I am not a software coder and am feeling a bit lost. Thanks

You HAVE to define all Items, including dummy Items, in your .items files.

A proxy Item is just an item that isn’t bound to anything with a rule attached to it to do something instead of a binding. Usually the thing that triggers the rule is another Item or field on your sitemap. In your case:

  • UP_GR_TV is the proxy item
  • “Great Room TV Source” is the rule
  • “Switch item=UP_GR_TV …” is the trigger

Using your code above you would have:

Number UP_GR_TV "label" (groups)

NOTE: I use a Number because a Switch can only be ON or OFF (i.e. 1 or 0).

Replace “label” with the text you want on the sitemap and replace groups with any groups your want UP_GR_TV to belong to or remove it if you don’t want it to be a member of any group.

Change the trigger of your rule to

Item UP_GR_TV received update

I’m not sure that Numbers can receive commands and this will trigger the rule for any update to the item.

I believe your sitemap will work just fine.

This will certainly get rid of the “could not be found in the item registry” error.

Rich,
Thanks for the clarification, for future reference is there a resource that details these particulars, I have tried finding a manual and haven’t had any luck. Reviewing the examples frequently results in more questions than answers due to my limited exposure to Java coding. Thanks again.

Your source for pretty much all of the openHAB documentation is the wiki.

Keep in mind that rules development is not Java, it is a Domain Specific Language (DSL) built off of Xtext which is in turn built off of Java. While Java classes are available, the DSL is NOT Java. For language syntax documentation see the Xtend documentation, which is also based off of Xtext and very similar to the DSL.