Hello,
I’m currently setting up OpenHAB for Home Automation with a Wago PLC. The PLC is integrated with the Modbus Binding over Modbus TCP. I have already a working setup that enables me to read/write coils/register in my PLC, so communication already works fine.
Next step is to integrate a simple light to OpenHAB controlled by the PLC. This light can also be switched on/off by a wall mounted switch also attached to the PLC, so the state of the light can change at any time (and OpenHAB should always know the actual and not any predicted state).
Therefore I provide 3 Modbus variables in the PLC that can be read/written by OpenHAB:
- get the actual light state (read by OpenHAB)
- switch light on (written by OpenHAB)
- switch light off (written by OpenHAB)
What I have in OpenHAB:
3 Things to read/write the above modbus variables
Bridge modbus:tcp:wago_t "Bridge Wago-T" [ host="192.168.80.3", port="502", id=1 ] {
// read-only for discrete inputs
Bridge poller discreteInputs [ start=6144, length=1, refresh=500, type="discrete" ] {
Thing data OH_R031_LichtStatus [ readStart="6144", readValueType="bit" ]
}
// Write-only entry: thing is child of tcp directly. No readStart etc. need to be defined.
// Note that the openHAB state might differ from the physical slave since it is not refreshed at all
Thing data OH_R031_LichtAn [ writeStart="0", writeValueType="bit", writeType="coil", writeMultipleEvenWithSingleRegisterOrCoil="true" ]
Thing data OH_R031_LichtAus [ writeStart="1", writeValueType="bit", writeType="coil", writeMultipleEvenWithSingleRegisterOrCoil="true" ]
}
and 3 switch items (each bound to the corresponding modbus data thing):
Switch SW_031_LichtStatus {channel="modbus:data:wago_t:discreteInputs:OH_R031_LichtStatus:switch"}
Switch SW_031_LichtAn {channel="modbus:data:wago_t:OH_R031_LichtAn:switch"}
Switch SW_031_LichtAus {channel="modbus:data:wago_t:OH_R031_LichtAus:switch"}
What I want:
Just one combined switch item that is bound to the 3 data things and which shows the actual state of the light and is also able to switch the light on and off.
I found out that the design pattern “Proxy item” by @rlkoshak may suite to my Problem, but doing that will mean that for about 50 lights in the building I’ll have a lot of monkey work to do (e.g. creating 50 rules for the proxy items). So I wonder if there is a simpler way to achieve this? Isn’t there a more generic way to group multiple things and link them to one item? Or is this problem some kind of PLC specific, because other bindings usually combine state and on/off commands already in the thing layer to one thing and modbus binding doesn’t do this? Maybe I’m just missing another layer between things and items…
Thanks,
Tobias