Logic Machine Forum
grp.create() value_custom - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: grp.create() value_custom (/showthread.php?tid=4044)



grp.create() value_custom - emme - 15.05.2022

Ciao,

creating modbus device profile is it possible to specify custom value visual by using the value_custom key as table.

Is there a way to use the same key in scripting while creating objects using the grp.create() function?

I tried value_custom()... but it was not considered while creating a new group

thansk
Ciao
M


RE: grp.create() value_custom - admin - 16.05.2022

This field is called enums in grp.create. It should either be a Lua table or a string containing a JSON object.


RE: grp.create() value_custom - p_xatzi - 29.02.2024

(16.05.2022, 07:43)admin Wrote: This field is called enums in grp.create. It should either be a Lua table or a string containing a JSON object.

Hi again,

It works for objects accepting custom values. However the following code causes temperature to be read as (22) instead of 22.15

Code:
grp.create({
    datatype = 9001,
    address = '3/2/56',
    name = 'Temperature',
    enums = {},
    comment = '',
    forcename =true
  })

So, I also tried

Code:
enums = nil

which works, but point is, if I had once set 
Code:
enums = {},
then
Code:
enums = nil
cannot fix object read value until I delete it and recreate it.

I addition when I log same object when set right I see an empty string for enum key.

Can you please make more clear all the above.

Thanks in advance.


RE: grp.create() value_custom - admin - 29.02.2024

At the moment it's not possible to clear custom values for existing objects via grp.create. If you set enums to an empty table it will still be used to lookup custom values. Since the table is empty the resulting value text is also empty.