typescriptifying completed
This commit is contained in:
23
dist/Forwarder.js
vendored
Normal file
23
dist/Forwarder.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const AItem_1 = require("./AItem");
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
class Forwarder extends AItem_1.AItem {
|
||||
constructor(floor, room, item, topicLastPart, targetTopics) {
|
||||
super(floor, room, item);
|
||||
this.inTopic = `${this.topicFirstPart}/${topicLastPart}`;
|
||||
this.subscribeTopics = [this.inTopic];
|
||||
this.targetTopics = targetTopics;
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
switch (topic) {
|
||||
case this.inTopic:
|
||||
this.targetTopics.forEach((targetTopic) => {
|
||||
MqttDispatcher_1.mqttHandler.send(targetTopic, payload, true);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Forwarder = Forwarder;
|
||||
//# sourceMappingURL=Forwarder.js.map
|
64
dist/HomematicDimmerItem.js
vendored
Normal file
64
dist/HomematicDimmerItem.js
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
"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
|
48
dist/HomematicSwitchItem.js
vendored
Normal file
48
dist/HomematicSwitchItem.js
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AHomematicItem_1 = require("./AHomematicItem");
|
||||
class HomematicSwitchItem extends AHomematicItem_1.AHomematicItem {
|
||||
constructor(floor, room, item, hmId) {
|
||||
super(floor, room, item, hmId);
|
||||
this.stateTopic = `${this.topicFirstPart}/state`;
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.deviceFeedbackTopic = `${this.deviceTopicPre}/1/STATE`;
|
||||
this.actionTopic = `${this.actionTopicPre}/1/STATE`;
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic,
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
switch (topic) {
|
||||
case this.stateTopic:
|
||||
this.state = payload;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true');
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false');
|
||||
}
|
||||
this.oldState = this.state;
|
||||
}
|
||||
break;
|
||||
case this.deviceFeedbackTopic:
|
||||
if (payload == 'true') {
|
||||
this.state = 'ON';
|
||||
}
|
||||
else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
this.oldState = this.state;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.HomematicSwitchItem = HomematicSwitchItem;
|
||||
//# sourceMappingURL=HomematicSwitchItem.js.map
|
50
dist/TimerAdaptor.js
vendored
Normal file
50
dist/TimerAdaptor.js
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const AItem_1 = require("./AItem");
|
||||
const logger = require("./log");
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
class TimerAdaptor extends AItem_1.AItem {
|
||||
constructor(floor, room, item, delay) {
|
||||
super(floor, room, item);
|
||||
this.actionStateTopic = `${this.topicFirstPart}/state`;
|
||||
this.inTopic = `${this.topicFirstPart}/timerIn`;
|
||||
this.subscribeTopics = [this.inTopic];
|
||||
this.state = 'OFF';
|
||||
this.delay = delay;
|
||||
this.timer = null;
|
||||
}
|
||||
processMessage(topic, payload) {
|
||||
switch (topic) {
|
||||
case this.inTopic:
|
||||
switch (payload) {
|
||||
case 'SHORT':
|
||||
if ((this.state == 'ON') && (this.timer != null)) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
this.state = 'ON';
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionStateTopic, this.state, true);
|
||||
this.timer = setTimeout(() => {
|
||||
logger.info(`timer ${this.itemId} elapsed`);
|
||||
this.state = 'OFF';
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionStateTopic, this.state, true);
|
||||
}, (this.delay * 1000));
|
||||
break;
|
||||
case 'LONG_END':
|
||||
if (this.timer != null) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
if (this.state == 'OFF') {
|
||||
this.state = 'ON';
|
||||
}
|
||||
else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionStateTopic, this.state, true);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.TimerAdaptor = TimerAdaptor;
|
||||
//# sourceMappingURL=TimerAdaptor.js.map
|
15
dist/main.js
vendored
15
dist/main.js
vendored
@ -5,6 +5,10 @@ const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const M433SwitchItem_1 = require("./M433SwitchItem");
|
||||
const HomematicFourButtonThing_1 = require("./HomematicFourButtonThing");
|
||||
const DimmerAdaptor_1 = require("./DimmerAdaptor");
|
||||
const TimerAdaptor_1 = require("./TimerAdaptor");
|
||||
const HomematicDimmerItem_1 = require("./HomematicDimmerItem");
|
||||
const HomematicSwitchItem_1 = require("./HomematicSwitchItem");
|
||||
const Forwarder_1 = require("./Forwarder");
|
||||
logger.info("Dispatcher starting");
|
||||
let aquariumLight = new M433SwitchItem_1.M433SwitchItem('1st', 'Anna', 'AquariumLight', '14665044 24 1', '14665041 24 1');
|
||||
aquariumLight.start();
|
||||
@ -19,6 +23,17 @@ let testFourButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gn
|
||||
testFourButton.start();
|
||||
let testDimmerAdaptor = new DimmerAdaptor_1.DimmerAdaptor('Gnd', 'Hallway', 'Testlight');
|
||||
testDimmerAdaptor.start();
|
||||
let testTimerAdaptor = new TimerAdaptor_1.TimerAdaptor('Gnd', 'Hallway', 'DeskLight', 10);
|
||||
testTimerAdaptor.start();
|
||||
let testLight = new HomematicDimmerItem_1.HomematicDimmerItem('Gnd', 'Hallway', 'Testlight', 8);
|
||||
testLight.start();
|
||||
let testLight2 = new HomematicSwitchItem_1.HomematicSwitchItem('Gnd', 'Hallway', 'Testlight2', 5);
|
||||
testLight2.start();
|
||||
let testForwarder = new Forwarder_1.Forwarder('Gnd', 'Hallway', 'TestForwarder', 'state', [
|
||||
'dispatcher_ng/items/Gnd/Hallway/Testlight2/state',
|
||||
'dispatcher_ng/items/Gnd/Hallway/DeskLight/state'
|
||||
]);
|
||||
testForwarder.start();
|
||||
MqttDispatcher_1.mqttHandler.exec();
|
||||
logger.info("Dispatcher running");
|
||||
//# sourceMappingURL=main.js.map
|
Reference in New Issue
Block a user