Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bridges/lutron-bridge.js b/bridges/lutron-bridge.js
- old mode 100644
- new mode 100755
- index 2a53466..c7fc4ef
- --- a/bridges/lutron-bridge.js
- +++ b/bridges/lutron-bridge.js
- @@ -32,7 +32,7 @@ module.exports = {
- // const assert = require('assert');
- const log = require('loglevel');
- -log.setLevel('info')
- +log.setLevel('debug')
- const net = require('net');
- const tls = require('tls');
- @@ -56,6 +56,7 @@ const communiqueBridgeScenesRequest =
- '{"CommuniqueType":"ReadRequest","Header":{"Url":"/virtualbutton"}}\n';
- const communiqueBridgeButtonGroupsRequest =
- '{"CommuniqueType":"ReadRequest","Header":{"Url":"/buttongroup"}}\n';
- +const communiqueBridgeButtonGroupsRequestUrl = '/buttongroup';
- const communiqueBridgeButtonsRequest =
- '{"CommuniqueType":"ReadRequest","Header":{"Url":"/button"}}\n';
- const communiqueBridgeButtonProgrammingModelRequest1of2 =
- @@ -98,6 +99,9 @@ const communiqueBridgePicoButtonActionPressAndRelease3of3 =
- const communiqueBridgePicoButtonActionPressAndHold3of3 = '"PressAndHold"}}}\n';
- const communiqueBridgePicoButtonActionRelease3of3 = '"Release"}}}\n';
- +const statusCodeNoContent = '204 NoContent';
- +const statusCodeCreated = '201 Created';
- +
- const LB_REQUEST_TIMEOUT = 5000; // was 1500
- const LB_RESPONSE_TIMEOUT = 20000; // was 3000
- const LB_RECONNECT_DELAY_RESET = 30000;
- @@ -247,7 +251,7 @@ function picoID(lbridgeID, picoDevice, picoButtonNumber) {
- return lbridgeID + ":" + picoDevice + ":" + picoButtonNumber;
- }
- -function picoReportJSONFormatter(picoBridge, picoDevice, picoButtonNumber, picoOpName) {
- +function picoReportJSONFormatter(picoBridge, picoDevice, picoButtonNumber, picoOpName) {
- return {
- Header: {
- MessageBodyType: "ButtonAction",
- @@ -809,11 +813,7 @@ Bridge.prototype._handleIncomingSSLData = function (msgStringData, digest) {
- // update the buttons table from SmartThings device handlers to add LIP button number (2-6, 8-11) and press/hold mode
- this._logger.info('Lutron Bridge %s Pico info:\n%o\n', this.bridgeID, this._picoList);
- - this._bridgeEvents.emit(BE_GOTBUTTONGROUPS, this.bridgeIX);
- - this._bridgeEvents.emit(BE_GOTDEVICES, this.bridgeIX, this._updatedDevices); // we've got all the device info available; tell the listener(s)
- -
- - if (this._dReqDeviceListCallback.length)
- - this._dReqDeviceListCallback.shift()(this.bridgeIX);
- + this._bridgeAnnounceAllDeviceInfoIsAvailable();
- return;
- }
- else if (jsonData.Header.MessageBodyType == 'OneProgrammingModelDefinition') {
- @@ -901,8 +901,15 @@ Bridge.prototype._handleIncomingSSLData = function (msgStringData, digest) {
- }
- return;
- }
- - else if (jsonData.Header.StatusCode == '204 NoContent' ||
- - jsonData.Header.StatusCode == '201 Created') { // probably a command acknowledgement
- + else if (jsonData.Header.StatusCode == statusCodeNoContent ||
- + jsonData.Header.StatusCode == statusCodeCreated) { // probably a command acknowledgement
- + if (jsonData.Header.StatusCode == statusCodeNoContent &&
- + jsonData.Header.Url == communiqueBridgeButtonGroupsRequestUrl) {
- + // no buttons configured with bridge, close the loop
- + this._logger.info('Lutron Bridge %s button groups request: nothing received', this.bridgeID);
- + this._bridgeAnnounceAllDeviceInfoIsAvailable();
- + return;
- + }
- this._logger.debug(msgStringData);
- this._expectResponse(-1);
- return;
- @@ -1065,7 +1072,7 @@ Bridge.prototype._telnetHandler = function(telnetInSessionCallback) {
- }
- // listen for a release event on this button; note that an event is created per-button
- picoEvents.on(myPicoID, function(picoNextID, picoButtonNextOp, forcedrelease) {
- - if (picoButtonNextOp == BUTTON_OP_RELEASE) { // released
- + if (picoButtonNextOp == BUTTON_OP_RELEASE) { // released
- var nextPicoActive = picoActive[picoNextID];
- nextPicoActive.timerQuash();
- var elapsed = nextPicoActive.elapsed();
- @@ -1741,3 +1748,11 @@ Bridge.prototype.buttonRemoteSetMode = function(deviceSN, picoModeMap, picoPushT
- if (typeof cb === 'function')
- cb(error);
- }
- +Bridge.prototype._bridgeAnnounceAllDeviceInfoIsAvailable = function() {
- + // we've got all the device info available; tell the listener(s)
- + this._bridgeEvents.emit(BE_GOTBUTTONGROUPS, this.bridgeIX);
- + this._bridgeEvents.emit(BE_GOTDEVICES, this.bridgeIX, this._updatedDevices);
- +
- + if (this._dReqDeviceListCallback.length)
- + this._dReqDeviceListCallback.shift()(this.bridgeIX);
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement