homebridge-syntex-magichome
Advanced tools
Comparing version 1.2.5-b1 to 1.2.5-b2
{ | ||
"name": "homebridge-syntex-magichome", | ||
"version": "1.2.5-b1", | ||
"version": "1.2.5-b2", | ||
"description": "Homebridge Plugin for MagicHome LED Strips with preset scenes", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"color-convert": "^1.5.0", | ||
"homebridge-syntex-dynamic-platform": "1.0.8-b43" | ||
"homebridge-syntex-dynamic-platform": "1.0.8-b49" | ||
}, | ||
@@ -18,0 +18,0 @@ "keywords": [ |
@@ -64,6 +64,6 @@ const { ColoredBulbService } = require('homebridge-syntex-dynamic-platform'); | ||
{ | ||
this.value = this.tempState.value = state.value; | ||
this.tempState.value = state.value; | ||
super.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value), false); | ||
@@ -75,6 +75,6 @@ changed = true; | ||
{ | ||
this.hue = this.tempState.hue = state.hue; | ||
this.tempState.hue = state.hue; | ||
super.setHue(state.hue, | ||
() => this.service.getCharacteristic(this.Characteristic.Hue).updateValue(state.hue)); | ||
() => this.service.getCharacteristic(this.Characteristic.Hue).updateValue(state.hue), false); | ||
@@ -86,6 +86,6 @@ changed = true; | ||
{ | ||
this.saturation = this.tempState.saturation = state.saturation; | ||
this.tempState.saturation = state.saturation; | ||
super.setSaturation(state.saturation, | ||
() => this.service.getCharacteristic(this.Characteristic.Saturation).updateValue(state.saturation)); | ||
() => this.service.getCharacteristic(this.Characteristic.Saturation).updateValue(state.saturation), false); | ||
@@ -97,6 +97,6 @@ changed = true; | ||
{ | ||
this.brightness = this.tempState.brightness = state.brightness; | ||
this.tempState.brightness = state.brightness; | ||
super.setBrightness(state.brightness, | ||
() => this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(state.brightness)); | ||
() => this.service.getCharacteristic(this.Characteristic.Brightness).updateValue(state.brightness), false); | ||
@@ -108,3 +108,3 @@ changed = true; | ||
{ | ||
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 + ' )'); | ||
this.logger.log('update', this.id, this.letters, '%update_state[0]% [' + this.name + '] %update_state[1]% [' + this.getStateText(this.letters) + '] ( ' + this.id + ' )'); | ||
} | ||
@@ -116,3 +116,3 @@ else | ||
this.AutomationSystem.LogikEngine.runAutomation(this, { value : this.value, hue : this.hue, saturation : this.saturation, brightness : this.brightness }); | ||
this.AutomationSystem.LogikEngine.runAutomation(this, state); | ||
} | ||
@@ -123,28 +123,19 @@ } | ||
{ | ||
super.getState((value) => { | ||
super.getState(() => { | ||
if(super.hasState('value')) | ||
if(!super.hasState('value')) | ||
{ | ||
this.value = value; | ||
this.DeviceManager.getState(this).then((state) => { | ||
this.logger.log('read', this.id, this.letters, '%read_state[0]% [' + this.name + '] %read_state[1]% [value: ' + value + ', hue: ' + this.hue + ', saturation: ' + this.saturation + ', brightness: ' + this.brightness + '] ( ' + this.id + ' )'); | ||
this.updateState(state); | ||
callback(null, value); | ||
callback(null, this.value); | ||
}); | ||
} | ||
else | ||
{ | ||
this.DeviceManager.getState(this, (state) => { | ||
if(state.value != null && !isNaN(state.value)) | ||
{ | ||
this.value = state.value; | ||
super.setState(state.value, | ||
() => this.logger.log('read', this.id, this.letters, '%read_state[0]% [' + this.name + '] %read_state[1]% [value: ' + state.value + ', hue: ' + this.hue + ', saturation: ' + this.saturation + ', brightness: ' + this.brightness + '] ( ' + this.id + ' )')); | ||
callback(null, this.value); | ||
} | ||
callback(null, this.value); | ||
}); | ||
} | ||
}); | ||
}, super.hasState('value')); | ||
} | ||
@@ -169,25 +160,19 @@ | ||
{ | ||
super.getHue((hue) => { | ||
super.getHue(() => { | ||
if(super.hasState('hue')) | ||
if(!super.hasState('hue')) | ||
{ | ||
this.hue = hue; | ||
this.DeviceManager.getState(this).then((state) => { | ||
callback(null, hue); | ||
this.updateState(state); | ||
callback(null, this.hue); | ||
}); | ||
} | ||
else | ||
{ | ||
this.DeviceManager.getState(this, (state) => { | ||
callback(null, this.hue); | ||
} | ||
if(state.hue != null && !isNaN(state.hue)) | ||
{ | ||
this.hue = state.hue; | ||
super.setHue(state.hue, () => {}); | ||
} | ||
callback(null, this.hue); | ||
}); | ||
} | ||
}); | ||
}, super.hasState('hue')); | ||
} | ||
@@ -212,25 +197,19 @@ | ||
{ | ||
super.getSaturation((saturation) => { | ||
super.getSaturation(() => { | ||
if(super.hasState('saturation')) | ||
if(!super.hasState('saturation')) | ||
{ | ||
this.saturation = saturation; | ||
this.DeviceManager.getState(this).then((state) => { | ||
callback(null, saturation); | ||
this.updateState(state); | ||
callback(null, this.saturation); | ||
}); | ||
} | ||
else | ||
{ | ||
this.DeviceManager.getState(this, (state) => { | ||
if(state.saturation != null && !isNaN(state.saturation)) | ||
{ | ||
this.saturation = state.saturation; | ||
super.setSaturation(state.saturation, () => {}); | ||
callback(null, this.saturation); | ||
} | ||
callback(null, this.saturation); | ||
}); | ||
} | ||
}); | ||
}, super.hasState('saturation')); | ||
} | ||
@@ -255,25 +234,19 @@ | ||
{ | ||
super.getBrightness((brightness) => { | ||
super.getBrightness(() => { | ||
if(super.hasState('brightness')) | ||
if(!super.hasState('brightness')) | ||
{ | ||
this.brightness = brightness; | ||
this.DeviceManager.getState(this).then((state) => { | ||
callback(null, brightness); | ||
this.updateState(state); | ||
callback(null, this.brightness); | ||
}); | ||
} | ||
else | ||
{ | ||
this.DeviceManager.getState(this, (state) => { | ||
callback(null, this.brightness); | ||
} | ||
if(state.brightness != null && !isNaN(state.brightness)) | ||
{ | ||
this.brightness = state.brightness; | ||
super.setBrightness(state.brightness, () => {}); | ||
} | ||
callback(null, this.brightness); | ||
}); | ||
} | ||
}); | ||
}, super.hasState('brightness')); | ||
} | ||
@@ -313,7 +286,3 @@ | ||
{ | ||
this.value = this.tempState.value; | ||
super.setState(this.value, () => {}); | ||
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 + ' )'); | ||
super.setState(this.tempState.value); | ||
} | ||
@@ -358,11 +327,7 @@ | ||
{ | ||
this.hue = hsl[0]; | ||
this.saturation = hsl[1]; | ||
this.brightness = hsl[2]; | ||
super.setHue(hsl[0], null, false); | ||
super.setSaturation(hsl[1], null, false); | ||
super.setBrightness(hsl[2], null, false); | ||
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 + ' )'); | ||
this.logger.log('update', this.id, this.letters, '%update_state[0]% [' + this.name + '] %update_state[1]% [' + this.getStateText(this.letters) + '] ( ' + this.id + ' )'); | ||
} | ||
@@ -369,0 +334,0 @@ } |
@@ -36,13 +36,2 @@ const { SwitchService } = require('homebridge-syntex-dynamic-platform'); | ||
getState(callback) | ||
{ | ||
super.getState((value) => { | ||
this.value = value; | ||
callback(null, value); | ||
}, true); | ||
} | ||
setState(value, callback) | ||
@@ -52,4 +41,2 @@ { | ||
this.value = value; | ||
Object.keys(this.ips).forEach((ip) => { | ||
@@ -127,3 +114,3 @@ | ||
{ | ||
super.setState(value, () => callback(), true); | ||
super.setState(value, () => callback()); | ||
@@ -145,6 +132,4 @@ this.EventManager.setOutputStream('resetSwitch', { sender : this }, Object.keys(this.ips)); | ||
{ | ||
this.value = state.value; | ||
super.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value), true); | ||
super.setState(state.value, | ||
() => this.service.getCharacteristic(this.Characteristic.On).updateValue(state.value)); | ||
} | ||
@@ -151,0 +136,0 @@ |
@@ -9,2 +9,4 @@ const { SwitchService } = require('homebridge-syntex-dynamic-platform'); | ||
super.setState(false, null, false); | ||
this.DeviceManager = manager.DeviceManager; | ||
@@ -26,7 +28,2 @@ this.EventManager = manager.platform.EventManager; | ||
getState(callback) | ||
{ | ||
callback(null, false); | ||
} | ||
setState(value, callback) | ||
@@ -33,0 +30,0 @@ { |
@@ -12,35 +12,38 @@ const cp = require('child_process'), path = require('path'), convert = require('color-convert'); | ||
getState(service, callback) | ||
getState(service) | ||
{ | ||
this.executeCommand(service.ip, '-i', (offline, output) => { | ||
return new Promise((callback) => { | ||
var state = {}; | ||
this.executeCommand(service.ip, '-i', (offline, output) => { | ||
if(!offline) | ||
{ | ||
var power = output.match(/\] ON /g), | ||
colors = output.match(/\(.*,.*,.*\)/g); | ||
state.value = (Array.isArray(power) && power.length > 0); | ||
if(Array.isArray(colors) && colors.length > 0) | ||
var state = {}; | ||
if(!offline) | ||
{ | ||
var converted = colors[0].slice(1).slice(0, -1).split(',').map((item) => item.trim()); | ||
converted = service.setChannels(converted); | ||
converted = convert.rgb.hsv(converted); | ||
if(converted != null) | ||
var power = output.match(/\] ON /g), | ||
colors = output.match(/\(.*,.*,.*\)/g); | ||
state.value = (Array.isArray(power) && power.length > 0); | ||
if(Array.isArray(colors) && colors.length > 0) | ||
{ | ||
state.hue = converted[0]; | ||
state.saturation = converted[1]; | ||
state.brightness = converted[2]; | ||
var converted = colors[0].slice(1).slice(0, -1).split(',').map((item) => item.trim()); | ||
converted = service.setChannels(converted); | ||
converted = convert.rgb.hsv(converted); | ||
if(converted != null) | ||
{ | ||
state.hue = converted[0]; | ||
state.saturation = converted[1]; | ||
state.brightness = converted[2]; | ||
} | ||
} | ||
} | ||
} | ||
state.connection = !offline; | ||
callback(state); | ||
state.connection = !offline; | ||
callback(state); | ||
}); | ||
}); | ||
@@ -126,19 +129,24 @@ } | ||
{ | ||
var converted = service.setChannels([states[ip].red, states[ip].green, states[ip].blue]); | ||
var state = { ...states[ip] }; | ||
converted = convert.rgb.hsv(converted); | ||
if(converted != null) | ||
if(state.red != null && state.green != null && state.blue != null) | ||
{ | ||
delete states[ip].red; | ||
delete states[ip].green; | ||
delete states[ip].blue; | ||
var converted = service.setChannels([state.red, state.green, state.blue]); | ||
states[ip].hue = converted[0]; | ||
states[ip].saturation = converted[1]; | ||
states[ip].brightness = converted[2]; | ||
converted = convert.rgb.hsv(converted); | ||
if(converted != null) | ||
{ | ||
delete state.red; | ||
delete state.green; | ||
delete state.blue; | ||
state.hue = converted[0]; | ||
state.saturation = converted[1]; | ||
state.brightness = converted[2]; | ||
} | ||
} | ||
service.setConnectionState(states[ip].connection, | ||
() => service.updateState(states[ip]), true); | ||
service.setConnectionState(state.connection, | ||
() => service.updateState(state), true); | ||
} | ||
@@ -145,0 +153,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
119834
893
+ Addedhomebridge-syntex-dynamic-platform@1.0.8-b49(transitive)
- Removedhomebridge-syntex-dynamic-platform@1.0.8-b43(transitive)