Compare commits
1 Commits
without_st
...
master
Author | SHA1 | Date | |
---|---|---|---|
ceeecf5009 |
15
dist/HomematicSwitchItem.js
vendored
15
dist/HomematicSwitchItem.js
vendored
@ -31,6 +31,7 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
this.deviceFeedbackTopic
|
||||
];
|
||||
this.state = 'OFF';
|
||||
this.oldState = undefined;
|
||||
this.type = type;
|
||||
}
|
||||
exportItem() {
|
||||
@ -41,11 +42,14 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
case this.stateTopic:
|
||||
this.state = payload;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state == 'ON') {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true');
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false');
|
||||
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:
|
||||
@ -55,6 +59,7 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
||||
else {
|
||||
this.state = 'OFF';
|
||||
}
|
||||
this.oldState = this.state;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
break;
|
||||
}
|
||||
|
14
dist/M433SwitchItem.js
vendored
14
dist/M433SwitchItem.js
vendored
@ -26,6 +26,7 @@ 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;
|
||||
@ -36,11 +37,14 @@ class M433SwitchItem extends AItem_1.AItem {
|
||||
processMessage(topic, payload) {
|
||||
this.state = payload;
|
||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state == 'ON') {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.onCode);
|
||||
}
|
||||
else {
|
||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
31
dist/main.js
vendored
31
dist/main.js
vendored
@ -477,36 +477,7 @@ let watchdogTimer = setInterval(() => {
|
||||
watchdogCounter += 1;
|
||||
MqttDispatcher_1.mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`);
|
||||
}, config.dict.watchdogInterval);
|
||||
// // ----------------------------------------------------------------------------------------------------------
|
||||
// // 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() };
|
||||
|
@ -46,6 +46,7 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
this.deviceFeedbackTopic
|
||||
]
|
||||
this.state = 'OFF'
|
||||
this.oldState = undefined
|
||||
this.type = type
|
||||
}
|
||||
|
||||
@ -58,10 +59,13 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
case this.stateTopic:
|
||||
this.state = payload
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||
if (this.state == 'ON') {
|
||||
mqttHandler.send(this.actionTopic, 'true')
|
||||
} else {
|
||||
mqttHandler.send(this.actionTopic, 'false')
|
||||
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:
|
||||
@ -70,6 +74,7 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
||||
} else {
|
||||
this.state = 'OFF'
|
||||
}
|
||||
this.oldState = this.state
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||
break
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ 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
|
||||
@ -53,10 +54,13 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd
|
||||
processMessage(topic: string, payload: string) {
|
||||
this.state = payload;
|
||||
mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||
if (this.state == 'ON') {
|
||||
mqttHandler.send(this.actionTopic, this.onCode);
|
||||
} else {
|
||||
mqttHandler.send(this.actionTopic, this.offCode);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
36
src/main.ts
36
src/main.ts
@ -597,41 +597,7 @@ let watchdogTimer = setInterval(() => {
|
||||
|
||||
|
||||
|
||||
// // ----------------------------------------------------------------------------------------------------------
|
||||
// // 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: any = {}
|
||||
allLights.forEach((item: HasStateAndFeedbackTopicAndLabelAndRoom) => {
|
||||
|
Reference in New Issue
Block a user