relaybox stuff
This commit is contained in:
42
dist/RelayBox.js
vendored
Normal file
42
dist/RelayBox.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const logger = require("./log");
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AItem_1 = require("./AItem");
|
||||
class RelayBoxThing extends AItem_1.AItem {
|
||||
constructor(floor, room, item, deviceCommandTopic, deviceStatusTopic, itemNames) {
|
||||
super(floor, room, item, '');
|
||||
this.itemNames = itemNames;
|
||||
this.deviceCommandTopic = deviceCommandTopic;
|
||||
this.deviceStatusTopic = deviceStatusTopic;
|
||||
this.stateTopicPre = `${this.topicFirstPart}/state`;
|
||||
this.subscribeTopics = [
|
||||
`${this.deviceStatusTopic}`,
|
||||
`${this.stateTopicPre}/#`
|
||||
];
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
logger.info(`RT: ${topic}, ${payload}`);
|
||||
if (topic == this.deviceStatusTopic) {
|
||||
logger.info(`RT: status received`);
|
||||
}
|
||||
else {
|
||||
let thingRelatedPart = topic.substring(this.stateTopicPre.length + 1);
|
||||
let itemIdx = parseInt(thingRelatedPart);
|
||||
logger.info(`RT: pre: ${this.stateTopicPre}, thingRelatedPart: ${thingRelatedPart}, itemIdx: ${itemIdx}`);
|
||||
if (itemIdx >= 0 && itemIdx < this.itemNames.length) {
|
||||
if (payload == 'ON') {
|
||||
MqttDispatcher_1.mqttHandler.send(this.deviceCommandTopic, `switch ${itemIdx} on`);
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.deviceCommandTopic, `switch ${itemIdx} off`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.warn(`RT: no handling available for ${topic}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.RelayBoxThing = RelayBoxThing;
|
||||
//# sourceMappingURL=RelayBox.js.map
|
6
dist/main.js
vendored
6
dist/main.js
vendored
@ -19,6 +19,7 @@ const UrlSwitchItem_1 = require("./UrlSwitchItem");
|
||||
const Cron_1 = require("./Cron");
|
||||
const HueColorBulbItem_1 = require("./HueColorBulbItem");
|
||||
const TouchSwitchMultiButtonThing_1 = require("./TouchSwitchMultiButtonThing");
|
||||
const RelayBox_1 = require("./RelayBox");
|
||||
logger.info("Dispatcher starting");
|
||||
let allLabeledItems = new Array();
|
||||
// Anna -----------------------------------------------------------------------------------------------------
|
||||
@ -249,6 +250,11 @@ let thermostatKitchenCron = new Cron_1.Cron('thermostatKitchenCron', thermostatK
|
||||
]);
|
||||
thermostatKitchenCron.start();
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
let relayBox = new RelayBox_1.RelayBoxThing('base', 'labor', 'relaybox', 'IoT/Command/RelayBox', 'IoT/Status/RelayBox', [
|
||||
"Küche", "Herd", "Waschküche", "Licht Keller", "Licht EG", "Licht OG"
|
||||
]);
|
||||
relayBox.start();
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
let testFourButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gnd', 'Hallway', 'TestButton', 9, [
|
||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Hallway/Testlight/dimmerIn'),
|
||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Hallway/DeskLight/timerIn'),
|
||||
|
Reference in New Issue
Block a user