preset fix

This commit is contained in:
2018-04-06 23:38:08 +02:00
parent c503e31ee5
commit a5c629e331
8 changed files with 36 additions and 8 deletions

4
dist/AItem.js vendored
View File

@ -15,6 +15,8 @@ class AItem {
}
this.topicFirstPart = `dispatcher_ng/items/${this.floor}/${this.room}/${this.item}`;
}
startFunc() {
}
exportItem() {
return null;
}
@ -22,7 +24,7 @@ class AItem {
MqttDispatcher_1.mqttHandler.register(this.subscribeTopics, (topic, payload) => {
// logger.info(`item ${this.itemId}: ${topic}, ${payload}`)
this.processMessage(topic, payload);
});
}, () => { this.startFunc(); });
}
}
exports.AItem = AItem;

View File

@ -36,7 +36,10 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem {
});
}
setPresetTemperature(presetTemperature) {
this.processMessage(this.presetTemperatureTopic, `${presetTemperature}`);
this.presetTemperature = presetTemperature;
}
startFunc() {
MqttDispatcher_1.mqttHandler.send(this.presetTemperatureTopic, `${this.presetTemperature}`);
}
processMessage(topic, payload) {
let setTemperature = false;

View File

@ -17,13 +17,15 @@ class MqttHandler {
this.mqttOptions.rejectUnauthorized = true;
}
this.topicHandlers = [];
this.startCallbacks = [];
logger.info("MqttHandler constructed");
}
register(topics, cb) {
register(topics, cb, startCb) {
topics.forEach((topic) => {
this.topicHandlers.push({ topic: topic, callback: cb });
logger.info(`Callback registered for ${topic}`);
});
this.startCallbacks.push(startCb);
}
exec() {
logger.info(`Connecting to ${this.mqttBrokerUrl}`);
@ -39,6 +41,10 @@ class MqttHandler {
logger.info(`${topicHandler.topic} subscribed`);
});
logger.info('MQTT connection established');
this.startCallbacks.forEach((cb) => {
cb();
logger.info("started");
});
});
this.mqttClient.on('message', (topic, payload, packet) => {
if (!packet.retain) {

2
dist/main.js vendored
View File

@ -221,7 +221,7 @@ windowContactBathroom1st.start();
allLabeledItems.push(windowContactBathroom1st);
let thermostatBathroom1st = new MaxThermostat_1.MaxThermostat('1st', 'Bathroom', 'Thermostat', 'Thermostat Bad oben', 3, [windowContactBathroom1st]);
thermostatBathroom1st.start();
thermostatBedroom1st.setPresetTemperature(20.0);
thermostatBathroom1st.setPresetTemperature(20.0);
allLabeledItems.push(thermostatBathroom1st);
let thermostatBathroom1stCron = new Cron_1.Cron('thermostatBathroom1stCron', thermostatBathroom1st, [
{ cronTime: '00 00 06 * * 1-5', output: 'ON' },