Tutorial - Timer for link lights for Route10

Jeff has helped me build a script to schedule the link lights on the switches. I wanted to share in case someone else still wanted to be able to turn the LEDs off at night!

A few notes before we start.

  1. The script below is set to enable the LEDs in the morning at 7:00am and disable the LEDs in the evening at 9:00PM. You can go through and adjust the times if needed, just remember to adjust them in every location. I am sure someone more clever with code than I can set a variable for the times and make it faster to change them.

  2. If you make any changes to the script you need to either reboot the switch or use PS to find the running script, kill the task, and run the script again.

Step 1: create a new script - /cfg/timer.sh and paste in the code below.

#!/bin/sh

turn_on_lights() {
    echo "Turning lights ON at $(date)"
    echo 0 > /sys/class/gpio/gpio490/value
}

turn_off_lights() {
    echo "Turning lights OFF at $(date)"
    echo 1 > /sys/class/gpio/gpio490/value
}

LAST_ACTION=""

while true; do
    # Get current time in HHMM format
    TIME=$(date +%H%M)
    
    # Check if it's 7:00 AM (0700)
    if [ "$TIME" = "0700" ] && [ "$LAST_ACTION" != "ON_0700" ]; then
        turn_on_lights
        LAST_ACTION="ON_0700"
    
    # Check if it's 09:00 PM (2100)
    elif [ "$TIME" = "2100" ] && [ "$LAST_ACTION" != "OFF_2100" ]; then
        turn_off_lights
        LAST_ACTION="OFF_2100"
    
    # Reset last action after the minute passes
    elif [ "$TIME" != "0700" ] && [ "$TIME" != "2100" ]; then
        LAST_ACTION=""
    fi
    
    # Sleep for 30 seconds before checking again
    sleep 30
done

Step 2: Make the new script is executable with chmod +x /cfg/timer.sh

Step 3: Add the following to /cfg/rc.local. (if /cfg/rc.local does not exist, create it first). /cfg/timer.sh &

That’s it. Your link lights should automatically turn off at 9:00pm and on again at 7:00am. Keep in mind if the switch restarts any time in between, the LEDs will follow the rules you have set in the controller.

5 Likes

Trying this one out and awaiting 9 PM :grinning_face: Do you know if there is anything similar for the controller (On-premises Control HW). And possibly something similar for the LED-light, or is this controlling that too?

Per an ALL Webinar from a couple months ago, control lights are not controllable, there is Link Light on Control in to add that feature.

2 Likes

Created a similar script for LED-lights for Route10 and Switch S8 (and maybe other switches too), here:

and for AP6 Pro (and maybe other APs too), here:

1 Like

Anyone knows which gpio correponds to the PoE light (same as low speed connection?!)?