add all existing items, homekit export

This commit is contained in:
Wolfgang Hottgenroth
2018-01-10 14:15:43 +01:00
parent 153b8570e4
commit 8a6547ff91
20 changed files with 746 additions and 42 deletions

View File

@ -1,7 +1,7 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { AHomematicItem } from './AHomematicItem'
import { SwitchHomekitExport, HomekitExportType } from './Export'
export class HomematicSwitchItem extends AHomematicItem {
private oldState: string|undefined
@ -10,9 +10,10 @@ export class HomematicSwitchItem extends AHomematicItem {
private deviceFeedbackTopic: string
private stateFeedbackTopic: string
private stateTopic: string
private type: string
constructor(floor: string, room: string, item: string, hmId: number) {
super(floor, room, item, hmId)
constructor(floor: string, room: string, item: string, label: string, hmId: number, type: string = 'bulb') {
super(floor, room, item, label, hmId)
this.stateTopic = `${this.topicFirstPart}/state`
this.stateFeedbackTopic = `${this.topicFirstPart}/state/feedback`
this.deviceFeedbackTopic = `${this.deviceTopicPre}/1/STATE`
@ -23,8 +24,12 @@ export class HomematicSwitchItem extends AHomematicItem {
]
this.state = 'OFF'
this.oldState = undefined
this.type = type
}
exportHomekit() : HomekitExportType {
return SwitchHomekitExport(this.itemId, this.label, this.stateTopic, this.stateFeedbackTopic, this.type)
}
processMessage(topic: string, payload: string) : void {
switch (topic) {