01.05.2023, 08:12
Use an event script to split the value. energy is 4 byte signed integer, tariff is 1 byte unsigned integer, tariffvalid / energyvalid are 1 bit booleans.
Code:
energy = busdatatype.decode(event.datahex:sub(1, 8), dt.int32)
tariff = tonumber(event.datahex:sub(9, 10), 16)
status = tonumber(event.datahex:sub(11, 12), 16)
tariffvalid = bit.band(status, 1) ~= 0
energyvalid = bit.band(status, 2) ~= 0
log(energy, tariff, tariffvalid, energyvalid)
grp.checkupdate('1/1/1', energy)
grp.checkupdate('1/1/2', tariff)
grp.checkupdate('1/1/3', tariffvalid)
grp.checkupdate('1/1/4', energyvalid)