Compare commits
5 Commits
master
...
HardButton
Author | SHA1 | Date | |
---|---|---|---|
8c6c89aa18
|
|||
a5e3d53d50
|
|||
f4933cb483
|
|||
80550321d2
|
|||
f98b1c2f39
|
15
dist/HomematicSwitchItem.js
vendored
15
dist/HomematicSwitchItem.js
vendored
@ -31,7 +31,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
|||||||
this.deviceFeedbackTopic
|
this.deviceFeedbackTopic
|
||||||
];
|
];
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
this.oldState = undefined;
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
exportItem() {
|
exportItem() {
|
||||||
@ -42,14 +41,11 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
|||||||
case this.stateTopic:
|
case this.stateTopic:
|
||||||
this.state = payload;
|
this.state = payload;
|
||||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||||
if (this.state != this.oldState) {
|
if (this.state == 'ON') {
|
||||||
if (this.state == 'ON') {
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true');
|
||||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'true');
|
}
|
||||||
}
|
else {
|
||||||
else {
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false');
|
||||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, 'false');
|
|
||||||
}
|
|
||||||
this.oldState = this.state;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case this.deviceFeedbackTopic:
|
case this.deviceFeedbackTopic:
|
||||||
@ -59,7 +55,6 @@ class HomematicSwitchItem extends AHomegearItem_1.AHomegearItem {
|
|||||||
else {
|
else {
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
}
|
}
|
||||||
this.oldState = this.state;
|
|
||||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
14
dist/M433SwitchItem.js
vendored
14
dist/M433SwitchItem.js
vendored
@ -26,7 +26,6 @@ class M433SwitchItem extends AItem_1.AItem {
|
|||||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`;
|
||||||
this.actionTopic = 'IoT/Mqtt433Gateway/Message';
|
this.actionTopic = 'IoT/Mqtt433Gateway/Message';
|
||||||
this.state = 'OFF';
|
this.state = 'OFF';
|
||||||
this.oldState = undefined;
|
|
||||||
this.onCode = onCode;
|
this.onCode = onCode;
|
||||||
this.offCode = offCode;
|
this.offCode = offCode;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -37,14 +36,11 @@ class M433SwitchItem extends AItem_1.AItem {
|
|||||||
processMessage(topic, payload) {
|
processMessage(topic, payload) {
|
||||||
this.state = payload;
|
this.state = payload;
|
||||||
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||||
if (this.state != this.oldState) {
|
if (this.state == 'ON') {
|
||||||
if (this.state == 'ON') {
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.onCode);
|
||||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.onCode);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode);
|
||||||
MqttDispatcher_1.mqttHandler.send(this.actionTopic, this.offCode);
|
|
||||||
}
|
|
||||||
this.oldState = this.state;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
84
dist/main.js
vendored
84
dist/main.js
vendored
@ -409,13 +409,58 @@ let mySwitchThingWolfgang = new MySwitchThing_1.MySwitchThing('1st', 'Schlafzimm
|
|||||||
]);
|
]);
|
||||||
mySwitchThingWolfgang.start();
|
mySwitchThingWolfgang.start();
|
||||||
// ----------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
let testFourButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gnd', 'Flur', 'TestButton', 9, [
|
let hardButton = new HomematicFourButtonThing_1.HomematicFourButtonThing('Gnd', 'Flur', 'HardButton', 9, [
|
||||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/Testlight/dimmerIn'),
|
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/HardButtonState/NextState'),
|
||||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/DeskLight/timerIn'),
|
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/2'),
|
||||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/3'),
|
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/3'),
|
||||||
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/4')
|
new HomematicFourButtonThing_1.HomematicFourButtonSingleItem('test/button/4')
|
||||||
]);
|
]);
|
||||||
testFourButton.start();
|
hardButton.start();
|
||||||
|
let hardButtonState = 0;
|
||||||
|
MqttDispatcher_1.mqttHandler.register(['dispatcher_ng/items/Gnd/Flur/HardButtonState/NextState'], (topic, payload) => {
|
||||||
|
switch (hardButtonState) {
|
||||||
|
case 0:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 1;
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 2;
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 0;
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
hardButtonState = 0;
|
||||||
|
}
|
||||||
|
switch (hardButtonState) {
|
||||||
|
case 0:
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/DayLight/state', 'OFF');
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/EcoLight/state', 'OFF');
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/DayLight/state', 'ON');
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/EcoLight/state', 'OFF');
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/DayLight/state', 'OFF');
|
||||||
|
MqttDispatcher_1.mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/EcoLight/state', 'ON');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}, () => { });
|
||||||
let testDimmerAdaptor = new DimmerAdaptor_1.DimmerAdaptor('Gnd', 'Flur', 'Testlight');
|
let testDimmerAdaptor = new DimmerAdaptor_1.DimmerAdaptor('Gnd', 'Flur', 'Testlight');
|
||||||
testDimmerAdaptor.start();
|
testDimmerAdaptor.start();
|
||||||
let testTimerAdaptor = new TimerAdaptor_1.TimerAdaptor('Gnd', 'Flur', 'DeskLight', 10);
|
let testTimerAdaptor = new TimerAdaptor_1.TimerAdaptor('Gnd', 'Flur', 'DeskLight', 10);
|
||||||
@ -477,7 +522,36 @@ let watchdogTimer = setInterval(() => {
|
|||||||
watchdogCounter += 1;
|
watchdogCounter += 1;
|
||||||
MqttDispatcher_1.mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`);
|
MqttDispatcher_1.mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`);
|
||||||
}, config.dict.watchdogInterval);
|
}, 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 = {};
|
let roomSwitches = {};
|
||||||
allLights.forEach((item) => {
|
allLights.forEach((item) => {
|
||||||
let switchItem = { 'label': item.getLabel(), 'actionTopic': item.getStateTopic(), 'feedbackTopic': item.getStateFeedbackTopic() };
|
let switchItem = { 'label': item.getLabel(), 'actionTopic': item.getStateTopic(), 'feedbackTopic': item.getStateFeedbackTopic() };
|
||||||
|
@ -46,7 +46,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
|||||||
this.deviceFeedbackTopic
|
this.deviceFeedbackTopic
|
||||||
]
|
]
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
this.oldState = undefined
|
|
||||||
this.type = type
|
this.type = type
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +58,10 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
|||||||
case this.stateTopic:
|
case this.stateTopic:
|
||||||
this.state = payload
|
this.state = payload
|
||||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||||
if (this.state != this.oldState) {
|
if (this.state == 'ON') {
|
||||||
if (this.state == 'ON') {
|
mqttHandler.send(this.actionTopic, 'true')
|
||||||
mqttHandler.send(this.actionTopic, 'true')
|
} else {
|
||||||
} else {
|
mqttHandler.send(this.actionTopic, 'false')
|
||||||
mqttHandler.send(this.actionTopic, 'false')
|
|
||||||
}
|
|
||||||
this.oldState = this.state
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case this.deviceFeedbackTopic:
|
case this.deviceFeedbackTopic:
|
||||||
@ -74,7 +70,6 @@ export class HomematicSwitchItem extends AHomegearItem implements HasStateAndFee
|
|||||||
} else {
|
} else {
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
}
|
}
|
||||||
this.oldState = this.state
|
|
||||||
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
mqttHandler.send(this.stateFeedbackTopic, this.state)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd
|
|||||||
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
|
||||||
this.actionTopic = 'IoT/Mqtt433Gateway/Message'
|
this.actionTopic = 'IoT/Mqtt433Gateway/Message'
|
||||||
this.state = 'OFF'
|
this.state = 'OFF'
|
||||||
this.oldState = undefined
|
|
||||||
this.onCode = onCode
|
this.onCode = onCode
|
||||||
this.offCode = offCode
|
this.offCode = offCode
|
||||||
this.type = type
|
this.type = type
|
||||||
@ -54,13 +53,10 @@ export class M433SwitchItem extends AItem implements HasStateAndFeedbackTopicAnd
|
|||||||
processMessage(topic: string, payload: string) {
|
processMessage(topic: string, payload: string) {
|
||||||
this.state = payload;
|
this.state = payload;
|
||||||
mqttHandler.send(this.stateFeedbackTopic, this.state);
|
mqttHandler.send(this.stateFeedbackTopic, this.state);
|
||||||
if (this.state != this.oldState) {
|
if (this.state == 'ON') {
|
||||||
if (this.state == 'ON') {
|
mqttHandler.send(this.actionTopic, this.onCode);
|
||||||
mqttHandler.send(this.actionTopic, this.onCode);
|
} else {
|
||||||
} else {
|
mqttHandler.send(this.actionTopic, this.offCode);
|
||||||
mqttHandler.send(this.actionTopic, this.offCode);
|
|
||||||
}
|
|
||||||
this.oldState = this.state;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
90
src/main.ts
90
src/main.ts
@ -496,13 +496,59 @@ mySwitchThingWolfgang.start()
|
|||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
let testFourButton = new HomematicFourButtonThing('Gnd', 'Flur', 'TestButton', 9, [
|
let hardButton = new HomematicFourButtonThing('Gnd', 'Flur', 'HardButton', 9, [
|
||||||
new HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/Testlight/dimmerIn'),
|
new HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/HardButtonState/NextState'),
|
||||||
new HomematicFourButtonSingleItem('dispatcher_ng/items/Gnd/Flur/DeskLight/timerIn'),
|
new HomematicFourButtonSingleItem('test/button/2'),
|
||||||
new HomematicFourButtonSingleItem('test/button/3'),
|
new HomematicFourButtonSingleItem('test/button/3'),
|
||||||
new HomematicFourButtonSingleItem('test/button/4')
|
new HomematicFourButtonSingleItem('test/button/4')
|
||||||
])
|
])
|
||||||
testFourButton.start()
|
hardButton.start()
|
||||||
|
|
||||||
|
let hardButtonState : number = 0
|
||||||
|
mqttHandler.register(['dispatcher_ng/items/Gnd/Flur/HardButtonState/NextState'],
|
||||||
|
(topic: string, payload: string) : void => {
|
||||||
|
switch (hardButtonState) {
|
||||||
|
case 0:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 1
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 2
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
if (payload == 'SHORT') {
|
||||||
|
hardButtonState = 0
|
||||||
|
}
|
||||||
|
if (payload == 'LONG_END') {
|
||||||
|
hardButtonState = 0
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
hardButtonState = 0
|
||||||
|
}
|
||||||
|
switch (hardButtonState) {
|
||||||
|
case 0:
|
||||||
|
mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/AllLights/state', 'OFF')
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/DayLight/state', 'ON')
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
mqttHandler.send('dispatcher_ng/items/Gnd/Szenen/EcoLight/state', 'ON')
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}, () => {})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let testDimmerAdaptor = new DimmerAdaptor('Gnd', 'Flur', 'Testlight')
|
let testDimmerAdaptor = new DimmerAdaptor('Gnd', 'Flur', 'Testlight')
|
||||||
testDimmerAdaptor.start()
|
testDimmerAdaptor.start()
|
||||||
@ -597,7 +643,41 @@ 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 = {}
|
let roomSwitches: any = {}
|
||||||
allLights.forEach((item: HasStateAndFeedbackTopicAndLabelAndRoom) => {
|
allLights.forEach((item: HasStateAndFeedbackTopicAndLabelAndRoom) => {
|
||||||
|
Reference in New Issue
Block a user