# \[Solved\] TP-Link RE650: Adding a function to a button

**URL:** <https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025>\
**Category:** Installing and Using OpenWrt\
**Created:** [September 21, 2021, 6:20am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025 "2021-09-21T06:20:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 6:20am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/1 "2021-09-21T06:20:36Z")

</div>

Hello everyone,

I'm trying to add function to a button on my RE650 on OpenWrt 21.02.

Reading [the wiki](https://openwrt.org/docs/guide-user/hardware/hardware.button) and [this post](https://forum.openwrt.org/t/toggle-led-with-push-button/71599/4) gave me some idea, but I didn't succeed so far.

**/sys/kernel/debug/gpio**

```
gpiochip2: GPIOs 416-447, parent: platform/1e000600.gpio, 1e000600.gpio-bank2:

gpiochip1: GPIOs 448-479, parent: platform/1e000600.gpio, 1e000600.gpio-bank1:

gpiochip0: GPIOs 480-511, parent: platform/1e000600.gpio, 1e000600.gpio-bank0:
 gpio-498 ( |wps ) in hi IRQ
 gpio-499 ( |reset ) out hi ACTIVE LOW
 gpio-502 ( |blue:power ) out lo ACTIVE LOW
 gpio-503 ( |blue:wifi2g ) out lo ACTIVE LOW
 gpio-504 ( |blue:wifi5g ) out hi ACTIVE LOW
 gpio-505 ( |power ) in hi IRQ
 gpio-506 ( |red:wps ) out lo
 gpio-507 ( |blue:wps ) out lo
 gpio-508 ( |green:eth_act ) out hi ACTIVE LOW
 gpio-509 ( |green:eth_link ) out lo ACTIVE LOW
 gpio-510 ( |led ) in hi IRQ
 gpio-511 ( |reset ) in hi IRQ

```

So the button "led" seems to be known to the system. That's why I thought adding the following file and doing "chmod 755" could be enough, but no /root/buttonpress.test appears when pressing the button.

**/etc/rc.button/led**

```
#!/bin/sh

["${ACTION}" = "released"] || exit 0

echo "pressed" > /root/buttonpress.test

return 0

```

Any help on this is very much appreciated!

---

<div class="post-metadata">

**Author:** ![frollic](https://forum.openwrt.org/user_avatar/forum.openwrt.org/frollic/32/30113_2.png) [@frollic](https://forum.openwrt.org/u/frollic)\
**Post date:** [September 21, 2021, 6:38am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/2 "2021-09-21T06:38:32Z")

</div>

i'd probably put the file in /tmp/ just to make sure it's not an auth issue.

---

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 6:59am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/3 "2021-09-21T06:59:59Z")

</div>

Thank you for the suggestion, but unfortunately the same result. Do I have to restart / reload anything for the new button script in /etc/rc.button/ to be picked up?

Also I keep reading about DTS (like in the above mentioned post) and don't know if I need to do further customization around that topic to make the button work...

---

<div class="post-metadata">

**Author:** ![frollic](https://forum.openwrt.org/user_avatar/forum.openwrt.org/frollic/32/30113_2.png) [@frollic](https://forum.openwrt.org/u/frollic)\
**Post date:** [September 21, 2021, 7:01am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/4 "2021-09-21T07:01:17Z")

</div>

might also want to put an echo before the variable check, just to check if the script gets executed, at all.

---

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 7:03am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/5 "2021-09-21T07:03:39Z")

</div>

It doesn't. Still nothing with the following file in /etc/rc.button:

```
#!/bin/sh

echo "pressed" > /tmp/buttonpress.test
echo "${ACTION}" >> /tmp/buttonpress.test

return 0

```

---

<div class="post-metadata">

**Author:** ![psherman](https://forum.openwrt.org/letter_avatar/psherman/32/5_5575768a8748004e209b776fc1b2916d.png) [@psherman](https://forum.openwrt.org/u/psherman)\
**Post date:** [September 21, 2021, 7:07am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/6 "2021-09-21T07:07:30Z")

</div>

If you haven’t already read this, take a look at the [buttons hotplug tutorial](https://openwrt.org/docs/guide-user/hardware/hardware.button).

---

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 7:20am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/7 "2021-09-21T07:20:05Z")

</div>

I read the whole article but don't really understand what is being said about procd vs hotplug. It seems my device on 21.02 uses procd?

I can find the following packages installed on my default installation:  
procd  
kmod-gpio-button-hotplug

/etc/hotplug.d exists, but no subdir "button".

---

<div class="post-metadata">

**Author:** ![pavelgl](https://forum.openwrt.org/user_avatar/forum.openwrt.org/pavelgl/32/33073_2.png) [@pavelgl](https://forum.openwrt.org/u/pavelgl)\
**Post date:** [September 21, 2021, 7:27am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/8 "2021-09-21T07:27:47Z")

</div>

The first script in the [preliminary steps](https://openwrt.org/docs/guide-user/hardware/hardware.button#preliminary_steps) will show you if the button name is really "led" and if there are detected any actions.

---

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 8:24am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/9 "2021-09-21T08:24:18Z")

</div>

Nice, thank you pavelgl. The hotplug-script worked and told me that the button was called "lights\_toggle" instead of "led".

Creating /etc/rc.button/lights\_toggle and giving it execute permission worked as expected. I will post back with the complete script as soon as I've finished and tested it!

---

<div class="post-metadata">

**Author:** ![PrePeter](https://forum.openwrt.org/letter_avatar/prepeter/32/5_5575768a8748004e209b776fc1b2916d.png) [@PrePeter](https://forum.openwrt.org/u/PrePeter)\
**Post date:** [September 21, 2021, 8:54am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/10 "2021-09-21T08:54:30Z")

</div>

This is what I came up with to toggle all LEDs. Thank you all for your help!

**/etc/rc.button/lights\_toggle**

```
#!/bin/sh

["${ACTION}" = "released"] || exit 0

if ["$(cat /sys/class/leds/blue:power/brightness)" -eq 255]; then
        logger "Button 'lights_toggle' pressed, disabling LEDs"
        echo 0 > /sys/class/leds/blue:power/brightness
        echo "none" > /sys/class/leds/blue:wifi2g/trigger
        echo "none" > /sys/class/leds/blue:wifi5g/trigger
        echo "none" > /sys/class/leds/green:eth_link/trigger
        echo "none" > /sys/class/leds/green:eth_act/trigger
else
        logger "Button 'lights_toggle' pressed, enabling LEDs"
        echo 255 > /sys/class/leds/blue:power/brightness
        echo "phy0tpt" > /sys/class/leds/blue:wifi2g/trigger
        echo "phy1tpt" > /sys/class/leds/blue:wifi5g/trigger
        # Ethernet port LEDs are configured in /etc/config/system, restore them by restarting service
        /etc/init.d/led restart
fi

return 0

```

---

<div class="post-metadata">

**Author:** ![tmomas](https://forum.openwrt.org/letter_avatar/tmomas/32/5_5575768a8748004e209b776fc1b2916d.png) [@tmomas](https://forum.openwrt.org/u/tmomas)\
**Post date:** [September 21, 2021, 11:05am UTC](https://forum.openwrt.org/t/solved-tp-link-re650-adding-a-function-to-a-button/107025/11 "2021-09-21T11:05:27Z")

</div>

If your problem is solved, please consider marking this topic as [Solved]. See [How to mark a topic as [Solved]](https://forum.openwrt.org/t/how-to-mark-a-topic-as-solved/40174) for a short how-to.
