DMX LogicMachine Lights user library

I have been optimizing my DMX scripts for the LogicMachine. The following is a set of functions that will enable you to turn a set of DMX channels on/off.

-- set of variables for zones in the apartment
 alllights = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}

 bathroomlights = {7,8,20}
 livinglights = {5,6,9,10,11,12,14,15,16,17,18,19}
 kitchenlights = {13}
 bedroomlights = {1,2}
 entrancelights = {4}

-- turns DMX stripe to full on or off based on two groups
function dmxtoggle(channel, state)
 -- group that contains the value for ON
 on = grp.getvalue('5/7/17')
 -- group that contains the value for OFF
 off = grp.getvalue('5/7/18')
 if (state == true) then
  DMX.set(channel, on)
  DMX.set(channel, off)

-- loops through all lights
-- lights is an array of the channel(s) to be set
-- state is the state of the group
function dmxlooptoggle(lights, state)
 for index, value in ipairs(lights) do
  dmxtoggle(value, state)

--Loops through an array of channels and sets them to a value
function dmxloopset(lights, value)
 for index, channel in ipairs(lights) do
  DMX.set(channel, value)

To use it, create a user library, I called it mydmx. Then copy/paste the above code and change the variables to the light groups you want to switch together.

To then run it use the following code. The first line enables the above user library. Then the dmxlooptoggle is called to change the bathroom light to the value of the group (on/off). the last code updates a group that holds the status object (on/off).

dmxlooptoggle(bathroomlights, event.getvalue())
grp.write('5/7/24', event.getvalue())

Batch change color of SVG icon set

CC-SA 3.0
Iconset in LM3

I ran across this cool set of icons that can be used in home automation projects. The latest firmware from openrb allows me to use SVGs as Icons in the logic machine re:actor. Only drawback is that for each state I would like to change the color of the icon. The iconset is set in white as default color.

When you open any of the SVGs from the KNX User Forum you will find that the color is set as a standard #000000 HTML color value for white. All we would need to do is switch these from that to for example #FFFFFF for them to be black. To do this on one file the code would be:

sed -i -e's/\"#.\{6\}/\"#000000/g' -e 's/#.*;/#FFFFFF;/g' icon.svg

where icon.svg is the file we want to turn into black lines.

If we then want to change all, we need a small bash script to loop all the files in a directory and apply the change. That would look like this:

for f in *.svg; 
  echo "Changing color of $&;f ..." 
  sed -i -e's/\"#.\{6\}/\"#000000/g' -e 's/#.*;/#FFFFFF;/g' "$&;f";

It is a good Idea to rename the files with a prefix that describes the color. That way you will have them sorted by color in the logic machine. Just change Black to any color you have chosen.

for f in *.svg ; do mv "$&;f" "Black $&;f" ; done

The logic machine likes the files to be zipped if you are going to upload a batch. I used this command to generate it:

zip *

Now you can go into the logic machine and upload