Switch off light with ZyXEL WSM20

root@WSM20-S1:~# ubus call system board
{
	"kernel": "5.15.137",
	"hostname": "WSM20-S1",
	"system": "MediaTek MT7621 ver:1 eco:3",
	"model": "ZyXEL WSM20",
	"board_name": "zyxel,wsm20",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "23.05.2",
		"revision": "r23630-842932a63d",
		"target": "ramips/mt7621",
		"description": "OpenWrt 23.05.2 r23630-842932a63d"
	}
}

The ZyXEL WSM20 (“Multy M1”) has a switch on the backside to put LED on or off. Can I use this switch with openwrt to disable the light, especially during night?

Best would be, if the front-LED blink when starting, but then are off.

root@WSM20-S1:~# uci show system
system.@system[0]=system
system.@system[0].hostname='WSM20-S1'
system.@system[0].ttylogin='0'
system.@system[0].log_size='64'
system.@system[0].urandom_seed='0'
system.@system[0].compat_version='1.1'
system.@system[0].zonename='UTC'
system.@system[0].log_proto='udp'
system.@system[0].conloglevel='8'
system.@system[0].cronloglevel='5'
system.ntp=timeserver
system.ntp.server='0.openwrt.pool.ntp.org' '1.openwrt.pool.ntp.org' '2.openwrt.pool.ntp.org' '3.openwrt.pool.ntp.org'
root@WSM20-S1:~# cat /etc/config/system

config system
	option hostname 'WSM20-S1'
	option ttylogin '0'
	option log_size '64'
	option urandom_seed '0'
	option compat_version '1.1'
	option zonename 'UTC'
	option log_proto 'udp'
	option conloglevel '8'
	option cronloglevel '5'

config timeserver 'ntp'
	list server '0.openwrt.pool.ntp.org'
	list server '1.openwrt.pool.ntp.org'
	list server '2.openwrt.pool.ntp.org'
	list server '3.openwrt.pool.ntp.org'

Yes, you just need to configure it accordingly. If you use the search function of this forum, you can find several threads discussing this here and here and here.

You should be able to switch the LED off, either via a configuration file or with a script that is run after boot. I'm not sure what the best way is, I never mess with the LEDs.

2 Likes

Checkout https://github.com/openwrt/openwrt/pull/13951, which adds support for using that button for the LEDs.

If you want to program the LED, this is what I currently use to turn off the LED at night in crontab:

# crontab -l
40 05 * * 1-5 echo 1 > /sys/class/leds/white:system/brightness
00 08 * * 0,6 echo 1 > /sys/class/leds/white:system/brightness
00 22 * *  *  echo 0 > /sys/class/leds/white:system/brightness

line by line:

  • turn on the led Mon-Fri at 5:40am
  • turn on the led Sat-Sun at 8:00am
  • turn off the led at 10:00pm each day

This alone has the disadvantage that the LED will be on after a reboot until the next "turn off" command, but since those devices run months or years at a time anyway, I don't bother.

1 Like

Thanks a lot. This issue has a low priority at the moment. I am coming back to this, when other things are solved.

Can I put

echo 0 > /sys/class/leds/white:system/brightness

in a boot script or whatever so it is executed with every boot?

Any idea, why this doesn't work with Asus?

That should work, yes.

For other devices you will have to adapt the name of the LED device. What is here /sys/class/leds/white:system/brightness could be something else, likely from /sys/class/leds/*/brightness - but since LEDs with devices and LED configuration might not be consistent, you will have to figure out which LED of the Asus has which name and use that instead.

1 Like

I meant what is the best way to do it?

As a cronjob
@reboot echo 0 > /sys/class/leds/white:system/brightness

or better something else?

if the command works and you want to turn off the LED at the end of the boot process

add command into /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

echo 0 > /sys/class/leds/white:system/brightness

exit 0

ps: runs at the end of the boot process
and obviously it must not conflict with the /etc/config/system file

and ps:
as per the files you posted in which no behavior of the LEDs is defined
if you have not defined any behavior of the LEDs the following command should report output=0

uci show | grep led | grep "default='1'" | wc -c
or
cat /etc/config/system | grep "config led" | wc -c

1 Like

If you have solved the post I recommend closing it

After executing the command manually:

root@WSM20-S1:~# uci show | grep led | grep "default='1'" | wc -c
0
root@WSM20-S1:~# cat /etc/config/system | grep "config led" | wc -c
0

It doesn't work. I tried

echo 0 > /sys/class/leds/white:system/brightness &

too. And it doesn't work as a cronjob

@reboot echo 0 > /sys/class/leds/white:system/brightness &

Maybe there can be a sleep command set before in the background. Not sure, how to do this without blocking the boot-process.

f you connect via ssh:

Does the following command work (the LED should light up)?

echo 1 > /sys/class/leds/white:system/brightness

and does the following command work (it should turn off the LED)?

echo 0 > /sys/class/leds/white:system/brightness

if the commands don't work then the LEDs could be managed on the hardware side, so a patch will be necessary

1 Like

The commands work after the router is booted. I can put leds off and on in a terminal.

first:
since you want the LED to always remain off, why not add it with the lights graphic interface if it is installed?

on my router (screenshot INFO and POWER led they were not present I add them):

add LED action (button screenshot)

cat /etc/config/system (partial only for the INFO and POWER LEDs)

config led
        option name 'INFO'
        option sysfs 'amber:info'
        option trigger 'none'
        option default '0'

config led
        option name 'POWER'
        option sysfs 'green:power'
        option trigger 'none'
        option default '0'

command find all the LEDs

find /sys/class/leds/*/brightness

