I / O module bit masks

It is possible for different devices (different UIs) to respond in different ways to a click on screen, without the actual openHAB Item state changing. I think that is what is being described, but it is hard work.

Yes, I restart openhab app and openhab. One switch has different States on different devices.

It works

Final code

import java.math.BigInteger

rule “Device in”

when

Item InOut changed

then

var BigInteger register = (InOut.state as DecimalType).toBigDecimal.toBigInteger

gLights.members.forEach[i |

    val Integer nBit = Integer::parseInt(i.name.split("_").get(1)) - 1

    i.postUpdate(if(register.testBit(nBit) == true) ON else OFF)

]

end

rule “Device out”

when

Member of gLights received command

then

var BigInteger register = (InOut.state as DecimalType).toBigDecimal.toBigInteger

val Integer nBit = Integer::parseInt(triggeringItem.name.split("_").get(1)) - 1

if(receivedCommand == ON)

    register = register.setBit(nBit)

else

    register = register.clearBit(nBit)

InOut.sendCommand(register)

end

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.