64 lines
2.6 KiB
JavaScript
64 lines
2.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const logger = require("./log");
|
|
const MqttDispatcher_1 = require("./MqttDispatcher");
|
|
const AHomematicItem_1 = require("./AHomematicItem");
|
|
class HomematicDimmerItem extends AHomematicItem_1.AHomematicItem {
|
|
constructor(floor, room, item, hmId) {
|
|
super(floor, room, item, hmId);
|
|
this.stateTopic = `${this.topicFirstPart}/state`;
|
|
this.brightTopic = `${this.topicFirstPart}/bright`;
|
|
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
|
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`;
|
|
this.actionTopic = `${this.actionTopicPre}/1/LEVEL`;
|
|
this.errorOverheatTopic = `${this.deviceTopicPre}/1/ERROR_OVERHEAT`;
|
|
this.errorOverloadTopic = `${this.deviceTopicPre}/1/ERROR_OVERLOAD`;
|
|
this.errorReducedTopic = `${this.deviceTopicPre}/1/ERROR_REDUCED`;
|
|
this.subscribeTopics = [
|
|
this.stateTopic,
|
|
this.brightTopic,
|
|
this.errorOverheatTopic,
|
|
this.errorOverloadTopic,
|
|
this.errorReducedTopic
|
|
];
|
|
this.state = 'OFF';
|
|
this.oldState = undefined;
|
|
this.bright = 0.0;
|
|
this.oldBright = undefined;
|
|
}
|
|
dimmerAction() {
|
|
if ((this.state != this.oldState) || (this.bright != this.oldBright)) {
|
|
if (this.state == 'ON') {
|
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, `${this.bright / 100.0}`);
|
|
}
|
|
else {
|
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, '0');
|
|
}
|
|
this.oldState = this.state;
|
|
this.oldBright = this.bright;
|
|
}
|
|
}
|
|
processMessage(topic, payload) {
|
|
switch (topic) {
|
|
case this.stateTopic:
|
|
this.state = payload;
|
|
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
|
this.dimmerAction();
|
|
break;
|
|
case this.brightTopic:
|
|
this.bright = parseFloat(payload);
|
|
MqttDispatcher_1.mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`);
|
|
this.dimmerAction();
|
|
break;
|
|
case this.errorOverheatTopic:
|
|
case this.errorOverloadTopic:
|
|
case this.errorReducedTopic:
|
|
if (payload != 'false') {
|
|
logger.warn(`Homematic dimmer ${this.hmId}, ${this.itemId} reports: ${topic}: ${payload}`);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
exports.HomematicDimmerItem = HomematicDimmerItem;
|
|
//# sourceMappingURL=HomematicDimmerItem.js.map
|