Compare commits
3 Commits
master
...
without_st
Author | SHA1 | Date | |
---|---|---|---|
f4933cb483
|
|||
80550321d2
|
|||
f98b1c2f39
|
5
dist/HomematicSwitchItem.js
vendored
5
dist/HomematicSwitchItem.js
vendored
@ -31,7 +31,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
this.type = type;
|
||||
}
|
||||
exportItem() {
|
||||
@ -42,15 +41,12 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
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') {
|
||||
@ -59,7 +55,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
this.oldState = this.state;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
break;
|
||||
}
|
||||
|
4
dist/M433SwitchItem.js
vendored
4
dist/M433SwitchItem.js
vendored
@ -26,7 +26,6 @@ class M433SwitchItem extends AItem_1.AItem {
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||
this.actionTopic = 'IoT/Mqtt433Gateway/Message';
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
this.onCode = onCode;
|
||||
this.offCode = offCode;
|
||||
this.type = type;
|
||||
@ -37,15 +36,12 @@ class M433SwitchItem extends AItem_1.AItem {
|
||||
processMessage(topic, payload) {
|
||||
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, this.onCode);
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode);
|
||||
}
|
||||
this.oldState = this.state;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.M433SwitchItem = M433SwitchItem;
|
||||
|
4
dist/SimpleTopicSwitchItem.js
vendored
4
dist/SimpleTopicSwitchItem.js
vendored
@ -40,10 +40,10 @@ class SimpleTopicSwitchItem extends AItem_1.AItem {
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true');
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'ON');
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false');
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'OFF');
|
||||
}
|
||||
this.oldState = this.state;
|
||||
}
|
||||
|
61
dist/main.js
vendored
61
dist/main.js
vendored
@ -477,37 +477,36 @@ let watchdogTimer = setInterval(() => {
|
||||
watchdogCounter += 1;
|
||||
MqttDispatcher_1.mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`);
|
||||
}, config.dict.watchdogInterval);
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// Homekit export
|
||||
let homekitObject = {};
|
||||
let openhabList = [];
|
||||
// logger.info("allLabeledItems")
|
||||
// logger.info(JSON.stringify(allLabeledItems))
|
||||
allLabeledItems.forEach((item) => {
|
||||
let exportData = item.exportItem();
|
||||
if (exportData != null) {
|
||||
if ('id' in exportData['homekit']) {
|
||||
homekitObject[exportData['homekit']['id']] = exportData['homekit']['object'];
|
||||
}
|
||||
if (exportData['openhab'] instanceof Array) {
|
||||
let da = exportData['openhab'];
|
||||
da.forEach((o) => openhabList.push(o));
|
||||
}
|
||||
else {
|
||||
let da = exportData['openhab'];
|
||||
openhabList.push(da);
|
||||
}
|
||||
// logger.info("openHabList")
|
||||
// logger.info(JSON.stringify(openhabList))
|
||||
}
|
||||
});
|
||||
let heatingMainSwitchExport = MaxThermostat_1.MaxThermostat.exportHeatingMainSwitchItem();
|
||||
if (heatingMainSwitchExport != null) {
|
||||
let da = heatingMainSwitchExport['openhab'];
|
||||
openhabList.push(da);
|
||||
}
|
||||
fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4));
|
||||
fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'));
|
||||
// // ----------------------------------------------------------------------------------------------------------
|
||||
// // Homekit export
|
||||
// let homekitObject : { [key:string]:{} } = {}
|
||||
// let openhabList : string[] = []
|
||||
// // logger.info("allLabeledItems")
|
||||
// // logger.info(JSON.stringify(allLabeledItems))
|
||||
// allLabeledItems.forEach((item: AItem) => {
|
||||
// let exportData : ExportType|null = item.exportItem()
|
||||
// if (exportData != null) {
|
||||
// if ('id' in exportData['homekit']) {
|
||||
// homekitObject[exportData['homekit']['id']] = exportData['homekit']['object']
|
||||
// }
|
||||
// if (exportData['openhab'] instanceof Array) {
|
||||
// let da : string[] = exportData['openhab'] as string[]
|
||||
// da.forEach((o: string) => openhabList.push(o))
|
||||
// } else {
|
||||
// let da : string = exportData['openhab'] as string
|
||||
// openhabList.push(da)
|
||||
// }
|
||||
// // logger.info("openHabList")
|
||||
// // logger.info(JSON.stringify(openhabList))
|
||||
// }
|
||||
// })
|
||||
// let heatingMainSwitchExport : ExportType|null = MaxThermostat.exportHeatingMainSwitchItem()
|
||||
// if (heatingMainSwitchExport != null) {
|
||||
// let da : string = heatingMainSwitchExport['openhab'] as string
|
||||
// openhabList.push(da)
|
||||
// }
|
||||
// fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4))
|
||||
// fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'))
|
||||
let roomSwitches = {};
|
||||
allLights.forEach((item) => {
|
||||
let switchItem = { 'label': item.getLabel(), 'actionTopic': item.getStateTopic(), 'feedbackTopic': item.getStateFeedbackTopic() };
|
||||
|
@ -48,6 +48,11 @@
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/Esszimmer/CupboardLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/Esszimmer/CupboardLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Regallicht",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/Esszimmer/ShelfLight/state",
|
||||
"feedbackTopic": "dispatcher_ng/items/Gnd/Esszimmer/ShelfLight/state/feedback"
|
||||
},
|
||||
{
|
||||
"label": "Nähkästchen",
|
||||
"actionTopic": "dispatcher_ng/items/Gnd/Esszimmer/NaehkaestchenLight/state",
|
||||
|
@ -46,7 +46,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
this.deviceFeedbackTopic
|
||||
]
|
||||
this.state = 'OFF'
|
||||
this.oldState = undefined
|
||||
this.type = type
|
||||
}
|
||||
|
||||
@ -59,14 +58,11 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
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
|
||||
case this.deviceFeedbackTopic:
|
||||
if (payload == 'true') {
|
||||
@ -74,7 +70,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
} else {
|
||||
this.state = 'OFF'
|
||||
}
|
||||
this.oldState = this.state
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||
break
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd
|
||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
||||
this.actionTopic = 'IoT/Mqtt433Gateway/Message'
|
||||
this.state = 'OFF'
|
||||
this.oldState = undefined
|
||||
this.onCode = onCode
|
||||
this.offCode = offCode
|
||||
this.type = type
|
||||
@ -54,14 +53,11 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd
|
||||
processMessage(topic: string, payload: string) {
|
||||
this.state = payload;
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
mqttHandler.send(this.actionTopic, this.onCode);
|
||||
} else {
|
||||
mqttHandler.send(this.actionTopic, this.offCode);
|
||||
}
|
||||
this.oldState = this.state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ export class SimpleTopicSwitchItem extends AItem implements HasStateAndFeedbackT
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||
if (this.state != this.oldState) {
|
||||
if (this.state == 'ON') {
|
||||
mqttHandler.send(this.actionTopic, 'true')
|
||||
mqttHandler.send(this.actionTopic, 'ON')
|
||||
} else {
|
||||
mqttHandler.send(this.actionTopic, 'false')
|
||||
mqttHandler.send(this.actionTopic, 'OFF')
|
||||
}
|
||||
this.oldState = this.state
|
||||
}
|
||||
|
60
src/main.ts
60
src/main.ts
@ -597,40 +597,40 @@ let watchdogTimer = setInterval(() => {
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
// Homekit export
|
||||
let homekitObject : { [key:string]:{} } = {}
|
||||
let openhabList : string[] = []
|
||||
// // ----------------------------------------------------------------------------------------------------------
|
||||
// // Homekit export
|
||||
// let homekitObject : { [key:string]:{} } = {}
|
||||
// let openhabList : string[] = []
|
||||
|
||||
// logger.info("allLabeledItems")
|
||||
// logger.info(JSON.stringify(allLabeledItems))
|
||||
// // logger.info("allLabeledItems")
|
||||
// // logger.info(JSON.stringify(allLabeledItems))
|
||||
|
||||
allLabeledItems.forEach((item: AItem) => {
|
||||
let exportData : ExportType|null = item.exportItem()
|
||||
if (exportData != null) {
|
||||
if ('id' in exportData['homekit']) {
|
||||
homekitObject[exportData['homekit']['id']] = exportData['homekit']['object']
|
||||
}
|
||||
if (exportData['openhab'] instanceof Array) {
|
||||
let da : string[] = exportData['openhab'] as string[]
|
||||
da.forEach((o: string) => openhabList.push(o))
|
||||
} else {
|
||||
let da : string = exportData['openhab'] as string
|
||||
openhabList.push(da)
|
||||
}
|
||||
// logger.info("openHabList")
|
||||
// logger.info(JSON.stringify(openhabList))
|
||||
}
|
||||
})
|
||||
// allLabeledItems.forEach((item: AItem) => {
|
||||
// let exportData : ExportType|null = item.exportItem()
|
||||
// if (exportData != null) {
|
||||
// if ('id' in exportData['homekit']) {
|
||||
// homekitObject[exportData['homekit']['id']] = exportData['homekit']['object']
|
||||
// }
|
||||
// if (exportData['openhab'] instanceof Array) {
|
||||
// let da : string[] = exportData['openhab'] as string[]
|
||||
// da.forEach((o: string) => openhabList.push(o))
|
||||
// } else {
|
||||
// let da : string = exportData['openhab'] as string
|
||||
// openhabList.push(da)
|
||||
// }
|
||||
// // logger.info("openHabList")
|
||||
// // logger.info(JSON.stringify(openhabList))
|
||||
// }
|
||||
// })
|
||||
|
||||
let heatingMainSwitchExport : ExportType|null = MaxThermostat.exportHeatingMainSwitchItem()
|
||||
if (heatingMainSwitchExport != null) {
|
||||
let da : string = heatingMainSwitchExport['openhab'] as string
|
||||
openhabList.push(da)
|
||||
}
|
||||
// let heatingMainSwitchExport : ExportType|null = MaxThermostat.exportHeatingMainSwitchItem()
|
||||
// if (heatingMainSwitchExport != null) {
|
||||
// let da : string = heatingMainSwitchExport['openhab'] as string
|
||||
// openhabList.push(da)
|
||||
// }
|
||||
|
||||
fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4))
|
||||
fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'))
|
||||
// fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4))
|
||||
// fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'))
|
||||
|
||||
|
||||
let roomSwitches: any = {}
|
||||
|
Reference in New Issue
Block a user