From fed0de2c9e61293783f0f236534515fdfbb86c50 Mon Sep 17 00:00:00 2001 From: Thiemo Hoffmann <20605452+theimo1221@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:57:55 +0100 Subject: [PATCH] Add functions to control the LED of an access point --- unifi.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/unifi.js b/unifi.js index f470e5f..7e9ffbd 100644 --- a/unifi.js +++ b/unifi.js @@ -2139,6 +2139,48 @@ class Controller extends EventEmitter { return this._request('/api/s//rest/device/' + ap_id.trim(), {disabled: disable}, 'PUT'); } + /** + * Override LED settings for a device (using REST) + * + * required parameter = 24 char string; value of _id for the device which can be obtained from the device list + * required parameter = string, hexCode; "#ff0000" sets LED to full red. + * required parameter = string, 0-100; "100" sets LED to full brightness. + * required parameter = string, off/on/default; "off" disables the LED of the device, + * "on" enables the LED of the device, + * "default" applies the site-wide setting for device LEDs + */ + setLED(device_id, override_color, override_color_brightness, override_mode) { + return this._request( + '/api/s//rest/device/' + device_id.trim(), + { + led_override: override_mode, + led_override_color: override_color, + led_override_color_brightness: override_color_brightness + }, + 'PUT' + ); + } + + /** + * Override LED Brightness for a device (using REST) - led_override_color_brightness() + * + * required parameter = 24 char string; value of _id for the device which can be obtained from the device list + * required parameter = string, 0-100; "100" sets LED to full brightness. + */ + setLEDBrightness(device_id, override_color_brightness) { + return this._request('/api/s//rest/device/' + device_id.trim(), {led_override_color_brightness: override_color_brightness}, 'PUT'); + } + + /** + * Override LED Color for a device (using REST) - led_override_color() + * + * required parameter = 24 char string; value of _id for the device which can be obtained from the device list + * required parameter = string, hexCode; "#ff0000" sets LED to full red. + */ + setLEDColor(device_id, override_color) { + return this._request('/api/s//rest/device/' + device_id.trim(), {led_override_color: override_color}, 'PUT'); + } + /** * Override LED mode for a device (using REST) - led_override() *