Remove #stateToValue
This commit is contained in:
@@ -44,7 +44,7 @@ class Watch {
|
||||
alertRepeat: (params['alertRepeat'] !== undefined) ? params['alertRepeat'] : 0,
|
||||
initialAlertFunc: (params['initialAlertFunc'] !== undefined) ? params['initialAlertFunc'] : '',
|
||||
endAlertFunc: (params['endAlertFunc'] !== undefined) ? params['endAlertFunc'] : '',
|
||||
hysteresis: (params['hysteresis'] !== undefined) ? this.#stateToValue(params['hysteresis']) : '',
|
||||
hysteresis: (params['hysteresis'] !== undefined) ? lib.convertValue(params['hysteresis']) : '',
|
||||
alert: false
|
||||
}
|
||||
|
||||
@@ -240,44 +240,6 @@ class Watch {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#stateToValue(state) {
|
||||
console.log('Converting value ' + state + ' of type ' + typeof state);
|
||||
if(typeof state === 'string') {
|
||||
if(state.includes(' ')) {
|
||||
try {
|
||||
console.log('Quantity: ' + state);
|
||||
return Quantity(state)
|
||||
} catch(e) {
|
||||
// do nothing, leave it as a String
|
||||
console.log('Not a Quantity but has a space, leaving as a string: ' + state);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
else if(!isNaN(state)) {
|
||||
console.log('Number: ' + state)
|
||||
return Number.parseFloat(state);
|
||||
}
|
||||
else if(state == 'UnDefType' || state == 'NULL' || state == 'UNDEF') {
|
||||
console.log('UnDefType: ' + state);
|
||||
return 'UnDefType';
|
||||
}
|
||||
console.log('String: ' + state);
|
||||
return state;
|
||||
}
|
||||
else if(state instanceof DecimalType || state instanceof PercentType) {
|
||||
console.log('DecimalType or PercentType: ' + state);
|
||||
return state.floatValue();
|
||||
}
|
||||
else if(state instanceof QuantityType) {
|
||||
console.log('QuantityType: ' + state);
|
||||
return Quantity(state);
|
||||
}
|
||||
else {
|
||||
console.log('String: ' + state);
|
||||
return state.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user