1
0
This repository has been archived on 2025-01-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
openhab-js-automation-old/utils/equipment.js

68 lines
1.7 KiB
JavaScript

console.loggerName = 'js.equipment';
console.log('Load equipment modules');
class Equipment {
constructor(equipmentItem) {
console.info('Initialization of eqipment ' + equipmentItem.name + ' with type ' + this.constructor.name);
// Set equipmentItem
this.equipmentItem = equipmentItem;
// Set stateItem, toDo: error when no stateItem existing
this.stateItem = items.getItem(this.equipmentItem.name + '_State');
// Initialization of properties
this.name = this.equipmentItem.name;
this.watch = new Object();
}
gc() {
console.log('Denitialization of eqipment ' + this.name);
// Delete all watchObjects
for (let watchItem of Object.keys(this.watch)) {
this.watch[watchItem].deleteAll();
}
}
}
class Irrigation extends Equipment {
constructor(equipmentItem) {
super(equipmentItem);
}
}
class IrrigationValve extends Equipment {
constructor(equipmentItem) {
super(equipmentItem);
this.watch['state'] = new watch.Watch(this.stateItem.name);
this.autoOff = this.watch['state'].add({
targetState: 'ON',
alertFunc: () => { this.stateItem.sendCommand('OFF'); },
alertDelay: 'PT1M'
});
}
}
class TowelRadiator extends Equipment {
constructor(equipmentItem) {
super(equipmentItem);
this.watch['state'] = new watch.Watch(this.stateItem.name);
this.autoOff = this.watch['state'].add({
targetState: 'ON',
alertFunc: () => { this.stateItem.sendCommand('OFF'); },
alertDelay: 'PT30M'
});
}
}
module.exports = {
Equipment,
Irrigation,
IrrigationValve,
TowelRadiator
};