Logic Machine Forum
Make higher group adress - 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: Make higher group adress (/showthread.php?tid=2278)



Make higher group adress - PassivPluss - 10.10.2019

Hi
In current project we will make conversation from 4 bit from a swich to 0-100 % to use with dimmer output.
I want to use tag and event on the tags.
Then use event.dst to get the group adress that triggered it.
How to edit this group adress in lua?
I.e if triggered group adress returns 1/1/1
I want the output byte adress to be (1/1/1 +1) 1/1/2 ?


RE: Make higher group adress - Daniel - 10.10.2019

Hi
It is good practice to do it based on group naming. Let say your dim group will be called Room101-dim and your output group will be Room101-value then you can make such script.

Code:
outName, found = string.gsub(grp.alias(event.dst), 'dim', 'value')
value=100
if  found == 1 then
  grp.write(outName, value)
end
 
You tag only the input groups.


RE: Make higher group adress - PassivPluss - 10.10.2019

Perfect. Will try this tomorrow. Can this functions also be used in javascript/css?


RE: Make higher group adress - admin - 11.10.2019

Lua:
Code:
addr = '1/1/1'
nextaddr = buslib.decodega(buslib.encodega(addr) + 1)

Visualization:
Code:
addr = '1/1/1'
nextaddr = Scada.decodeGroupAddress(Scada.encodeGroupAddress(addr) + 1)

Apps:
Code:
addr = '1/1/1'
nextaddr = localbus.decodega(localbus.encodega(addr) + 1)