I’m fairly new with openhab, I have been working with it for a small week now.
My input is driven by on mqtt and my output is driven by modbus.
I’m communicating with a wago 750-881 plc.
I’m using push buttons to handle my output. one push is on, a second push is off.
When I push a button i receive a ‘ON’ command, when i release the button I receive an ‘OFF’ command.
I’m working with the ON and OFF on the push button to get to the next level where I’m able to dim my lights by a long press
and my rule to handle the press on the button is the following
rule "toggle"
when
Item mqttSwitchIn2 received command OFF
then
if (modbusSwitchOut1.state != ON)
modbusSwitchOut1.sendCommand(ON)
else
modbusSwitchOut1.sendCommand(OFF)
end
This is all very straight forward.
Now i see on my sitemap, that the status of my out switch is not updated, this means when I turn on the lights, i have to click twice in my sitemap to turn out the light.
I’m wondering what I’m doing wrong, do I need to send a event to the sitemap to make sure it is updated to the new model?
I know this works, but is this a good design for openhab buttons?
If you can get feedback from the Wago as to the real state of the output, that would be the best way to go. Else have the rule postUpdate the new switch state.
thus this means I would need to bind the same input as output to my button?
like this? Switch modbusSwitchOut1 "modbus switch 1 out" (ALL) {modbus="<[plc:512],>[plc:512]"}
Is this a good design for what I’m trying to achieve?
Thus i would have 2 bindings, one starting at 0 for my inputs and one
starting at 512 for my outputs? I was thinking about that but I did not
know it was better than having 1 binding
Yes. That would mean the modbus polling service makes two polls of small groups of registers instead of a one poll of many hundreds. Even if not all the possible registers are bound to OH Items, the binding will read all of the specified (read or r/w) registers across Modbus.
The choice is yours - “better” depends on your whole situation.