Got en error with enocean

Hi all,

I am a newbie with openHAB and I am struggeling with openHAB and a window handle. The windows handle based on enocean and has three states: Down, MIddle and Up. I am using an USB310 stick and in my opinion the binding works well.
My openHAB version is 2.1.0 an enocean 1.10.00

Whenever I used the handle I found this in the log:

2017-09-29 22:57:07.395 [DEBUG] [.enocean.internal.bus.EnoceanBinding] - Received new value Middle for device at EnoceanParameter: {id=“00:22:CC:1F”, parameter=“CONTACT_STATE”}
2017-09-29 22:57:07.399 [ERROR] [org.opencean.core.ESP3Host ] - Error
java.lang.ClassCastException: org.opencean.core.common.values.WindowHandleState cannot be cast to org.opencean.core.common.values.ContactState
at org.openhab.binding.enocean.internal.converter.ContactStateConverter.convertToImpl(ContactStateConverter.java:1)[188:org.openhab.binding.enocean:1.10.0]
at org.openhab.binding.enocean.internal.converter.StateConverter.convertTo(StateConverter.java:68)[188:org.openhab.binding.enocean:1.10.0]
at org.openhab.binding.enocean.internal.profiles.StandardProfile.valueChanged(StandardProfile.java:79)[188:org.openhab.binding.enocean:1.10.0]
at org.openhab.binding.enocean.internal.bus.EnoceanBinding.valueChanged(EnoceanBinding.java:298)[188:org.openhab.binding.enocean:1.10.0]
at org.opencean.core.ParameterChangeNotifier.receivePacket(ParameterChangeNotifier.java:47)[188:org.openhab.binding.enocean:1.10.0]
at org.opencean.core.ESP3Host.notifyReceivers(ESP3Host.java:52)[188:org.openhab.binding.enocean:1.10.0]
at org.opencean.core.ESP3Host.run(ESP3Host.java:73)[188:org.openhab.binding.enocean:1.10.0]

The item is defined like this
Contact Bedroom_Contact “Left Window” (groupGF_Bedroom) {enocean="{id=00:22:CC:1F, eep=F6:10:00, parameter=CONTACT_STATE}"}

What’s wrong? Any idea?

I don’t use Enocean devices myself but I had a look at the binding code.

It looks like the openHAB Binding currently can not convert the WindowHandleState from the opencean library (used by the binding) to an openHAB State type.

The ContactStateConverter can only convert ContactState and not WindowHandleState.

So I think some code should be added to the binding to also support window handle states.

I had another look and what could also help is to use a String item instead of a Contact item. :slight_smile:

            if (item.getClass().equals(StringItem.class) && EEPId.EEP_F6_10_00.equals(eep)) {
                WindowHandleProfile profile = new WindowHandleProfile(item, eventPublisher);
                addProfile(item, parameterAddress, profile);

So try:

String Bedroom_Contact "Left Window" (groupGF_Bedroom) {enocean="{id=00:22:CC:1F, eep=F6:10:00, parameter=CONTACT_STATE}"}

Thank you for your answer. I will figure it out and will tell you what happend.