Rule for using only the lower byte of an 2 Byte value?

I did some more testing :slight_smile:

This works for me:

import org.openhab.core.library.types.*
import org.openhab.model.script.actions.*
import org.openhab.core.types.Command

var Number i = 2048
rule "MB_I_Reg_10"
when
    Time cron "0 45 * * * ?" // get the rule triggered
then
    while(i < 2305) {
        logInfo("test","i = {} i % 256 = {} i & 255 = {}",i, i.intValue % 256 , i.intValue.bitwiseAnd(255))
        i = i + 1
    }
end

So there is mod() and and() available… (EDIT: but the names are different…)

In question of the mysterious 16586, I think, this is not written by the rule, does this happen at every start?