homebridge-virtual-accessories
Version:
Virtual HomeKit accessories for Homebridge.
43 lines • 1.89 kB
JavaScript
/* eslint-disable curly */
import { HumidifierType } from '../schema.js';
import { Utils } from '../../utils/utils.js';
/**
*
*/
export class HumidifierDehumidifierConfiguration {
type;
humidifierThreshold;
dehumidifierThreshold;
errorFields = [];
fieldNames = Utils.proxiedPropertiesOf(this);
isValid(prefix) {
const isValidType = (Utils.required(this.type) &&
HumidifierType.Types.includes(this.type));
const isValidHumidifierThreshold = ((this.humidifierThreshold !== undefined) ?
Utils.isPercentage(this.humidifierThreshold) :
true);
const isValidDehumidifierThreshold = ((this.dehumidifierThreshold !== undefined) ?
Utils.isPercentage(this.dehumidifierThreshold) :
true);
const isValidThresholdWindow = ((this.humidifierThreshold !== undefined) && (this.dehumidifierThreshold !== undefined) ?
(this.dehumidifierThreshold > this.humidifierThreshold) :
true);
// Store fields failing validation
if (!isValidType)
this.errorFields.push(prefix + '.' + this.fieldNames.type);
if (!isValidHumidifierThreshold)
this.errorFields.push(prefix + '.' + this.fieldNames.humidifierThreshold);
if (!isValidDehumidifierThreshold)
this.errorFields.push(prefix + '.' + this.fieldNames.dehumidifierThreshold);
if (!isValidThresholdWindow)
this.errorFields.push(prefix + '.' + this.fieldNames.humidifierThreshold + ' <= ' + prefix + '.' + this.fieldNames.dehumidifierThreshold);
return [
(isValidType &&
isValidHumidifierThreshold &&
isValidDehumidifierThreshold &&
isValidThresholdWindow),
this.errorFields,
];
}
}
//# sourceMappingURL=configurationHumidifierDehumidifier.js.map