SimpleTopicSwitchItem added, Regallicht changed
This commit is contained in:
56
dist/SimpleTopicSwitchItem.js
vendored
Normal file
56
dist/SimpleTopicSwitchItem.js
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const MqttDispatcher_1 = require("./MqttDispatcher");
|
||||
const AItem_1 = require("./AItem");
|
||||
const Export_1 = require("./Export");
|
||||
class SimpleTopicSwitchItem extends AItem_1.AItem {
|
||||
getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
getRoom() {
|
||||
return this.room;
|
||||
}
|
||||
getStateTopic() {
|
||||
return this.stateTopic;
|
||||
}
|
||||
getStateFeedbackTopic() {
|
||||
return this.stateFeedbackTopic;
|
||||
}
|
||||
getState() {
|
||||
return this.state;
|
||||
}
|
||||
constructor(floor, room, item, label, actionTopic) {
|
||||
super(floor, room, item, label);
|
||||
this.stateTopic = `${this.topicFirstPart}/state`;
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.actionTopic = actionTopic;
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
}
|
||||
exportItem() {
|
||||
return Export_1.SwitchExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type);
|
||||
}
|
||||
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;
|
||||
}
|
||||
this.emit('somethingChanged');
|
||||
}
|
||||
}
|
||||
exports.SimpleTopicSwitchItem = SimpleTopicSwitchItem;
|
||||
//# sourceMappingURL=SimpleTopicSwitchItem.js.map
|
11
dist/main.js
vendored
11
dist/main.js
vendored
@ -16,7 +16,6 @@ const Scene_1 = require("./Scene");
|
||||
const MaxEcoSwitch_1 = require("./MaxEcoSwitch");
|
||||
const MaxThermostat_1 = require("./MaxThermostat");
|
||||
const MaxWindowContact_1 = require("./MaxWindowContact");
|
||||
const UrlSwitchItem_1 = require("./UrlSwitchItem");
|
||||
const Cron_1 = require("./Cron");
|
||||
const HueColorBulbItem_1 = require("./HueColorBulbItem");
|
||||
const TouchSwitchMultiButtonThing_1 = require("./TouchSwitchMultiButtonThing");
|
||||
@ -24,6 +23,7 @@ const RelayBox_1 = require("./RelayBox");
|
||||
const HeatingScene_1 = require("./HeatingScene");
|
||||
const TwoLedSignal_1 = require("./TwoLedSignal");
|
||||
const MySwitchThing_1 = require("./MySwitchThing");
|
||||
const SimpleTopicSwitchItem_1 = require("./SimpleTopicSwitchItem");
|
||||
logger.info("Dispatcher starting");
|
||||
let allLabeledItems = new Array();
|
||||
let allThermostatItems = new Array();
|
||||
@ -113,10 +113,11 @@ allLabeledItems.push(diningRoomCupboardLight);
|
||||
allRelevantLights.push(diningRoomCupboardLight);
|
||||
allLights.push(diningRoomCupboardLight);
|
||||
// Esszimmer Regallicht
|
||||
let diningRoomShelfLight = new UrlSwitchItem_1.UrlSwitchItem('Gnd', 'Esszimmer', 'ShelfLight', 'Regallicht', 'http://172.16.2.43/dv?dv=1023', 'http://172.16.2.43/dv?dv=0');
|
||||
// diningRoomShelfLight.start()
|
||||
// allLabeledItems.push(diningRoomShelfLight)
|
||||
// allRelevantLights.push(diningRoomShelfLight)
|
||||
let diningRoomShelfLight = new SimpleTopicSwitchItem_1.SimpleTopicSwitchItem('Gnd', 'Esszimmer', 'ShelfLight', 'Regallicht', 'IoT/WifiRelay1/State');
|
||||
diningRoomShelfLight.start();
|
||||
allLabeledItems.push(diningRoomShelfLight);
|
||||
allRelevantLights.push(diningRoomShelfLight);
|
||||
allLights.push(diningRoomShelfLight);
|
||||
let diningRoomNaehkaestchenLight = new HueColorBulbItem_1.HueColorBulbItem('Gnd', 'Esszimmer', 'NaehkaestchenLight', 'Nähkästchen', 15);
|
||||
diningRoomNaehkaestchenLight.start();
|
||||
allLabeledItems.push(diningRoomNaehkaestchenLight);
|
||||
|
70
src/SimpleTopicSwitchItem.ts
Normal file
70
src/SimpleTopicSwitchItem.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import * as logger from './log'
|
||||
import { mqttHandler } from './MqttDispatcher'
|
||||
import { AItem } from './AItem'
|
||||
import { SwitchExport, ExportType } from './Export'
|
||||
import { HasStateAndFeedbackTopicAndLabelAndRoom } from './AItem';
|
||||
|
||||
export class SimpleTopicSwitchItem extends AItem implements HasStateAndFeedbackTopicAndLabelAndRoom {
|
||||
private oldState: string|undefined
|
||||
private state: string
|
||||
private actionTopic: string
|
||||
private deviceFeedbackTopic: string
|
||||
private stateFeedbackTopic: string
|
||||
private stateTopic: string
|
||||
private type: string
|
||||
private partId: number
|
||||
|
||||
getLabel(): string {
|
||||
return this.label
|
||||
}
|
||||
|
||||
getRoom() : string {
|
||||
return this.room
|
||||
}
|
||||
|
||||
getStateTopic() : string {
|
||||
return this.stateTopic
|
||||
}
|
||||
|
||||
getStateFeedbackTopic() : string {
|
||||
return this.stateFeedbackTopic
|
||||
}
|
||||
|
||||
getState() : string {
|
||||
return this.state
|
||||
}
|
||||
|
||||
constructor(floor: string, room: string, item: string, label: string, actionTopic: string) {
|
||||
super(floor, room, item, label)
|
||||
this.stateTopic = `${this.topicFirstPart}/state`
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
||||
this.actionTopic = actionTopic
|
||||
this.subscribeTopics = [
|
||||
this.stateTopic
|
||||
]
|
||||
this.state = 'OFF'
|
||||
this.oldState = undefined
|
||||
}
|
||||
|
||||
exportItem() : ExportType|null {
|
||||
return SwitchExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type)
|
||||
}
|
||||
|
||||
processMessage(topic: string, payload: string) : void {
|
||||
switch (topic) {
|
||||
case this.stateTopic:
|
||||
this.state = payload
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
mqttHandler.send(this.actionTopic, 'true')
|
||||
} else {
|
||||
mqttHandler.send(this.actionTopic, 'false')
|
||||
}
|
||||
this.oldState = this.state
|
||||
}
|
||||
break
|
||||
}
|
||||
this.emit('somethingChanged')
|
||||
}
|
||||
}
|
11
src/main.ts
11
src/main.ts
@ -26,6 +26,8 @@ import { RelayBoxThing } from './RelayBox'
|
||||
import { HeatingScene } from './HeatingScene'
|
||||
import { TwoLedSignal } from './TwoLedSignal'
|
||||
import { MySwitchThing, MySwitchSingleItem } from './MySwitchThing'
|
||||
import { SimpleTopicSwitchItem } from './SimpleTopicSwitchItem'
|
||||
|
||||
|
||||
|
||||
logger.info("Dispatcher starting")
|
||||
@ -137,10 +139,11 @@ allRelevantLights.push(diningRoomCupboardLight)
|
||||
allLights.push(diningRoomCupboardLight)
|
||||
|
||||
// Esszimmer Regallicht
|
||||
let diningRoomShelfLight = new UrlSwitchItem('Gnd', 'Esszimmer', 'ShelfLight', 'Regallicht', 'http://172.16.2.43/dv?dv=1023', 'http://172.16.2.43/dv?dv=0')
|
||||
// diningRoomShelfLight.start()
|
||||
// allLabeledItems.push(diningRoomShelfLight)
|
||||
// allRelevantLights.push(diningRoomShelfLight)
|
||||
let diningRoomShelfLight = new SimpleTopicSwitchItem('Gnd', 'Esszimmer', 'ShelfLight', 'Regallicht', 'IoT/WifiRelay1/State')
|
||||
diningRoomShelfLight.start()
|
||||
allLabeledItems.push(diningRoomShelfLight)
|
||||
allRelevantLights.push(diningRoomShelfLight)
|
||||
allLights.push(diningRoomShelfLight)
|
||||
|
||||
let diningRoomNaehkaestchenLight = new HueColorBulbItem('Gnd', 'Esszimmer', 'NaehkaestchenLight', 'Nähkästchen', 15)
|
||||
diningRoomNaehkaestchenLight.start()
|
||||
|
Reference in New Issue
Block a user