Constant lighting control with LM2
Example: Constant lighting control with Logic Machine
Task
Dimm lights with values received from lighting sensor, only if the binary object ‘gate’ is 1. If ‘gate’ is 0, the program send 0 to output object.
Start dimming also if the object ‘gate’ changes from 0 to 1.
Input: 2/1/1
Gate: 2/1/2
Output: 2/1/3
Add the following function to Scripting–>Tools–>User function library
- function checkdimmer(event, ctrl, out)
- -- get input sensor value from group write event
- local value = dpt.decode(event.datahex, dt.scale)
-
- -- if gate is disabled, set value to 0
- if not grp.getvalue(ctrl) then
- value = 0
- end
-
- -- write to output
- grp.write(out, value, dt.scale)
- end
-
- function checkgate(event, inp, out)
- local value = 0
-
- -- gate is on, get value from input
- if dpt.decode(event.datahex, dt.bool) then
- value = grp.getvalue(inp)
- end
-
- -- write to output
- grp.write(out, value, dt.scale)
- end
Add Event-based script for the group-address 2/1/1 (Input) with the the following code
- checkdimmer(event, '2/1/2', '2/1/3')
Add Event-based script for the group-address 2/1/2 (Gate) with the the following code
- checkgate(event, '2/1/1', '2/1/3')