I / O module bit masks

Which part does not work?

I think that in the rules. If you look at the data from MQTT DeviceIO gets. It doesn’t go any further. Can’t there be a problem with converting from one format to another?

Any error message in openhab.log?

    020-07-19 19:29:33.653 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'output.rules'
2020-07-19 19:29:33.987 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:29:34.284 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:29:34.823 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:30:00.890 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:01.224 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:01.515 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:01.917 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:02.444 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:30:02.628 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:02.910 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:30:03.253 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:30:03.503 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:30:03.674 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 9, length 23
2020-07-19 19:45:41.354 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:45:42.357 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:45:42.710 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21
2020-07-19 19:45:43.671 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 9, length 21

Oh, missed the first part. Try

register = register.setBit(nBit)

and

register = register.clearBit(nBit)

instead.

See also this post. Once upon a time, the import java.lang.math worked for me and Biginteger bitwise.
Then it didn’t work - don’t know why, but substitute import java.math.BigInteger sorted it out.

1 Like

To declare variables?

No. Please take a look at the Rule. There are only two lines, which use register.setBit() respectively register.clearBit(). just add register = in front of the register.[set|clear]Bit()

I changed the lines in the code above.

In question of the import, I don’t need any import for BigInteger (but I did in OH1)

Log.

The import ‘java.lang.Math’ is never used.

there’s no library?

 The import 'java.lang.Math' is never used.
2020-07-20 19:08:51.657 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'output.rules'
2020-07-20 19:08:54.945 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:08:56.039 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:08:56.701 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:08:57.078 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:08:58.080 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:08:58.528 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:08:59.090 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:08:59.378 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:09:09.817 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:10.285 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:10.933 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:11.354 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:09:11.701 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:09:12.089 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23
2020-07-20 19:09:14.037 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:14.325 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:14.668 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:21.118 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:21.664 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:23.005 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'setBit' is not a member of 'BigInteger'; line 21, column 20, length 21
2020-07-20 19:09:23.025 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Device out': 'clearBit' is not a member of 'BigInteger'; line 23, column 20, length 23

This helped

import java.math.*

It works, but it doesn’t work correctly, in a different way

No, import with * is not allowed.
Please try

import java.math.BigInteger

instead. (as @rossko57 already suggested)

switch random…
hmm…

2020-07-20 19:36:55.179 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/output.rules has not been opened.
2020-07-20 19:36:58.109 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'output.rules'
2020-07-20 19:38:29.800 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 3009479 failed: null
2020-07-20 19:38:29.802 [WARN ] [io.openhabcloud.internal.CloudClient] - Response Failure: null
2020-07-20 19:38:48.516 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 3010310 failed: null
2020-07-20 19:38:48.518 [WARN ] [io.openhabcloud.internal.CloudClient] - Response Failure: null
2020-07-20 19:43:05.693 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 3024214 failed: null
2020-07-20 19:43:05.694 [WARN ] [io.openhabcloud.internal.CloudClient] - Response Failure: null

Looks like what can happen when you edit a rules file. Some editors touch the file timestamp before they have properly saved your new file, and openhab tries to load it prematurely.
Later it loads successfully, as seen in your log.

Cloud warnings are unrelated.

there are no more errors in log. The algorithm just doesn’t work correctly. And switches on other devices are not updated.

Show us your events.log for when you expect something to have happened.

Did you already restart openHAB (after the last changes)?

No restart.

2020-07-20 19:55:55.034 [ome.event.ItemCommandEvent] - Item ‘light_1’ received command ON
2020-07-20 19:55:55.046 [ome.event.ItemCommandEvent] - Item ‘InOut’ received command 1
2020-07-20 19:55:58.273 [ome.event.ItemCommandEvent] - Item ‘light_2’ received command ON
2020-07-20 19:55:58.285 [ome.event.ItemCommandEvent] - Item ‘InOut’ received command 2
2020-07-20 19:55:59.335 [ome.event.ItemCommandEvent] - Item ‘light_3’ received command ON
2020-07-20 19:55:59.346 [ome.event.ItemCommandEvent] - Item ‘InOut’ received command 4
2020-07-20 19:56:00.571 [ome.event.ItemCommandEvent] - Item ‘light_4’ received command ON
2020-07-20 19:56:00.580 [ome.event.ItemCommandEvent] - Item ‘InOut’ received command 8

4 switch on = 15

That’s pretty much what I would expect with autoupdate=“false”. You won’t get any state changes until you have your MQTT configured correctly.

To test if the rule is working as expected, you can change this line

Number DeviceIO "In/Out" { channel="mqtt:topic:myBroker:myDevice:IO", autoupdate="false" }

to this:

Number DeviceIO "In/Out" { channel="mqtt:topic:myBroker:myDevice:IO", autoupdate="true" }

but this is only to change update behavior temporally.

No work.

Number DeviceIO “In/Out” { channel=“mqtt:topic:myBroker:myDevice:IO”, autoupdate=“true” }
Group gSwitches { autoupdate=“true” }
Switch Switch_1 “Out 1 [%s]” (gSwitches) { autoupdate=“true” }