homebridge-syntex-dynamic-platform
Advanced tools
Comparing version 1.0.8-b54 to 1.0.8-b55
27
main.js
@@ -155,19 +155,10 @@ const fs = require('fs'), path = require('path'); | ||
{ | ||
if(urlParams.value != null) | ||
{ | ||
let state = { value : urlParams.value }; | ||
var characteristics = this.TypeManager.getCharacteristics({ letters : service.letters }), state = {}; | ||
if(urlParams.hue != null) | ||
for(const type in characteristics) | ||
{ | ||
state.hue = urlParams.hue; | ||
} | ||
if(urlParams.saturation != null) | ||
if(urlParams[type] != null) | ||
{ | ||
state.saturation = urlParams.saturation; | ||
state[type] = urlParams[type]; | ||
} | ||
if(urlParams.brightness != null) | ||
{ | ||
state.brightness = urlParams.brightness; | ||
} | ||
@@ -180,10 +171,8 @@ | ||
state = this.updateAccessoryService(service, state); | ||
response.end(state != null ? 'Success' : 'Error'); | ||
if(Object.keys(state).length > 0) | ||
{ | ||
response.end(this.updateAccessoryService(service, state) != null ? 'Success' : 'Error'); | ||
} | ||
else | ||
{ | ||
let state = null; | ||
if(accessory.homebridgeAccessory != null | ||
@@ -203,3 +192,3 @@ && accessory.homebridgeAccessory.context != null | ||
response.end(state != null ? JSON.stringify(state) : 'Error'); | ||
response.end(Object.keys(state).length > 0 ? JSON.stringify(state) : 'Error'); | ||
} | ||
@@ -206,0 +195,0 @@ } |
{ | ||
"name": "homebridge-syntex-dynamic-platform", | ||
"version": "1.0.8-b54", | ||
"version": "1.0.8-b55", | ||
"description": "A Dynamic Platform Accessory", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.AirQuality).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.ContactSensorState).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.CurrentRelativeHumidity).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.LeakDetected).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.CurrentAmbientLightLevel).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -24,3 +24,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
@@ -27,0 +27,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.MotionDetected).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.OccupancyDetected).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.SmokeDetected).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -19,3 +19,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
@@ -22,0 +22,0 @@ } |
@@ -20,3 +20,3 @@ const BaseService = require('../base'); | ||
{ | ||
super.setState(state.value, | ||
this.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.CurrentTemperature).updateValue(state.value)); | ||
@@ -23,0 +23,0 @@ } |
@@ -9,2 +9,4 @@ const BaseService = require('../base'); | ||
this.running = false; | ||
this.value = super.getValue('value'); | ||
@@ -15,2 +17,9 @@ this.target = super.getValue('target', false); | ||
this.tempState = { | ||
value : this.value, | ||
target : this.target, | ||
state : this.state, | ||
mode : this.mode | ||
}; | ||
this.service.getCharacteristic(this.Characteristic.CurrentTemperature).on('get', this.getState.bind(this)); | ||
@@ -156,25 +165,72 @@ this.service.getCharacteristic(this.Characteristic.TargetTemperature).on('get', this.getTargetTemperature.bind(this)).on('set', this.setTargetTemperature.bind(this)); | ||
{ | ||
if(state.target != null && (!super.hasState('target') || this.target != state.target)) | ||
if(state.value != null && (!super.hasState('value') || this.tempState.value != state.value)) | ||
{ | ||
this.tempState.value = state.value; | ||
this.changedValue = true; | ||
} | ||
if(state.target != null && (!super.hasState('target') || this.tempState.target != state.target)) | ||
{ | ||
this.tempState.target = state.target; | ||
this.changedTarget = true; | ||
} | ||
if(state.mode != null && (!super.hasState('mode') || this.mode != state.mode)) | ||
if(state.state != null && (!super.hasState('state') || this.tempState.state != state.state)) | ||
{ | ||
this.changedMode = true; | ||
this.tempState.state = state.state; | ||
this.changedState = true; | ||
} | ||
if(this.changedTarget) | ||
if(state.mode != null && (!super.hasState('mode') || this.tempState.mode != state.mode)) | ||
{ | ||
targetCallback(() => { | ||
this.tempState.mode = state.mode; | ||
this.changedTarget = false; | ||
}); | ||
this.changedMode = true; | ||
} | ||
else if(this.changedMode) | ||
if(!this.running) | ||
{ | ||
modeCallback(() => { | ||
this.running = true; | ||
this.changedMode = false; | ||
}); | ||
setTimeout(() => { | ||
if(this.changedTarget) | ||
{ | ||
targetCallback(() => { | ||
this.changedTarget = false; | ||
this.changedValue = false; | ||
this.changedState = false; | ||
this.running = false; | ||
}); | ||
} | ||
else if(this.changedMode) | ||
{ | ||
modeCallback(() => { | ||
this.changedMode = false; | ||
this.changedValue = false; | ||
this.changedState = false; | ||
this.running = false; | ||
}); | ||
} | ||
else | ||
{ | ||
unchangedCallback(() => { | ||
this.changedValue = false; | ||
this.changedState = false; | ||
this.running = false; | ||
}); | ||
} | ||
}, 10); | ||
} | ||
@@ -181,0 +237,0 @@ else |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81770
2357