Wago PLC with modbus

Thanks a lot, I got to the bottom of my problem, but I have another hurdle in fornt of me. Just to help others who are tring to use Wago PFC 200 (8202) PLC contorller with openhab and modbus I will tell that you cant use graphical modbus configurator tool in eCockpit. It works, but you can’t make make real read/wite variable. You can write by modbus to PLC, but you can’t overwrite that variable from PLC itself. To achive such behavior you should use wago modbus library and setup standalone modbus slave server. Rember to turn off modbus service in WBM or setup new one on different port.

That’s said, I am back with another problem. Until now I was using Papuer UI to test everything and it works quite well. But now I want to move everything to files and start using proper UI for my smart home.

I created sitemap and other files with Home Builder tool, it looks nice, but I have no communication between OH interface and PLC. When I slide the switch nothing happens. In logs I can see that modbus is correctly polling modbus coils representing state of the Light, when I change it by wall switch, but slider in Openhab doesn’t change position.

So I put my files here:

item:

Switch FF_Office_Light_2 “Światło Główne” (FF_Office, gLight) [“Lighting”, “Switchable”] {channel=“modbus:tcp:wagoMB:coils:SwiatloGabinet:switch”, autoupdate=“false”}

things:

Bridge modbus:tcp:wagoMB [ host=“192.168.10.60”, port=502, id=1 ] {
Bridge poller coils [ start=0, length=2, refresh=1000, type=“coil” ] {
// Note the zero based indexing: first coil is index 0.
Thing data SwiatloGabinet [ readStart=“1”, readValueType=“bit”, writeStart=“0”, writeValueType=“bit”, writeType=“coil” ]
}}

Sitemap:

sitemap dom label=“Stokrotki” {
Frame label=“Parter” icon=“groundfloor” {
Group item=GF_LivingRoom
Group item=GF_Dining
Group item=GF_Boiler
Group item=GF_Garage
Group item=GF_Bathroom
Group item=GF_Entryway
Group item=GF_Corridor
}

Frame label="Pierwsze Piętro" icon="firstfloor" {
    Group item=FF_MasterBedroom
    Group item=FF_Office
    Group item=FF_KidsRoom
    Group item=FF_GuestRoom
    Group item=FF_Wardrobe
    Group item=FF_Bathroom
    Group item=FF_Kanciapa
}

Frame label="Poddasze" icon="attic" {
    Group item=AT_StorageRoom
}

Frame label="Posesja" icon="garden" {
    Group item=OU_Backyard
}

Frame {
    Text label="Światło" icon="light" {
        Default item=GF_LivingRoom_Light label="Pokój Dzienny"
        Default item=GF_Dining_Light label="Jadalnia"
        Default item=GF_Entryway_Light label="Wejście"
        Default item=GF_Corridor_Light label="Korytarz"
        Default item=FF_MasterBedroom_Light label="Główna Sypialnia"
        Default item=FF_Office_Light label="Biuro"
        Default item=FF_KidsRoom_Light label="Pokój Dziecięcy"
        Default item=FF_GuestRoom_Light label="Pokój gościnny"
        Default item=FF_Wardrobe_Light label="Garderoba"
        Default item=FF_Bathroom_Light label="Łazienka"
        Default item=FF_Kanciapa_Light label="Kanciapa"
        Default item=AT_StorageRoom_Light label="Przechowalnia"
        Default item=OU_Backyard_Light label="Ogród"
    }
}

}

I tried to compare everything with Paper UI config and it seems almost match. The only difference is that when I list Things in Paper UI I dont se linked Items (when using fles config). I don’t now. So it looks like I don’t have linked items and don’t know how to linked them in files config.

and modbus logs:

2020-10-26 17:29:49.909 [DEBUG] [rt.modbus.internal.ModbusManagerImpl] - Executing scheduled (1000ms) poll task BasicPollTask@70c1b4[request=ModbusReadRequestBlueprint@a87cd8[slaveId=1,functionCode=READ_COILS,start=0,length=2,maxTries=3],endpoint=ModbusTCPSlaveEndpoint@c5f714[address=192.168.10.60,port=502],resultCallback=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@4beb4b,failureCallback=org.openhab.binding.modbus.handler.ModbusPollerThingHandler$ReadCallbackDelegator@4beb4b]. Current millis: 1603733389908
2020-10-26 17:29:49.910 [DEBUG] [wimpi.modbus.net.TCPMasterConnection] - connect()
2020-10-26 17:29:50.007 [DEBUG] [bus.handler.ModbusPollerThingHandler] - Thing modbus:poller:wagoMB:coils received response PollResult(result=AsyncModbusReadResult(request = ModbusReadRequestBlueprint@a87cd8[slaveId=1,functionCode=READ_COILS,start=0,length=2,maxTries=3], bits = BitArray(bits=00)))
2020-10-26 17:29:50.009 [DEBUG] [ernal.handler.ModbusDataThingHandler] - Thing modbus:data:wagoMB:coils:SwiatloGabinet channels updated: {}. readValueType=bit, readIndex=Optional[1] → numeric value 0 and boolValue=false. Bits BitArray(bits=00) for request ModbusReadRequestBlueprint@a87cd8[slaveId=1,functionCode=READ_COILS,start=0,length=2,maxTries=3]
2020-10-26 17:29:50.056 [DEBUG] [rt.modbus.internal.ModbusManagerImpl] - Modbus operation ended, timing info: {total: 146 ms, connection: 48, transaction=93, callback=5} [operation ID 1d0667ce-bd81-48b7-83f5-871d826e216d]

The simplest way to get this stuff correct is to copy/paste the channel UID visible in PaperUI.
From your screenshot, that’s more like
modbus:data:wago … etc.

Thanks rossko57. You’re great. I hate these typos. Works like a dream.

The logic behind figuring out workable UIDs is all rather opaque. Using PaperUI as a “reader” is really the way to go.

In this case, when you think about it, your data channel has no need to know anything about tcp or serial - that’s the business of the Bridge Things higher up in the hierarchy.