Controlling My UniFi AP Leds via Home Assistant

July 19, 2025 · Vivaan M #Lab #Guide #Networking

The UniFi U7 Pros have these neat LED rings on them, but they can be pretty distracting during the night - so I thought it would be cool to be able to control them via Home Assistant, and automate them. And honestly, another set of lights to have control over - especially considering they seem to make pretty good night lights.

Setting up the APs

In order to control the AP LEDs, you will need to enable SSH. You can do this via the UniFi Controller.

But first, you need to generate an SSH Key.

Generating an SSH Key

You can do this, by following the steps below:

 102:30:57 vivaan@ultimate ~ → ssh-keygen -t rsa
 2Generating public/private rsa key pair.
 3Enter file in which to save the key (/ultmt/home/vivaan/.ssh/id_rsa): ./unifi
 4Enter passphrase (empty for no passphrase):
 5Enter same passphrase again:
 6Your identification has been saved in ./unifi
 7Your public key has been saved in ./unifi.pub
 8The key fingerprint is:
 9SHA256:Bi9Oh3/y3Byyj4WxYf/GdOK+ZST5EdsVE2/FtA8sxQQ vivaan@ultimate
10The key's randomart image is:
11+---[RSA 3072]----+
12|            E+o*+|
13|             o. B|
14|      .     . oo+|
15|       +     . +*|
16|      + S +   oo+|
17|     o = . *  o+o|
18|      . o = ++ o+|
19|         = B o+o |
20|          =.+o+. |
21+----[SHA256]-----+
2202:31:17 vivaan@ultimate ~ → 

It is very important that you do not set a passphrase, otherwise Home Assistant will not be able utilise the key without requiring user input - which we do not want.

Now, to set up the key in the console

Setting up the Key in the console

Navigate to ‘UniFi Devices’

image.png

Click ‘Device Updates and Settings’ in the top left corner

image.png

This will open a menu. Scroll to the bottom to find the SSH section:

image.png

Add your SSH key that was generated previously. You can view your key by running

102:34:52 vivaan@ultimate ~ → cat test.pub
2ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDJDoV11JhVxRwKTj8W7rRbZkdtO7EppdgsG+bjCa9vcMrNGeP/Fn6d+RE9kGgn8TtdX6/9093yteH4xJoYLJ6cdYprrR8YHStN4Gpt1oUPwivck6kjVY1U1xbkC16XW/YekFgm1f/6Wb4qJSgIK6vSRQojB0iHfX96ox4oKF3Ge7b+t/ZIjmTMLICpQEwV5Ne3UUv6huwcmR7SAKFXSIv4FnNl7tD0T7p/WhrJVa3C2szVZ5dpOd0UacOch6vHaFZWvhVCaVPwMBTK/RExUMv+2XjLWbpkFYe/Y6g9yRtXq3mxPCyYPBmr7ewu71KHuHIvLHTxvU6v2So5Blwlbb+ygSbTs0cbS1PpfrYYo+5g6gz24JzDgH6vf4bw4/Ial5FOjn1wmWfURrfnDBGrn/Nqj14WX91EIjkcz/1DY0ioRovso4SLMLCaPFeRqKfnDahJuyqPZAEqztUJ7qZ4MYxHWC2Ulj9v+hyx85Fuh0CR4WJQVuVOBG5L+ABEqOgx3xM= vivaan@ultimate
302:35:32 vivaan@ultimate ~ →

Don’t worry, I generated this key for the sole purpose of this guide. Regardless, it is a Public Key after all, so it should be fine.

Setting up Home Assistant

In order for Home Assistant to be able to SSH into the APs, it needs two things. The IP Address, and the SSH Private Key you generated before.

You can get your IPs from the UniFi console, and you can get your private key by running the following:

 102:35:32 vivaan@ultimate ~ → cat unifi
 2-----BEGIN OPENSSH PRIVATE KEY-----
 3b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
 4NhAAAAAwEAAQAAAYEAyQ6FddSYVcUcCk4/Fu60W2ZHbTuxKaXYLBvm4wmvb3DKzRnj/xZ+
 5nfkRPZBoJ/E7XV+v/dPd8rXh+MSaGCyenHWKa60fGB0rTeBqbdaFD8Ir3JOpI1WNVNcW5A
 6tel1v2HpBYJtX/+lm+KiUoCCur0kUKIwdIh31/eqMeKChdxnu2/rf2SI5kzCyAqUBMFeTX
 7t1FL+obsHJke0gChV0iL+BZzZe7Q9E+6f1oayVWtwtrM1WeXaTndFGnDnIerx2hWVr4VQm
 8lT8DAUyv0RMVDL/tl4y1m6ZBWHv2OoPckbV6t5sTwsmDwZq+3sLu9Sh7hyLyx08b1Or9kq
 9OQZcJW2/soEm07NHG0tT6X62GKPuYOoM9uCcw4B+r3+G8OPyGp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go+e6e7gB181VjhkLgawz4JFQxV
