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,26 +1,37 @@
import * as logger from './log'
import { mqttHandler } from './MqttDispatcher'
import { HomekitExportType } from './Export'
export abstract class AItem {
protected topicFirstPart: string
protected itemId: string
protected label: string
private item: string
private room: string
private floor: string
protected subscribeTopics: string[]
constructor(floor: string, room: string, item: string) {
constructor(floor: string, room: string, item: string, label: string = '') {
this.floor = floor
this.room = room
this.item = item
this.itemId = `${this.floor}.${this.room}.${this.item}`
if (label == '') {
this.label = this.itemId
} else {
this.label = label
}
this.topicFirstPart = `dispatcher_ng/items/${this.floor}/${this.room}/${this.item}`
}
abstract processMessage(topic: string, payload: string) : void
exportHomekit() : HomekitExportType {
return {'id': this.itemId, 'object': null }
}
start() : void {
mqttHandler.register(this.subscribeTopics, (topic: string, payload: string) : void => {
logger.info(`item ${this.itemId}: ${topic}, ${payload}`)
@ -28,5 +39,3 @@ export abstract class AItem {
})
}
}