Logic Machine Forum
how to charge fluorescent sign - 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: how to charge fluorescent sign (/showthread.php?tid=2217)



how to charge fluorescent sign - benthoma - 31.08.2019

Hi I will turn on the light every 3 hours for 15 minutes to charge some fluorescent signs between 07-16 when the room is not in use, but stop this feature shown the room is in use. has a motion detector that records whether the room is being used. How to create this code?

I can not use the slave input of the motion detector because the rom starts heating and ventilation.


RE: how to charge fluorescent sign - admin - 03.09.2019

You can create a scheduled script that runs on a specified time. If room is not occupied then you turn the light on/off:

1/1/1 is occupancy status, 1/1/2 is light output.
Scheduled script parameters:
Minute: 0 for turn on, 15 for turn off
Hour: 7,10,13,16
Day of the month: *
Month of the year: All
Day of the week: All

Turn on:
Code:
if not grp.getvalue('1/1/1') then
  grp.write('1/1/2', true)
end

Turn off:
Code:
if not grp.getvalue('1/1/1') then
  grp.write('1/1/2', false)
end



RE: how to charge fluorescent sign - benthoma - 04.09.2019

(03.09.2019, 08:54)admin Wrote: You can create a scheduled script that runs on a specified time. If room is not occupied then you turn the light on/off:

1/1/1 is occupancy status, 1/1/2 is light output.
Scheduled script parameters:
Minute: 0 for turn on, 15 for turn off
Hour: 7,10,13,16
Day of the month: *
Month of the year: All
Day of the week: All

Turn on:
Code:
if not grp.getvalue('1/1/1') then
  grp.write('1/1/2', true)
end

Turn off:
Code:
if not grp.getvalue('1/1/1') then
  grp.write('1/1/2', false)
end
tnx this will work, but is it possible to check more rooms in the same code? how will that code look like?


RE: how to charge fluorescent sign - admin - 05.09.2019

Create a User library called rooms. Modify rooms table as needed. You can add any number of rows.

Code:
rooms = {
  { status = '1/1/1', output = '1/1/2' },
  { status = '2/1/1', output = '2/1/2' },
  { status = '3/1/1', output = '3/1/2' },
  { status = '4/1/1', output = '4/1/2' },
  { status = '5/1/1', output = '5/1/2' },
  { status = '6/1/1', output = '6/1/2' },
}

function setrooms(value)
  for _, room in ipairs(rooms) do
    local status = grp.getvalue(room.status)
    if not status then
      grp.write(room.output, value)
      os.sleep(0.2)
    end
  end
end

Turn on:
Code:
require('user.rooms')
setrooms(true)

Turn off:
Code:
require('user.rooms')
setrooms(false)



RE: how to charge fluorescent sign - benthoma - 05.09.2019

(05.09.2019, 06:26)admin Wrote: Create a User library called rooms. Modify rooms table as needed. You can add any number of rows.

Code:
rooms = {
  { status = '1/1/1', output = '1/1/2' },
  { status = '2/1/1', output = '2/1/2' },
  { status = '3/1/1', output = '3/1/2' },
  { status = '4/1/1', output = '4/1/2' },
  { status = '5/1/1', output = '5/1/2' },
  { status = '6/1/1', output = '6/1/2' },
}

function setrooms(value)
  for _, room in ipairs(rooms) do
    local status = grp.getvalue(room.status)
    if not status then
      grp.write(room.output, value)
      os.sleep(0.2)
    end
  end
end

Turn on:
Code:
require('user.rooms')
setrooms(true)

Turn off:
Code:
require('user.rooms')
setrooms(false)
tnx Smile