output the command:

/sys/class/leds/amber:info/brightness
/sys/class/leds/green:lan/brightness
/sys/class/leds/green:power/brightness
/sys/class/leds/green:wan/brightness
/sys/class/leds/green:wlan/brightness
/sys/class/leds/red:info/brightness

better to go luci interface (very little risk of causing damage)

edit your /etc/config/system (at your own risk)
in your case similar this ...

config led
        option name 'MYLED'
        option sysfs 'white:system'
        option trigger 'none'
        option default '0'

second:
you can post your /etc/rc.local file


third:
have you thought about creating a script with the command to turn off the LED?

example:

I create the script

cat << "EOF" > /root/disable_led
#!/bin/sh
echo 0 > /sys/class/leds/white:system/brightness
#understand script executed create /tmp/disable_led.exec
touch /tmp/disable_led.exec
EOF

I make the script executable:

chmod 700 /root/disable_led

I edit /etc/rc.local accordingly
cat /etc/rc.local

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

if [ -x /root/disable_led ]; then
#exec script
/root/disable_led

#exec script on 2 minutes at boot
#opkg update; opkg install at
#install at command and test
#at -f /root/disable_led now+2minutes 2> /dev/null 1> /dev/null
fi

exit 0
1 Like

works for the WSM20, but doesn't show all LED with the AX53U. See Asus RT-AX53U: Switch off LEDs

This is empty by default and I did nothing else than to add the discussed line. IMHO the command is executed too early.

At the end it is ok for me, if I excute the command after every reboot or use a daily cronjob at noon, so it doesn't light during the night after a reboot.

Seens like a cronjob is easier.

Did not check this. Do you think I loose what I edited in /etc/rc.local after a reboot and this is the reason why it works?

so first you say that the commands (via terminal) work...?

now you tell me that the router is different....?

make a decision of which router you want to fix....

you know cars all look alike but the engines inside are different....

or another example, I have a petrol car but I insert diesel fuel
the engine may well be the same but the mechanics around it are different...

Don't take this the wrong way, I'm trying to help you but things have to stay put (one router, one problem at a time, one solution...) :smiley:

1 Like

Yes, it does with the WSM20 and partly with AX53-U

I have set a link to another router, the Asus AX53U. So I would like if you answer in the other thread too. The commands are more or less the same. See Asus RT-AX53U: Switch off LEDs - #4 by linuxuser

Both, discussed in the specific thread. The AX-53U is more important. I fear there is a bug in the Asus-image because there is a led section missing.

To switch off the LEDs in the WSM20 permantly, is more a cosmetic discussion, how to make it perfect. There are not so much reboots and a daily cronjob would do most times the job.

the controls may be the same, the engine is not...

so if you want to solve this post you have to stick to the initial request:

router=ZyXEL WSM20
what to do = always turn off the LED

I was just asking to help to solve the similar problem with the other router in another thread.

I think this could be a solution.

Maybe in a cronjob

@reboot sleep 60 &;echo 0 > /sys/class/leds/white:system/brightness &

I am angry to try this. I would have a big problem, if the router doesn't fully boot anymore.

crontab on busybox does not accept "@reboot"

Time shortcuts are not enabled by default. Shortcuts require compiling busybox with FEATURE_CROND_SPECIAL_TIMES enabled in the busybox compile options.

1 Like

use the "luci" graphical interface and set the led off and you should be good to go with this router,

for the other router you will have to wait for the LEDs to be implemented see:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=c4b806d5c4ccc653968620e6e9aec93bc4e370e5
switch LEDs are best left to be controlled by hardware for now.

1 Like