syntex-automation
Advanced tools
Comparing version 1.0.3-b8 to 1.0.3-b9
{ | ||
"name": "syntex-automation", | ||
"version": "1.0.3-b8", | ||
"version": "1.0.3-b9", | ||
"description": "An automation system for your smart home", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
# SynTex Automation System | ||
An automation system for your smart home |
@@ -33,10 +33,10 @@ var presets = {}; | ||
B : { type : 'motion', format : 'boolean' }, | ||
C : { type : 'temperature', format : 'number' }, | ||
D : { type : 'humidity', format : 'number' }, | ||
C : { type : 'temperature', format : 'number', min : -270, max : 100 }, | ||
D : { type : 'humidity', format : 'number', min : 0, max : 100 }, | ||
E : { type : 'rain', format : 'boolean' }, | ||
F : { type : 'light', format : 'number' }, | ||
F : { type : 'light', format : 'number', min : 0.0001, max : 100000 }, | ||
0 : { type : 'occupancy', format : 'boolean' }, | ||
1 : { type : 'smoke', format : 'boolean' }, | ||
2 : { type : 'airquality', format : 'number' }, | ||
3 : { type : 'rgb', format : { value : 'boolean', brightness : 'number', saturation : 'number', hue : 'number' } }, | ||
2 : { type : 'airquality', format : 'number', min : 0, max : 5 }, | ||
3 : { type : 'rgb', format : { value : 'boolean', brightness : 'number', saturation : 'number', hue : 'number' }, min : { brightness : 0, saturation : 0, hue : 0 }, max : { brightness : 100, saturation : 100, hue : 360 } }, | ||
4 : { type : 'switch', format : 'boolean' }, | ||
@@ -47,3 +47,3 @@ 5 : { type : 'relais', format : 'boolean' }, | ||
8 : { type : 'led', format : 'boolean' }, | ||
9 : { type : 'dimmer', format : { value : 'boolean', brightness : 'number' } } | ||
9 : { type : 'dimmer', format : { value : 'boolean', brightness : 'number' }, min : { brightness : 0 }, max : { brightness : 100 } } | ||
}; | ||
@@ -53,27 +53,49 @@ | ||
{ | ||
if(state[i] != null) | ||
try | ||
{ | ||
try | ||
state[i] = JSON.parse(state[i]); | ||
} | ||
catch(e) | ||
{ | ||
this.logger.log('warn', id, letters, '%conversion_error_parse[0]%: [' + state[i] + '] %conversion_error_parse[1]%! ( ' + id + ' )'); | ||
return null; | ||
} | ||
var format = data[letters[0].toUpperCase()].format; | ||
if(format instanceof Object) | ||
{ | ||
format = format[i]; | ||
} | ||
if(typeof state[i] != format) | ||
{ | ||
this.logger.log('warn', id, letters, '%conversion_error_format[0]%: [' + state[i] + '] %conversion_error_format[1]% ' + (format == 'boolean' ? '%conversion_error_format[2]%' : format == 'number' ? '%conversion_error_format[3]%' : '%conversion_error_format[4]%') + ' %conversion_error_format[5]%! ( ' + id + ' )'); | ||
return null; | ||
} | ||
if(format == 'number') | ||
{ | ||
var min = data[letters[0].toUpperCase()].min, max = data[letters[0].toUpperCase()].max; | ||
if(min instanceof Object) | ||
{ | ||
state[i] = JSON.parse(state[i]); | ||
min = min[i]; | ||
} | ||
catch(e) | ||
if(max instanceof Object) | ||
{ | ||
this.logger.log('warn', id, letters, '%conversion_error_parse[0]%: [' + state[i] + '] %conversion_error_parse[1]%! ( ' + id + ' )'); | ||
return null; | ||
max = max[i]; | ||
} | ||
var format = data[letters[0].toUpperCase()].format; | ||
if(format instanceof Object) | ||
if(min != null && state[i] < min) | ||
{ | ||
format = format[i]; | ||
state[i] = min; | ||
} | ||
if(typeof state[i] != format) | ||
if(max != null && state[i] > max) | ||
{ | ||
this.logger.log('warn', id, letters, '%conversion_error_format[0]%: [' + state[i] + '] %conversion_error_format[1]% ' + (format == 'boolean' ? '%conversion_error_format[2]%' : format == 'number' ? '%conversion_error_format[3]%' : '%conversion_error_format[4]%') + ' %conversion_error_format[5]%! ( ' + id + ' )'); | ||
return null; | ||
state[i] = max; | ||
} | ||
@@ -80,0 +102,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
22438
560