Skip to content

Commit 91c5e29

Browse files
author
QuickSander
committed
feat: expanded identify function with blinking the light.
1 parent a6c6ed8 commit 91c5e29

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ This fork differs from the original [jnovack/homebridge-better-http-rgb](https:/
2121
updated state after reboot.
2222
* Supports regular expression pattern matching for on/off switches to determine whether the body reflects an on or off status.
2323
* Fixes a bug which causes the original plugin to not report the correct manufacturer, make and model towards HomeKit.
24+
* Briefly turn off/on or on/off the light/switch to locate the device's physical
25+
location when HomeKit requests 'identify'.
2426
* Added timeout parameter to prevent HomeBridge from getting stuck on a single unresponsive device. Credits: [Tommrodrigues/homebridge-better-http-rgb](https://github.com/Tommrodrigues/homebridge-better-http-rgb).
2527
* README rewrite and corrections.
2628

index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const SERIAL_NUMBER = '001';
1111
const MODEL = PACKAGE_JSON.name;
1212
const FIRMWARE_REVISION = PACKAGE_JSON.version;
1313

14+
const IDENTIFY_BLINK_DELAY_MS = 250; // [ms]
15+
1416
// -----------------------------------------------------------------------------
1517
// Module variables
1618
// -----------------------------------------------------------------------------
@@ -148,9 +150,22 @@ function HttpPushRgb(log, config) {
148150
HttpPushRgb.prototype = {
149151

150152
// Required Functions
153+
154+
/**
155+
* Blink device to allow user to identify its location.
156+
*/
151157
identify: function(callback) {
152158
this.log('Identify requested!');
153-
callback();
159+
160+
this.getPowerState( (error, onState) => {
161+
162+
this.setPowerState(!onState, (error, responseBody) => {
163+
// Ignore any possible error, just continue as if nothing happened.
164+
setTimeout(() => {
165+
this.setPowerState(onState, callback);
166+
}, IDENTIFY_BLINK_DELAY_MS);
167+
});
168+
});
154169
},
155170

156171
getServices: function() {
@@ -165,7 +180,7 @@ HttpPushRgb.prototype = {
165180
switch (this.serviceCategory) {
166181
case 'Light':
167182
this.log('Creating Lightbulb');
168-
this.service = new Service.Lightbulb(this.name);
183+
this.service = new Service.Lightbulb(this.name);
169184

170185
if (this.switch.status) {
171186
this.service

0 commit comments

Comments
 (0)