Logic Machine Forum
Number codes json modbus - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Number codes json modbus (/showthread.php?tid=3660)



Number codes json modbus - Peter S - 02.11.2021

Hi,

I have a SMA inverter that gives different code numbers depending on status via modbus.
Address: 30201
303=OFF
307=OK
455=Warning
35=FAULT.

I would like to convert it to 1bit signals and make up 4 different group addresses, one for each signal. What is the best solution for this? Is it possible to convert it in the json file? Or is it better to make a script?

"name": "Status of device",
"bus_datatype": "uint32",
"type": "register",
"address": 30201,
"datatype": "int32"


Any help is much appreciated.

Peter


RE: Number codes json modbus - admin - 03.11.2021

You can map numbers to text value via Custom values for display but you cannot split such value into 4 bit objects without a script.
The event script is very simple though:
Code:
value = event.getvalue()
grp.checkwrite('1/1/1', value == 303) -- OFF
grp.checkwrite('1/1/2', value == 307) -- OK
grp.checkwrite('1/1/3', value == 455) -- Warning
grp.checkwrite('1/1/4', value == 35) -- Fault