[solved] Night LED timer for wifi router for OpenWrt

Note: I have not tested any of this, since I don't own your particular device.

  1. Write this script and store in /root/leds_on:
#!/bin/sh
cd /sys/class/leds/green:lan
echo netdev > trigger
echo br-lan > device_name
echo 1 > link
echo 1 > tx
echo 1 > rx
cd /sys/class/leds/green:wan
echo netdev > trigger
echo wan > device_name
echo 1 > link
echo 1 > tx
echo 1 > rx
  1. Write this script and store in /root/leds_off:
#!/bin/sh
cd /sys/class/leds/green:lan
echo none > trigger
cd /sys/class/leds/green:wan
echo none > trigger
  1. Do chmod +x on both scripts.

  2. Verify that the scripts do what you want by directly invoking them in SSH.

  3. In the LuCI interface, go to System → Scheduled Tasks and enter your desired crontab entries. Look up "cron syntax" with your favorite search engine to learn more. For example, to turn on LEDs at 6:00 AM and turn off LEDs at 9:00 PM:

0 6 * * * /root/leds_on
0 21 * * * /root/leds_off

You can do the same thing with crontab -e if you know your way around vi.

4 Likes