This commit is contained in:
Wolfgang Hottgenroth
2018-01-27 17:58:18 +01:00
parent 3002b01788
commit c4ab32a229
7 changed files with 183 additions and 7 deletions

85
dist/HueColorBulbItem.js vendored Normal file
View File

@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const MqttDispatcher_1 = require("./MqttDispatcher");
const AHomegearItem_1 = require("./AHomegearItem");
const Export_1 = require("./Export");
class HueColorBulbItem extends AHomegearItem_1.AHomegearItem {
getStateTopic() {
return this.stateTopic;
}
getInTopic() {
return this.stateTopic;
}
getStateFeedbackTopic() {
return this.stateFeedbackTopic;
}
constructor(floor, room, item, label, hmId) {
super(floor, room, item, label, hmId);
this.stateTopic = `${this.topicFirstPart}/state`;
this.brightTopic = `${this.topicFirstPart}/bright`;
this.colorTemperatureTopic = `${this.topicFirstPart}/colorTemperature`;
this.hueTopic = `${this.topicFirstPart}/hue`;
this.saturationTopic = `${this.topicFirstPart}/saturation`;
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`;
this.hueFeedbackTopic = `${this.topicFirstPart}/bright/hue`;
this.saturationFeedbackTopic = `${this.topicFirstPart}/bright/saturation`;
this.colorTemperatureFeedbackTopic = `${this.topicFirstPart}/colorTemperature/feedback`;
this.stateActionTopic = `${this.actionTopicPre}/1/STATE`;
this.brightActionTopic = `${this.actionTopicPre}/1/FAST_BRIGHTNESS`;
this.hueActionTopic = `${this.actionTopicPre}/1/HUE`;
this.saturationActionTopic = `${this.actionTopicPre}/1/SATURATION`;
this.colorTemperatureActionTopic = `${this.actionTopicPre}/1/COLOR_TEMPERATURE`;
this.subscribeTopics = [
this.stateTopic,
this.brightTopic,
this.colorTemperatureTopic,
this.hueTopic,
this.saturationTopic
];
this.state = 'OFF';
this.bright = 0;
this.colorTemperature = 0;
this.hue = 0;
this.saturation = 0;
}
exportItem() {
return Export_1.HueColorLightExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.brightTopic, this.brightFeedbackTopic, this.hueTopic, this.hueFeedbackTopic, this.saturationTopic, this.saturationFeedbackTopic, this.colorTemperatureTopic, this.colorTemperatureFeedbackTopic);
}
processMessage(topic, payload) {
switch (topic) {
case this.stateTopic:
this.state = payload;
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
if (this.state == "ON") {
MqttDispatcher_1.mqttHandler.send(this.stateActionTopic, "true");
}
else {
MqttDispatcher_1.mqttHandler.send(this.stateActionTopic, "false");
}
break;
case this.brightTopic:
this.bright = parseFloat(payload);
MqttDispatcher_1.mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`);
MqttDispatcher_1.mqttHandler.send(this.brightActionTopic, `${this.bright * 2.54}`);
break;
case this.hueTopic:
this.hue = parseFloat(payload);
MqttDispatcher_1.mqttHandler.send(this.hueFeedbackTopic, `${this.hue}`);
MqttDispatcher_1.mqttHandler.send(this.hueActionTopic, `${this.hue * 65535.0 / 360.0}`);
break;
case this.saturationTopic:
this.saturation = parseFloat(payload);
MqttDispatcher_1.mqttHandler.send(this.saturationFeedbackTopic, `${this.saturation}`);
MqttDispatcher_1.mqttHandler.send(this.saturationActionTopic, `${this.saturation * 2.54}`);
break;
case this.colorTemperatureTopic:
this.colorTemperature = parseInt(payload);
MqttDispatcher_1.mqttHandler.send(this.colorTemperatureFeedbackTopic, `${this.colorTemperature}`);
MqttDispatcher_1.mqttHandler.send(this.colorTemperatureActionTopic, `${this.colorTemperature}`);
break;
}
}
}
exports.HueColorBulbItem = HueColorBulbItem;
//# sourceMappingURL=HueColorBulbItem.js.map