Cron implemented
This commit is contained in:
23
dist/Cron.js
vendored
Normal file
23
dist/Cron.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const logger = require("./log");
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const cron = require("cron");
|
||||
class Cron {
|
||||
constructor(name, target, crontab) {
|
||||
this.name = name;
|
||||
this.targetTopic = target.getInTopic();
|
||||
this.crontab = crontab;
|
||||
}
|
||||
start() {
|
||||
this.crontab.forEach((cronEntry) => {
|
||||
logger.info(`Starting cronjob for: ${this.targetTopic}, ${cronEntry.output} at ${cronEntry.cronTime}`);
|
||||
cronEntry.cronJob = new cron.CronJob(cronEntry.cronTime, () => {
|
||||
logger.info(`Firing ${this.targetTopic}, ${cronEntry.output}`);
|
||||
MqttDispatcher_1.mqttHandler.send(this.targetTopic, cronEntry.output);
|
||||
}, undefined, true, 'Europe/Berlin');
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Cron = Cron;
|
||||
//# sourceMappingURL=Cron.js.map
|
3
dist/MaxThermostat.js
vendored
3
dist/MaxThermostat.js
vendored
@ -6,6 +6,9 @@ const AHomematicItem_1 = require("./AHomematicItem");
|
||||
const WINDOW_OPEN_TEMPERATURE = 4.5;
|
||||
class MaxThermostat extends AHomematicItem_1.AHomematicItem {
|
||||
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
|
||||
getInTopic() {
|
||||
return this.temperatureTopic;
|
||||
}
|
||||
constructor(floor, room, item, label, hmId, windowContacts) {
|
||||
super(floor, room, item, label, hmId);
|
||||
this.temperatureTopic = `${this.topicFirstPart}/temperature`;
|
||||
|
7
dist/main.js
vendored
7
dist/main.js
vendored
@ -15,6 +15,7 @@ const Scene_1 = require("./Scene");
|
||||
const MaxEcoSwitch_1 = require("./MaxEcoSwitch");
|
||||
const MaxThermostat_1 = require("./MaxThermostat");
|
||||
const MaxWindowContact_1 = require("./MaxWindowContact");
|
||||
const Cron_1 = require("./Cron");
|
||||
logger.info("Dispatcher starting");
|
||||
let allLabeledItems = new Array();
|
||||
// Anna -----------------------------------------------------------------------------------------------------
|
||||
@ -162,6 +163,12 @@ let windowContact2 = new MaxWindowContact_1.MaxWindowContact('Gnd', 'Bathroom',
|
||||
windowContact2.start();
|
||||
let thermostat1 = new MaxThermostat_1.MaxThermostat('Gnd', 'Bathroom', 'Thermostat', 'Thermostat Bad unten', 3, [windowContact1, windowContact2]);
|
||||
thermostat1.start();
|
||||
let thermostat1Cron = new Cron_1.Cron('Thermostat1Cron', thermostat1, [
|
||||
{ cronTime: '00 47 17 * * *', output: '5.0' },
|
||||
{ cronTime: '00 48 17 * * *', output: '20.0' },
|
||||
{ cronTime: '00 49 17 * * *', output: '25.0' }
|
||||
]);
|
||||
thermostat1Cron.start();
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// Homekit export
|
||||
let homekitObject = {};
|
||||
|
Reference in New Issue
Block a user