Digital Loggers

Customize your power controller using simple, powerful Lua scripting.


Updated 01/26/2022

Advanced Power Control - Lua Scripting

On its own, a power switch isn't very smart.  Add custom functionality using the built-in simple Lua scripting language. It's really simple. No programming experience is required.  Give it a try!

 

Main Lua scripting page

Reboot the modem weekly


To start automatically upon power up, set the start script



After entering the scripts (or copy/paste) and saving it, select the script to run and press the Start button to start it.
Start Scripts

-- Constants for convenience
local Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec=1,2,3,4,5,6,7,8,9,10,11,12
local Sun,Mon,Tue,Wed,Thu,Fri,Sat=1,2,3,4,5,6,7
local Modem=1 -- Modem outlet

-- Start all of my scripts from here.
-- We can start several at once this way.
function start_my_scripts()
  thread.run(reboot_modem_weekly, "Reboot the modem every week")
end
-- Reboot the modem weekly
function reboot_modem_weekly()
  for i,t,data in event.stream(event.local_time({wday=Mon,hour=4,min=0})) do
    outlet[Modem].off()
    delay(45) 
    outlet[Modem].on()  
  end
end

Have a smart script or unique way to use your switch?  Let us know!

engineering@digital-loggers.com