first Hue light
This commit is contained in:
52
dist/HueColorTemperatureBulbItem.js
vendored
Normal file
52
dist/HueColorTemperatureBulbItem.js
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AHomegearItem_1 = require("./AHomegearItem");
|
||||
class HueColorTemperatureBulbItem extends AHomegearItem_1.AHomegearItem {
|
||||
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.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.brightFeedbackTopic = `${this.topicFirstPart}/bright/feedback`;
|
||||
this.colorTemperatureFeedbackTopic = `${this.topicFirstPart}/colorTemperature/feedback`;
|
||||
this.stateActionTopic = `${this.actionTopicPre}/1/STATE`;
|
||||
this.brightActionTopic = `${this.actionTopicPre}/1/BRIGHTNESS`;
|
||||
this.colorTemperatureActionTopic = `${this.actionTopicPre}/1/COLOR_TEMPERATURE`;
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic,
|
||||
this.brightTopic,
|
||||
this.colorTemperatureTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.bright = 0;
|
||||
this.colorTemperature = 0;
|
||||
}
|
||||
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 = parseInt(payload);
|
||||
MqttDispatcher_1.mqttHandler.send(this.brightFeedbackTopic, `${this.bright}`);
|
||||
MqttDispatcher_1.mqttHandler.send(this.brightActionTopic, `${this.bright}`);
|
||||
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.HueColorTemperatureBulbItem = HueColorTemperatureBulbItem;
|
||||
//# sourceMappingURL=HueColorTemperatureBulbItem.js.map
|
Reference in New Issue
Block a user