homebridge-syntex-dynamic-platform
Advanced tools
Comparing version 1.0.8-b4 to 1.0.8-b40
43
main.js
@@ -1,2 +0,2 @@ | ||
const axios = require('axios'), fs = require('fs'), path = require('path'); | ||
const fs = require('fs'), path = require('path'); | ||
@@ -25,3 +25,3 @@ const ContextManager = require('./src/context'); | ||
let logger = require('syntex-logger'), AutomationSystem = require('syntex-automation'), FileSystem = require('syntex-filesystem'), WebServer = require('syntex-webserver'), EventManager = require('./src/event-manager'), TypeManager = require('./src/type-manager'); | ||
let logger = require('syntex-logger'), AutomationSystem = require('syntex-automation'), Basic = require('syntex-basic'), FileManager = require('syntex-filesystem'), WebServer = require('syntex-webserver'), TypeManager = require('./src/type-manager'); | ||
@@ -41,4 +41,2 @@ let DynamicPlatform = class SynTexDynamicPlatform | ||
this.options = {}; | ||
this.api = api; | ||
@@ -53,12 +51,7 @@ this.config = config; | ||
if(config['options'] != null) | ||
{ | ||
this.options = config['options']; | ||
} | ||
this.options = config['options'] || {}; | ||
this.port = this.options['port']; | ||
this.debug = this.options['debug'] || false; | ||
this.language = this.options['language'] || 'en'; | ||
this.logger = new logger(this); | ||
this.logger = new logger(this, { language : this.options['language'] || 'en', levels : this.config['log'] }); | ||
@@ -80,7 +73,10 @@ if(config['baseDirectory'] != null) | ||
} | ||
else | ||
{ | ||
this.logger.log('error', 'bridge', 'Bridge', '%no_base_path%!'); | ||
} | ||
this.files = new FileSystem(this, { initDirectories : ['activity', 'automation', 'log'] }); | ||
this.files = new FileManager(this, { initDirectories : ['activity', 'automation', 'log'] }); | ||
this.TypeManager = new TypeManager(this.logger); | ||
this.EventManager = new EventManager(this); | ||
this.ContextManager = new ContextManager(this); | ||
@@ -95,2 +91,7 @@ | ||
this.Basic = new Basic({ ...this, loggerSpecial : this.logger }); | ||
this.EventManager = this.Basic.getEventManager(); | ||
this.RequestManager = this.Basic.getRequestManager(); | ||
this.AutomationSystem = new AutomationSystem(this); | ||
@@ -472,3 +473,3 @@ | ||
{ | ||
var url = 'http://syntex.sytes.net:8800/init-bridge?id=' + bridgeID + '&plugin=' + this.pluginName + '&version=' + this.pluginVersion + '&name=' + this.bridgeName; | ||
var url = 'http://syntex-cloud.com:8888/init-bridge?id=' + bridgeID + '&plugin=' + this.pluginName + '&version=' + this.pluginVersion + '&name=' + this.bridgeName; | ||
@@ -480,9 +481,9 @@ if(initBridge) | ||
axios.get(url).then((data) => { | ||
this.RequestManager.fetch(url).then((response) => { | ||
if(data != null && data.data != null) | ||
if(response.data != null) | ||
{ | ||
if(data.data != bridgeID) | ||
if(response.data != bridgeID) | ||
{ | ||
setTimeout(() => this.setBridgeID(data.data), 10000); | ||
setTimeout(() => this.setBridgeID(response.data), 10000); | ||
} | ||
@@ -494,8 +495,2 @@ } | ||
} | ||
}).catch((e) => { | ||
this.logger.err(e); | ||
setTimeout(() => this.connectBridge(bridgeID, initBridge), 30000); | ||
}); | ||
@@ -502,0 +497,0 @@ } |
{ | ||
"name": "homebridge-syntex-dynamic-platform", | ||
"version": "1.0.8-b4", | ||
"version": "1.0.8-b40", | ||
"description": "A Dynamic Platform Accessory", | ||
@@ -12,7 +12,7 @@ "main": "main.js", | ||
"dependencies": { | ||
"axios": "^0.21.1", | ||
"syntex-automation": "1.2.0", | ||
"syntex-filesystem": "1.0.2", | ||
"syntex-logger": "1.0.8", | ||
"syntex-webserver": "1.1.0" | ||
"syntex-automation": "1.2.1-b14", | ||
"syntex-basic": "1.0.0-b18", | ||
"syntex-filesystem": "1.0.3-b9", | ||
"syntex-logger": "1.0.9-b2", | ||
"syntex-webserver": "1.1.1-b14" | ||
}, | ||
@@ -43,4 +43,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "^8.7.0" | ||
"eslint": "^8.7.0", | ||
"eslint-plugin-react": "^7.31.11" | ||
} | ||
} |
@@ -16,2 +16,11 @@ const DimmedBulbService = require('./dimmedBulb'); | ||
this.saturation = super.getValue('saturation'); | ||
this.tempState = { | ||
value : this.value, | ||
hue : this.hue, | ||
saturation : this.saturation, | ||
brightness : this.brightness | ||
}; | ||
this.running = false; | ||
@@ -77,2 +86,72 @@ homebridgeAccessory.getServiceById(this.Service.Lightbulb, serviceConfig.subtype).getCharacteristic(this.Characteristic.Hue).on('get', this.getHue.bind(this)).on('set', this.setHue.bind(this)); | ||
} | ||
setToCurrentColor(state, powerCallback, colorCallback, unchangedCallback) | ||
{ | ||
if(state.value != null && (!super.hasState('value') || this.tempState.value != state.value)) | ||
{ | ||
this.tempState.value = state.value; | ||
this.changedPower = true; | ||
} | ||
if(state.hue != null && (!super.hasState('hue') || this.tempState.hue != state.hue)) | ||
{ | ||
this.tempState.hue = state.hue; | ||
this.changedColor = true; | ||
} | ||
if(state.saturation != null && (!super.hasState('saturation') || this.tempState.saturation != state.saturation)) | ||
{ | ||
this.tempState.saturation = state.saturation; | ||
this.changedColor = true; | ||
} | ||
if(state.brightness != null && (!super.hasState('brightness') || this.tempState.brightness != state.brightness)) | ||
{ | ||
this.tempState.brightness = state.brightness; | ||
this.changedColor = true; | ||
} | ||
if(!this.running) | ||
{ | ||
this.running = true; | ||
setTimeout(() => { | ||
if(this.changedPower) | ||
{ | ||
powerCallback(() => { | ||
this.changedPower = false; | ||
this.running = false; | ||
}); | ||
} | ||
else if(this.changedColor) | ||
{ | ||
colorCallback(() => { | ||
this.changedColor = false; | ||
this.running = false; | ||
}); | ||
} | ||
else | ||
{ | ||
unchangedCallback(() => { | ||
this.running = false; | ||
}); | ||
} | ||
}, 10); | ||
} | ||
else | ||
{ | ||
unchangedCallback(() => {}); | ||
} | ||
} | ||
} |
@@ -16,2 +16,9 @@ const LightBulbService = require('./lightBulb'); | ||
this.tempState = { | ||
value : this.value, | ||
brightness : this.brightness | ||
}; | ||
this.running = false; | ||
homebridgeAccessory.getServiceById(this.Service.Lightbulb, serviceConfig.subtype).getCharacteristic(this.Characteristic.Brightness).on('get', this.getBrightness.bind(this)).on('set', this.setBrightness.bind(this)); | ||
@@ -60,2 +67,58 @@ | ||
} | ||
setToCurrentBrightness(state, powerCallback, brightnessCallback, unchangedCallback) | ||
{ | ||
if(state.value != null && (!super.hasState('value') || this.tempState.value != state.value)) | ||
{ | ||
this.tempState.value = state.value; | ||
this.changedPower = true; | ||
} | ||
if(state.brightness != null && (!super.hasState('brightness') || this.tempState.brightness != state.brightness)) | ||
{ | ||
this.tempState.brightness = state.brightness; | ||
this.changedBrightness = true; | ||
} | ||
if(!this.running) | ||
{ | ||
this.running = true; | ||
setTimeout(() => { | ||
if(this.changedPower) | ||
{ | ||
powerCallback(() => { | ||
this.changedPower = false; | ||
this.running = false; | ||
}); | ||
} | ||
else if(this.changedBrightness) | ||
{ | ||
brightnessCallback(() => { | ||
this.changedBrightness = false; | ||
this.running = false; | ||
}); | ||
} | ||
else | ||
{ | ||
unchangedCallback(() => { | ||
this.running = false; | ||
}); | ||
} | ||
}, 10); | ||
} | ||
else | ||
{ | ||
unchangedCallback(() => {}); | ||
} | ||
} | ||
} |
@@ -40,6 +40,6 @@ const fs = require('fs'), path = require('path'); | ||
{ | ||
this.context[entry.id][entry.letters] = { time : entry.time * 60000, state : entry.state }; | ||
this.context[entry.id][entry.letters] = { time : entry.time * 60000, state : { ...entry.state } }; | ||
} | ||
this.cache[entry.id][entry.letters].history.push({ time : entry.time * 60000, state : entry.state }); | ||
this.cache[entry.id][entry.letters].history.push({ time : entry.time * 60000, state : { ...entry.state } }); | ||
} | ||
@@ -131,4 +131,2 @@ else if(entry.automation != null) | ||
{ | ||
state = { ...state }; | ||
this._prepareStructure(id, letters); | ||
@@ -153,3 +151,3 @@ | ||
{ | ||
this.cache[id][letters].cycle.push(this.context[id][letters].state); | ||
this.cache[id][letters].cycle.push({ ...this.context[id][letters].state }); | ||
} | ||
@@ -291,3 +289,3 @@ } | ||
if(new Date().getTime() - time < 86400000) | ||
if(new Date().getTime() - time < 86400000 * 2) | ||
{ | ||
@@ -294,0 +292,0 @@ newData += JSON.stringify(entry) + '\n'; |
@@ -139,7 +139,7 @@ module.exports = class TypeManager | ||
letterToType(letter) | ||
letterToType(letters) | ||
{ | ||
if(typeof letter == 'string' && this.data[letter.toUpperCase()] != null) | ||
if(typeof letters == 'string' && this.data[letters[0].toUpperCase()] != null) | ||
{ | ||
return this.data[letter.toUpperCase()].type; | ||
return this.data[letters[0].toUpperCase()].type; | ||
} | ||
@@ -146,0 +146,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
76308
2085
2
26
+ Addedsyntex-basic@1.0.0-b18
+ Addedcharenc@0.0.2(transitive)
+ Addedcrypt@0.0.2(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)
- Removedsyntex-automation@1.2.0(transitive)
- Removedsyntex-filesystem@1.0.2(transitive)
- Removedsyntex-logger@1.0.8(transitive)
- Removedsyntex-webserver@1.1.0(transitive)
Updatedsyntex-automation@1.2.1-b14
Updatedsyntex-filesystem@1.0.3-b9
Updatedsyntex-logger@1.0.9-b2
Updatedsyntex-webserver@1.1.1-b14