22.12.2021, 10:52
It's not possible to do this via a profile, you will have to use scripts. You can access the same RS485 port from both profiles and scripts using mbproxy.
You can read multiple coils/inputs via a script and convert to a number.
The addressing probably starts from 0 so you have to subtract 1 from the documented addresses.
Temperature will not work with "value_multiplier": 0.1, try using "datatype": "float16" and "bus_datatype": "float16" without "value_multiplier".
You can read multiple coils/inputs via a script and convert to a number.
Code:
function bitstonumber(bits)
local res = 0
for bnum, bval in ipairs(bits) do
if bval then
res = bit.bor(res, bit.lshift(1, bnum - 1))
end
end
return res
end
mb = require('mbproxy').new()
mb:setslave(1)
bits = { mb:readcoils(8, 8) }
if #bits == 8 then
mode = bitstonumber(bits)
log(mode)
else
log(bits)
end
The addressing probably starts from 0 so you have to subtract 1 from the documented addresses.
Temperature will not work with "value_multiplier": 0.1, try using "datatype": "float16" and "bus_datatype": "float16" without "value_multiplier".