Doubt about itemName and internalReceiveCommand

Hi all, I’m implementing a new binding and I don’t understand how work the function:

public void internalReceiveCommand(String itemName, Command command)

If I create the next item in mi .item file:

Switch Light_GF_Corridor_Ceiling “Ceiling” (GF_Corridor, Lights)

And I run the when I will turn on or off the switch this function is going to receive (Light_GF_Corridor_Ceiling, on/off). I’m right?

Could someone answer?


I’m not sure if I understand what you’re asking. Do you have physical switch that you will turn on/off, or are you talking about Switch item in OpenHAB UI? If you are talking about physical switch, you will need some binding in your .item file (z-wave, knx etc.) that will connect OpenHAB Switch item with physical switch. I don’t think the function you referenced should be called by a user. You can access a state of the switch by calling Item_name.state. And you can set state of the switch by using, either Item_name.postUpdate(state) or Item_name.sendCommand(state) (in case of Swith item, state should be ON or OFF). If you want to send command via BUS (for example, send command via z-wave binding to physical switch) you should use sendCommand. If you just want to change state of an item, you should use postUpdate. Hope this helps.

Best regards,

Hello Davor, first of all than you for your answer. I guess that I have not explained very well. I have some X10 devices and I’m trying to implement my own binding. I know that there a couple of binding which can support x10 technology. But I’m doing my final degree project and I have to implement this binding. I’m going to explain you what I have done. I use a c library called Libususb (I have to use it to control the communication between my Pc and the CM15pro). This library controlling the USB port and send command throw the PL to my X10 devices. I test this and it works. Now I have created a maven skeleton to my binding. My binding is so simple because it only have to receive a command from the openHAB UI and call to my c library to send the command. I run the c program from java with this line “p = Runtime.getRuntime().exec(“cm15a”);” and depends on the command on/off call a different class. In my .item file I create the items with the next structure “Switch A1 “Ceiling” (GF_Corridor, Lights)”.
When I will turn on this switch in the openhab UI my functio internalReceiveCommand will receive this (A1, on) ?

By other hand I have another question I have no found any information about the BindingProvider. What I have to put in this java class?

Thank you!!


Sorry if I misguided you with my information. I must’ve missed part where you’ve stated you are implementing a new binding. I thought you are trying to build .items file using official bindings. Regarding your question, I’m not so good at Java, so, it should be better if some of the binding developers help you.

Best regards,

If you have bound the item correctly to your binding, then the answer is yes.
internalReceiveCommand() will be informed by the event bus of any command send to your item.
You can then check what action to be run for different command types (ON/OFF/INCLEASE/DECREASE etc.)

Hello Hans, what do you mean with bound the item correctly?

You really should have a look at other bindings.
Every binding implements an identfier (binding string), that is used in item definitions ( the part in {} ) to link the item to a specific binding.

Ok thank you. I’m a new in java do you recommend me a easy binding to have a look? And another question, do you know if I have to create the GenericBindingProvider, BindingProvider and BindingConfig files If my binding only have to receive a command from the openhab UI? I have read How To Implement A Binding post but I’m not sure at all.

Thank you so much for help me.

You could have a look at my energenie binding, wich is quite simple.
And yes, you have to implement these.

Hello Hans, I have a look to your binding and to your item configuration. I have create my org.openhab.binding.x10.jar and I have put it in my openhab_demo/addons folder. When I run the I don’t read anything about my binding installation, like “X10 cm15 binding has been started” who is configured in my BindingActivator. And I have another problem: When I put my items like your configuration (Switch Alarma_dani “Alarma” {x10=“A1”} ) I don’t see any items in the openhab UI. Do you know what I’m doing wrong?

Thank you!!!

Well, best would be to push your code into your openhab fork and send me the link, either post it here or as a PM.
I could then have a look and tell you what I think is wrong.

Not seeing anything in the UI -> Did you create Items in your sitemap ? Without doing so, you will never see anything.