This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Number codes json modbus
#1
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
Reply
#2
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
Reply


Forum Jump: