export relaybox

This commit is contained in:
2018-04-03 00:00:42 +02:00
parent e883c9a791
commit 8350b21161
6 changed files with 109 additions and 99 deletions

View File

@ -1,6 +1,6 @@
export type ExportType = {
'homekit': HomekitExportType,
'openhab': string
'openhab': string | string[]
}
export type HomekitExportType = {
@ -46,17 +46,21 @@ export function HueColorLightExport(itemId: string, label: string,
saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic), 'openhab': ''}
}
export function RelayBoxExport(stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : ExportType {
return {'homekit': RelayBoxHomekitExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames),
'openhab': RelayBoxOpenHABExport(stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames)}
export function RelayBoxExport(itemId: string, stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : ExportType {
return {'homekit': RelayBoxHomekitExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames),
'openhab': RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames)}
}
function RelayBoxHomekitExport(stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : HomekitExportType{
function RelayBoxHomekitExport(itemId: string, stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : HomekitExportType{
return {'id': '', 'object': {}}
}
function RelayBoxOpenHABExport(stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : string {
return ''
function RelayBoxOpenHABExport(itemId: string, stateTopicPre: string, feedbackTopicPre: string, conflictTopicPre: string, itemNames: string[]) : string[] {
let o : string[] = []
itemNames.forEach((label: string, index: number) => {
o.push(`Switch ${itemId}${index} "${label} "{mqtt=">[localbroker:${stateTopicPre}/${index}:command:*:default],<[localbroker:${feedbackTopicPre}/${index}:state:default]"}`)
})
return o
}