homebridge-syntex-webhooks
Advanced tools
Comparing version 2.3.8-b3 to 2.3.8-b30
{ | ||
"name": "homebridge-syntex-webhooks", | ||
"version": "2.3.8-b3", | ||
"version": "2.3.8-b30", | ||
"description": "A webhook plugin for HTTP devices", | ||
@@ -14,5 +14,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"color-convert": "^1.5.0", | ||
"homebridge-syntex-dynamic-platform": "1.0.8-b9", | ||
"homebridge-syntex-dynamic-platform": "1.0.8-b40", | ||
"json-fs-store": "^1.0.1" | ||
@@ -43,4 +42,5 @@ }, | ||
"devDependencies": { | ||
"eslint": "^8.7.0" | ||
"eslint": "^8.7.0", | ||
"eslint-plugin-react": "^7.31.11" | ||
} | ||
} |
@@ -17,25 +17,6 @@ const { ColoredBulbService } = require('homebridge-syntex-dynamic-platform'); | ||
if(state.value != null) | ||
{ | ||
super.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
} | ||
if(state.hue != null) | ||
{ | ||
super.setHue(state.hue, | ||
() => this.service.getCharacteristic(this.Characteristic.Hue).updateValue(state.hue)); | ||
} | ||
if(state.saturation != null) | ||
{ | ||
super.setSaturation(state.saturation, | ||
() => this.service.getCharacteristic(this.Characteristic.Saturation).updateValue(state.saturation)); | ||
} | ||
if(state.brightness != null) | ||
{ | ||
super.setBrightness(state.brightness, | ||
() => this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(state.brightness)); | ||
} | ||
this.service.getCharacteristic(this.Characteristic.On).updateValue(this.value); | ||
this.service.getCharacteristic(this.Characteristic.Hue).updateValue(this.hue); | ||
this.service.getCharacteristic(this.Characteristic.Saturation).updateValue(this.saturation); | ||
this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(this.brightness); | ||
}); | ||
@@ -52,3 +33,3 @@ }; | ||
{ | ||
this.setToCurrentColor({ value }, () => super.setState(value, () => callback())); | ||
this.setToCurrentColor({ value }, () => callback()); | ||
} | ||
@@ -63,3 +44,3 @@ | ||
{ | ||
this.setToCurrentColor({ hue }, () => super.setHue(hue, () => callback())); | ||
this.setToCurrentColor({ hue }, () => callback()); | ||
} | ||
@@ -74,3 +55,3 @@ | ||
{ | ||
this.setToCurrentColor({ saturation }, () => super.setSaturation(saturation, () => callback())); | ||
this.setToCurrentColor({ saturation }, () => callback()); | ||
} | ||
@@ -85,3 +66,3 @@ | ||
{ | ||
this.setToCurrentColor({ brightness }, () => super.setBrightness(brightness, () => callback())); | ||
this.setToCurrentColor({ brightness }, () => callback()); | ||
} | ||
@@ -93,9 +74,19 @@ | ||
this.DeviceManager.fetchRequests(this, { value : this.value, hue : this.hue, saturation : this.saturation, brightness : this.brightness }).then((success) => { | ||
this.DeviceManager.fetchRequests(this, { value : this.tempState.value, hue : this.tempState.hue, saturation : this.tempState.saturation, brightness : this.tempState.brightness }).then((success) => { | ||
if(success) | ||
{ | ||
this.value = this.tempState.value; | ||
this.hue = this.tempState.hue; | ||
this.saturation = this.tempState.saturation; | ||
this.brightness = this.tempState.brightness; | ||
super.setState(this.value, () => {}); | ||
super.setHue(this.hue, () => {}); | ||
super.setSaturation(this.saturation, () => {}); | ||
super.setBrightness(this.brightness, () => {}); | ||
this.logger.log('update', this.id, this.letters, '%update_state[0]% [' + this.name + '] %update_state[1]% [value: ' + this.value + ', hue: ' + this.hue + ', saturation: ' + this.saturation + ', brightness: ' + this.brightness + '] ( ' + this.id + ' )'); | ||
} | ||
if(callback != null) | ||
@@ -105,4 +96,6 @@ { | ||
} | ||
resolve(); | ||
resolve(); | ||
this.AutomationSystem.LogikEngine.runAutomation(this, { value : this.value, hue : this.hue, saturation : this.saturation, brightness : this.brightness }); | ||
}); | ||
@@ -109,0 +102,0 @@ }; |
@@ -15,15 +15,4 @@ const { DimmedBulbService } = require('homebridge-syntex-dynamic-platform'); | ||
if(state.value != null) | ||
{ | ||
super.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
} | ||
if(state.brightness != null) | ||
{ | ||
super.setBrightness(state.brightness, | ||
() => this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(state.brightness)); | ||
} | ||
this.AutomationSystem.LogikEngine.runAutomation(this, state); | ||
this.service.getCharacteristic(this.Characteristic.On).updateValue(this.value); | ||
this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(this.brightness); | ||
}); | ||
@@ -40,8 +29,3 @@ }; | ||
{ | ||
this.setToCurrentBrightness({ value }, () => { | ||
super.setState(value, () => callback()); | ||
this.AutomationSystem.LogikEngine.runAutomation(this, { value, brightness : this.brightness }); | ||
}); | ||
this.setToCurrentBrightness({ value }, () => callback()); | ||
} | ||
@@ -56,8 +40,3 @@ | ||
{ | ||
this.setToCurrentBrightness({ brightness }, () => { | ||
super.setBrightness(brightness, () => callback()); | ||
this.AutomationSystem.LogikEngine.runAutomation(this, { value : this.value, brightness }); | ||
}); | ||
this.setToCurrentBrightness({ brightness }, () => callback()); | ||
} | ||
@@ -69,6 +48,12 @@ | ||
this.DeviceManager.fetchRequests(this, { value : this.value, brightness : this.brightness }).then((success) => { | ||
this.DeviceManager.fetchRequests(this, { value : this.tempState.value, brightness : this.tempState.brightness }).then((success) => { | ||
if(success) | ||
{ | ||
this.value = this.tempState.value; | ||
this.brightness = this.tempState.brightness; | ||
super.setState(this.value, () => {}); | ||
super.setBrightness(this.brightness, () => {}); | ||
this.logger.log('update', this.id, this.letters, '%update_state[0]% [' + this.name + '] %update_state[1]% [value: ' + this.value + ', brightness: ' + this.brightness + '] ( ' + this.id + ' )'); | ||
@@ -83,2 +68,4 @@ } | ||
resolve(); | ||
this.AutomationSystem.LogikEngine.runAutomation(this, { value : this.value, brightness : this.brightness }); | ||
}); | ||
@@ -85,0 +72,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
const axios = require('axios'), convert = require('color-convert'); | ||
const convert = require('color-convert'); | ||
@@ -10,4 +10,6 @@ module.exports = class DeviceManager | ||
this.logger = platform.logger; | ||
this.typeManager = platform.TypeManager; | ||
this.RequestManager = platform.RequestManager; | ||
this.TypeManager = platform.TypeManager; | ||
this.accessories = platform.accessories; | ||
@@ -43,20 +45,23 @@ | ||
axios.get(url, { timeout : 25000 }).then(() => { | ||
this.RequestManager.fetch(url, { timeout : 25000 }).then((response) => { | ||
this.connections[url] = 0; | ||
if(accessory.setConnectionState != null) | ||
if(response.data != null) | ||
{ | ||
accessory.setConnectionState(true, null, true); | ||
} | ||
this.connections[url] = 0; | ||
}).catch(() => { | ||
if(this.connections[url] < 2) | ||
{ | ||
this.connections[url]++; | ||
if(accessory.setConnectionState != null) | ||
{ | ||
accessory.setConnectionState(true, null, true); | ||
} | ||
} | ||
else if(accessory.setConnectionState != null) | ||
else | ||
{ | ||
accessory.setConnectionState(false, null, true); | ||
if(this.connections[url] < 2) | ||
{ | ||
this.connections[url]++; | ||
} | ||
else if(accessory.setConnectionState != null) | ||
{ | ||
accessory.setConnectionState(false, null, true); | ||
} | ||
} | ||
@@ -131,14 +136,11 @@ }); | ||
{ | ||
axios.get(urlToCall, theRequest).then(function(response) { | ||
this.RequestManager.fetch(urlToCall, theRequest).then(function(response) { | ||
success++; | ||
if(response.data != null) | ||
{ | ||
success++; | ||
} | ||
this.logger.log(response.data != null ? 'success' : 'error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (response.status || -1)+ '] %request_result[2]%: [' + (response.data || '') + ']', response.error || ''); | ||
this.logger.log('success', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + response.status + '] %request_result[2]%: [' + (response.data || '') + ']'); | ||
}.bind({ url : urlToCall, logger : this.logger })).catch(function(err) { | ||
this.logger.log('error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (err.response != null ? err.response.status : -1)+ '] %request_result[2]%: [' + (err.response != null ? err.response.data : '') + ']', err.stack); | ||
}.bind({ url : urlToCall, logger : this.logger })).then(function() { | ||
finished++; | ||
@@ -153,3 +155,3 @@ | ||
if(success == 0 && this.typeManager.letterToType(service.letters) == 'relais') | ||
if(success == 0 && this.TypeManager.letterToType(service.letters) == 'relais') | ||
{ | ||
@@ -163,4 +165,4 @@ resolve(false); | ||
} | ||
}.bind({ url : urlToCall, typeManager : this.typeManager })); | ||
}.bind({ url : urlToCall, logger : this.logger, TypeManager : this.TypeManager })); | ||
} | ||
@@ -176,12 +178,6 @@ else if(service.options.requests[i].trigger.toLowerCase() == 'color') | ||
axios.get(urlToCall + colors[0] + ',' + colors[1] + ',' + (state.value ? colors[2] : 0), theRequest).then(function(response) { | ||
this.RequestManager.fetch(urlToCall + colors[0] + ',' + colors[1] + ',' + (state.value ? colors[2] : 0), theRequest).then(function(response) { | ||
this.logger.log('success', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + response.status + '] %request_result[2]%: [' + (response.data || '') + '] '); | ||
}.bind({ url : urlToCall + colors[0] + ',' + colors[1] + ',' + (state.value ? colors[2] : 0), logger : this.logger })).catch(function(err) { | ||
this.logger.log(response.data != null ? 'success' : 'error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (response.status || -1) + '] %request_result[2]%: [' + (response.data || '') + ']', response.error || ''); | ||
this.logger.log('error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (err.response != null ? err.response.status : -1) + '] %request_result[2]%: [' + (err.response != null ? err.response.data : '') + ']', err.stack); | ||
}.bind({ url : urlToCall + colors[0] + ',' + colors[1] + ',' + (state.value ? colors[2] : 0), logger : this.logger })).then(() => { | ||
finished++; | ||
@@ -198,16 +194,11 @@ | ||
} | ||
}); | ||
}.bind({ url : urlToCall + colors[0] + ',' + colors[1] + ',' + (state.value ? colors[2] : 0), logger : this.logger })); | ||
} | ||
else if(service.options.requests[i].trigger.toLowerCase() == 'dimmer') | ||
{ | ||
axios.get(urlToCall + state.brightness, theRequest).then(function(response) { | ||
this.RequestManager.fetch(urlToCall + state.brightness, theRequest).then(function(response) { | ||
this.logger.log('success', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + response.status + '] %request_result[2]%: [' + (response.data || '') + '] '); | ||
}.bind({ url : urlToCall + state.brightness, logger : this.logger })).catch(function(err) { | ||
this.logger.log(response.data != null ? 'success' : 'error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (response.status || -1) + '] %request_result[2]%: [' + (response.data || '') + ']', response.error || ''); | ||
this.logger.log('error', service.id, service.letters, '[' + service.name + '] %request_result[0]% [' + this.url + '] %request_result[1]% [' + (err.response != null ? err.response.status : -1) + '] %request_result[2]%: [' + (err.response != null ? err.response.data : '') + ']', err.stack); | ||
}.bind({ url : urlToCall + state.brightness, logger : this.logger })).then(() => { | ||
finished++; | ||
@@ -224,3 +215,4 @@ | ||
} | ||
}); | ||
}.bind({ url : urlToCall + state.brightness, logger : this.logger })); | ||
} | ||
@@ -227,0 +219,0 @@ } |
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
3
54688
2
1033
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(transitive)
+ Addedhomebridge-syntex-dynamic-platform@1.0.8-b40(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedmd5@2.3.0(transitive)
+ Addedsyntex-automation@1.2.1-b14(transitive)
+ Addedsyntex-basic@1.0.0-b18(transitive)
+ Addedsyntex-filesystem@1.0.3-b9(transitive)
+ Addedsyntex-logger@1.0.9-b2(transitive)
+ Addedsyntex-webserver@1.1.1-b14(transitive)
- Removedaxios@^0.21.1
- Removedaxios@0.21.4(transitive)
- Removedfollow-redirects@1.15.9(transitive)
- Removedhomebridge-syntex-dynamic-platform@1.0.8-b9(transitive)
- Removedsyntex-automation@1.2.0(transitive)
- Removedsyntex-filesystem@1.0.2(transitive)
- Removedsyntex-logger@1.0.8(transitive)
- Removedsyntex-webserver@1.1.0(transitive)