Skip to content

Commit

Permalink
Make serial number/model changes optional dxdc#32
Browse files Browse the repository at this point in the history
  • Loading branch information
dxdc committed Apr 29, 2020
1 parent 50bd318 commit 8d816af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8d816af

Please sign in to comment.