25sZ54S05qrT1nBVtarIGQe4gEt9kGdn7cdLfnAUl+Ch2nKFxD9tCib7EaTYHLEJWvEE5EUA
26N2YJwZFdDITo5/21OkXggKwm4jg3n8skw0I2Qc604tiQRvqUNqzaa3gI4SIkz0jlatAAAA
27wH9sJ0lUErz7t9TvNSXQcOxwZTFmIZKkV4URceSr4qRLdK97o9o2dyQmVZjIJcI9AU8DbH
28WeBTWzGZqowbP9G+dsPQzTwBVNiLuNrJTaul1cb9sOCo3RTsKrhmvvWjKv0im87m3J4TlV
29v+CsANQk2DCWOehCcaFVkVLwDRY6rgjbu15UJN5z+57A/MfFp8qyouAZ1A733MbrgT68We
30A8UdFRu2RC9bq/6/6DarUPGH2j9becIAuax71hbSBoUcFc6wAAAMEA7kkpjvYnWFGoqmbT
31KnoBbC6i7cQRZb0qJyJPqY3nfFWzD6+YIp9xb0vaFSjCRKKgJjBbP2YGMqY91PzZCRkdI/
32MkOSt91J4WORDrfdcXJATOW3WnC/+EH4r6o++aizCi5SS741pDUA/+DEF0nxjHAv2wU8yx
33Bp2ovUmJ+1614sDm6NEvmZd8t71hNf5Y7wEMdEgwWcEmfnGeV6Or6YVGtQTiiLhnHf4qOx
34EMQymzp/l6azM9S4aEZCxTu617S7/VAAAAwQDYANlxAo7uDw9rRYhd8b9iB5yZD+CosXSX
35/kSvFayljxssRViAhHknhEEFvbmM0px3wRVqCzr38VMmDP4qso7clq426i8csIVzTIgVhY
36sD6iLgXRIZlCUvudsU8fG3pf8hpwbqnyF0xfz9T6f3qXFUHi84Qc7tcs+GTczCUdn3aOOF
37xHfHojN0LVgsN73pndBdXwTVSxIle1GJDuVsxK+e8OFTppaunjg0HIJMkVjMFbgUpyitnz
38DxNxVs2yFxf0cAAAAPdml2YWFuQHVsdGltYXRlAQIDBA==
39-----END OPENSSH PRIVATE KEY-----
4002:37:37 vivaan@ultimate ~ →

Again, I generated this key for the sole purpose of this guide, so it isn’t much of an issue putting it on the internet, as nothing actually uses it.

You should never ever give your private key to anyone else.

Doing stuff in Home Assistant

Navigate to your Home Assistant config folder.

102:40:44 vivaan@ultimate data → cd /clstr/homeassistant/data
202:40:47 vivaan@ultimate data → ls -a
3.            automations.yaml    deps                      home-assistant_v2.db-shm  scenes.yaml   zigbee.db
4..           backups             go2rtc-1.8.4              home-assistant_v2.db-wal  scripts.yaml  zigbee.db-shm
5.HA_VERSION  blueprints          home-assistant.log        integrations              secrets.yaml  zigbee.db-wal
6.cloud       configuration.yaml  home-assistant.log.1      lldap-ha-auth.sh          themes
7.ssh         core                home-assistant.log.fault  lovelace-cards-temp-vm    tts
8.storage     custom_components   home-assistant_v2.db      media                     www
902:40:48 vivaan@ultimate data →

As you can see, I have created a .ssh folder. In this folder, place your SSH key, named id_rsa .

102:40:48 vivaan@ultimate data → ls ./.ssh
2id_rsa
302:41:25 vivaan@ultimate data →

Next up, open your configuration.yaml file. (or if you’re using a modular structure like me - stay posted for a guide to do that - then open your integrations folder, and create a new file named shell_command.yaml )

102:43:59 vivaan@ultimate data → cd integrations/
2/clstr/homeassistant/data/integrations
302:44:03 vivaan@ultimate integrations → cat shell_command.yaml
4shell_command:
5  AP_NAME_led_on: ssh -o StrictHostKeyChecking=no -i ./.ssh/id_rsa USERNAME@IP "echo 1 >/proc/gpio/led_pattern ; sed -i '/mgmt.led_enabled=false/c\mgmt.led_enabled=true' /var/etc/persistent/cfg/mgmt"
6  AP_NAME_led_off: ssh -o StrictHostKeyChecking=no -i ./.ssh/id_rsa USERNAME@IP "echo 0 >/proc/gpio/led_pattern ; sed -i '/mgmt.led_enabled=true/c\mgmt.led_enabled=false' /var/etc/persistent/cfg/mgmt"
702:44:08 vivaan@ultimate integrations →

Repeat the following section for any other APs you have (if you have more then one) and ensure you set the USERNAME and IP .

1  AP_NAME_led_on: ssh -o StrictHostKeyChecking=no -i ./.ssh/id_rsa USERNAME@IP "echo 1 >/proc/gpio/led_pattern ; sed -i '/mgmt.led_enabled=false/c\mgmt.led_enabled=true' /var/etc/persistent/cfg/mgmt"
2  AP_NAME_led_off: ssh -o StrictHostKeyChecking=no -i ./.ssh/id_rsa USERNAME@IP "echo 0 >/proc/gpio/led_pattern ; sed -i '/mgmt.led_enabled=true/c\mgmt.led_enabled=false' /var/etc/persistent/cfg/mgmt"

Restart Home Assistant:

image.png

And you should end up with two (or more, but two per AP) new actions showing up.

image.png

You can use these in automation, like any standard action. For example, here’s mine to turn off the upstairs AP LED at 9, and back on at 7:

 1alias: Unifi - Automatic LED Toggle
 2description: ""
 3mode: single
 4triggers:
 5  - at: "21:00:00"
 6    id: night
 7    trigger: time
 8  - at: "07:00:00"
 9    id: day
10    trigger: time
11conditions: []
12actions:
13  - choose:
14      - conditions:
15          - condition: trigger
16            id:
17              - night
18        sequence:
19          - data: {}
20            action: shell_command.u7pro_firstfloor_led_off
21      - conditions:
22          - condition: trigger
23            id:
24              - day
25        sequence:
26          - data: {}
27            action: shell_command.u7pro_firstfloor_led_on

Thanks for reading! Stay tuned for my Home Assistant config structure, and to find out what themes and dashboards I use.