export relaybox
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user