export prepared

This commit is contained in:
2018-03-27 21:50:48 +02:00
parent 4f2e74bddb
commit cc930e6bbc
7 changed files with 40 additions and 6 deletions

3
dist/AItem.js vendored
View File

@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
class AItem {
constructor(floor, room, item, label = '') {
@ -21,7 +20,7 @@ class AItem {
}
start() {
MqttDispatcher_1.mqttHandler.register(this.subscribeTopics, (topic, payload) => {
logger.info(`item ${this.itemId}: ${topic}, ${payload}`);
// logger.info(`item ${this.itemId}: ${topic}, ${payload}`)
this.processMessage(topic, payload);
});
}

11
dist/Export.js vendored
View File

@ -28,6 +28,17 @@ function HueColorLightExport(itemId, label, stateTopic, stateFeedbackTopic, brig
return { 'homekit': HueColorLightHomekitExport(itemId, label, stateTopic, stateFeedbackTopic, brightnessTopic, brightnessFeedbackTopic, hueTopic, hueFeedbackTopic, saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic), 'openhab': '' };
}
exports.HueColorLightExport = HueColorLightExport;
function RelayBoxExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) {
return { 'homekit': RelayBoxHomekitExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames),
'openhab': RelayBoxOpenHABExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) };
}
exports.RelayBoxExport = RelayBoxExport;
function RelayBoxHomekitExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) {
return { 'id': '', 'object': {} };
}
function RelayBoxOpenHABExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) {
return '';
}
function SwitchHomekitBulbExport(id, label, setOn, statusOn) {
let o = {
"id": id,

View File

@ -43,7 +43,7 @@ class MqttHandler {
this.mqttClient.on('message', (topic, payload, packet) => {
if (!packet.retain) {
let payloadStr = payload.toString('UTF-8');
logger.info(`Message received on topic ${topic}: ${payload}`);
// logger.info(`Message received on topic ${topic}: ${payload}`)
this.processMessage(topic, payloadStr);
}
});
@ -76,7 +76,7 @@ class MqttHandler {
// sent = this.processMessage(topic, payload)
//}
//if (! sent) {
logger.info(`External sending required: ${topic}`);
logger.info(`External sending required: ${topic} ${payload}`);
let options = { retain: true, qos: 0 };
this.mqttClient.publish(topic, payload, options);
//} else {

6
dist/RelayBox.js vendored
View File

@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
const AItem_1 = require("./AItem");
const Export_1 = require("./Export");
class RelayBoxThing extends AItem_1.AItem {
constructor(floor, room, item, deviceCommandTopic, deviceStatusTopic, itemNames) {
super(floor, room, item, '');
@ -18,10 +19,13 @@ class RelayBoxThing extends AItem_1.AItem {
];
this.oldSwitchStates = '';
}
exportItem() {
return Export_1.RelayBoxExport(this.stateTopicPre, this.feedbackTopicPre, this.conflictTopicPre, this.itemNames);
}
processMessage(topic, payload) {
// logger.info(`RT: ${topic}, ${payload}`)
if (topic == this.deviceStatusTopic) {
logger.info(`RT: status received`);
// logger.info(`RT: status received`)
this.status = JSON.parse(payload);
let statusParsed = JSON.stringify(this.status);
this.switchStates = JSON.stringify(this.status.data.switchStates);