Controlling X10 with OH4

I’m running openHAB 4.0.3 on a Raspberry Pi 4 Model B and would like to use the “X10 Controller Binding [3.3.0.0;4.0.0.0)” to communicate with a CM15A.

I’ve installed Mochad and am able to control some lamp modules using on/off/dim commands, with both RF and PL commands from a command line using Putty.

I would appreciate instructions on how to create the bridge, things and items from within OpenHAB 4. When I try to add a thing for the X10 binding, I get the screen shown at the end, but there’s nothing to click on.

\var\lib\openhab\jsondb contains the json definitions, but I’m not knowledgeable enough to create the definitions from scratch, and I’d rather create everything from within OpenHAB if possible.

I’ve tried contacting the author, but no reply. The name of the binding implies it should work with openHAB4, but the examples he provides look to be OH2 vintage, e.g.

Bridge x10:cm15a:MyCm15a  [ host="mochad.local" ] {
    Thing switch SwitchA1 [ houseUnitCode="A1", viaRF=true ]
    Thing dimmer DimmerA2 [ houseUnitCode="A2", extendedDimming=false ]
}

and

SwitchA1  "Kitchen Plug"   <light>  (someGroup)  { channel="x10:switch:MyCm15a:SwitchA1:switchstatus" }
DimmerA2  "Porch lights"   <slider> (someGroup)  { channel="x10:dimmer:MyCm15a:DimmerA2:lightlevel" }
SwitchB1  "Garage Plug"    <light>  (someGroup)  { channel="x10:switch:MyCm11a:SwitchB1:switchstatus" }
DimmerB2  "Garden lights"  <slider> (someGroup)  { channel="x10:dimmer:MyCm11a:DimmerB2:lightlevel" }

Is official binding or third party?

I found recently that OH 4.0 UI does not show thing types if their id do not match addon name. Even if my addons were installed properly UI didn’t list thing types provided by them cause feature was named openhab-binding-bacnet but thing types/binding used co7io-bacnet identifier.

Thanks, Łukasz, but I think that’s not the problem here.

It’s a Community Marketplace binding, and the binding’s documentation implies that the thing and bridge must be defined textually (they won’t be discovered) and I don’t know how to do that in OH4.

You need to place sample contents in things file located in conf/things folder. File extension should be .things.

Thanks. I will try that and let you know.

Thanks to your help, I think I successfully created four things as x10.things:

Bridge x10:cm15a:MyCm15a  [ host="openhabian" ] {
    Thing dimmer Office_Floor_Lamp [ houseUnitCode="E8", extendedDimming=false ]
    Thing switch Office_Table_Lamp [ houseUnitCode="E1" ]
    Thing dimmer Media_Room_Dimmer [ houseUnitCode="E3", extendedDimming=false ]
    Thing dimmer Basement_Bedrrom_Dresser_Lamp [ houseUnitCode="E5" ]
}

I then created an x10.items file with just 1 line:

Office_Floor_Lamp "Office Floor Lamp" <slider> (Office) { channel="x10:dimmer:MyCm15a:Office_Desk_Lamp:lightlevel" }

As soon as I write the file, the log shows:

2023-10-06 16:55:37.477 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'x10.items' has errors, therefore ignoring it: [1,1]: missing EOF at 'Office_Floor_Lamp'

On the hour, but not every hour, I also get:

2023-10-06 16:00:29.335 [WARN ] [ternal.handler.AbstractBridgeHandler] - Bridge is not set

I’ve since rebooted the Pi and didn’t receive the bridge error at 17:00, but expect to see it again at 18:00.

Any further ideas?

There is syntax error in items file, it could be that it simply miss a new line at the end or have a wrong starting character (BOM for utf8 encoded files).

With regard to AbstractBridgeHandler log entry try commenting out / removing thing definitions and adding them back one by one and see which one triggers that message.

Thanks again.

My main problem was caused by wrong info in the binding’s documentation for item definition. It said:

SwitchA1 "Kitchen Plug" <light>  (someGroup) { channel="x10:switch:MyCm15a:SwitchA1:switchstatus" }

But should have said:

Switch SwitchA1 "Kitchen Plug" <light>  (someGroup) { channel="x10:switch:MyCm15a:SwitchA1:switchstatus" }

The “Bridge is not set” will require repairing the binding, I think. Not sure if I’m capable, but I’ll look into it. The message occurs when an X10 event takes place that is not initiated from OpenHAB even though the items that generate the error are defined inside OpenHAB (e.g. E1).
Or maybe, the OpenHAB name, e.g. TestDimmer needs to match the X10 “name” (E1)? <Edit: Nope. Just tried creating thing and item, both named “E7”. Same warnings.>