1
0

Initial commit of files

This commit is contained in:
2023-08-12 20:57:08 +02:00
parent 012a8f98d4
commit 27e2b6e028
4 changed files with 396 additions and 0 deletions

67
utils/equipment.js Normal file
View File

@@ -0,0 +1,67 @@
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
};