22.12.2016, 00:20
(This post was last modified: 22.12.2016, 00:22 by Erwin van der Zwart.)
Hi,
If you read a 16 bits integer register you can get back value 0 to 65535, but when this register is used as single bit (not coil) you probably get back only value 0 or 1 out of this register.
To use that value for a 1 bit KNX value you can simply transfer it to boolean by using this:
To set 16 bits register value to 2 byte signed you can use this code:
BR,
Erwin
If you read a 16 bits integer register you can get back value 0 to 65535, but when this register is used as single bit (not coil) you probably get back only value 0 or 1 out of this register.
To use that value for a 1 bit KNX value you can simply transfer it to boolean by using this:
Code:
value = mb:readregisters(123)
if value == 0 or value == 1 then
value = toboolean(value)
grp.write('1/1/1', value)
end
Code:
r1 = mb:readregisters(124)
value = lmcore.inttohex(r1, 2)
value = knxdatatype.decode(value, dt.int16)
BR,
Erwin