diff --git a/README.md b/README.md index 84a6fb3..4e402ee 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Add the accessory in `config.json` in your home directory inside `.homebridge`. "success_codes": [ 200, 204 ], "max_http_attempts": 5, "retry_delay": 2000, + "unique_serial": false, "use_same_url_for_stop": false, "show_stop_button": false, "show_toggle_button": false, @@ -208,6 +209,8 @@ These can be set to `true` or `false`, but the default is `false`. These can be set to `true` or `false`, but the default is `false`. +- `unique_serial` will use a uuid-based serial/model number instead of the default `BlindsHTTPAccessory`. This should only be required for specific external integrations (such as Eve) that may have problems with identical serial numbers for multiple devices. + - `use_same_url_for_stop` will send the previously sent url (either, `up_url` or `down_url`) again. This is for specific blind types that don't use a standard stop URL. - `trigger_stop_at_boundaries` sends an additional stop command when moving the blinds to position 0 or 100. Most blinds dont require this command and will stop by themselves. diff --git a/index.js b/index.js index 1cfd14f..3eb1cf4 100644 --- a/index.js +++ b/index.js @@ -70,6 +70,7 @@ function BlindsHTTPAccessory(log, config) { this.responseLag = parseInt(config.response_lag, 10) || 0; // advanced vars + this.uniqueSerial = config.unique_serial === true; this.stopAtBoundaries = config.trigger_stop_at_boundaries === true; this.useSameUrlForStop = config.use_same_url_for_stop === true; this.verbose = config.verbose === true; @@ -639,12 +640,20 @@ BlindsHTTPAccessory.prototype.httpRequest = function(url, methods, callback) { BlindsHTTPAccessory.prototype.getServices = function() { this.services = []; + let customName = ''; + let customSerial = ''; + + if (this.uniqueSerial) { + customName = 'BlindsHTTPAccessory-'; + customSerial = '-' + UUIDGen.generate(this.name); + } + const informationService = new Service.AccessoryInformation(); informationService .setCharacteristic(Characteristic.Manufacturer, 'homebridge-blinds') .setCharacteristic(Characteristic.Name, this.name) - .setCharacteristic(Characteristic.Model, 'BlindsHTTPAccessory-' + this.name) - .setCharacteristic(Characteristic.SerialNumber, 'BlindsHTTPAccessory-' + UUIDGen.generate(this.name)) + .setCharacteristic(Characteristic.Model, customName + this.name) + .setCharacteristic(Characteristic.SerialNumber, 'BlindsHTTPAccessory' + customSerial) .setCharacteristic(Characteristic.FirmwareRevision, packageJSON.version); this.services.push(informationService);