rework thermostat

This commit is contained in:
2018-04-06 23:00:41 +02:00
parent 9db2aebf09
commit 37acc620d5
9 changed files with 134 additions and 50 deletions

View File

@ -27,8 +27,8 @@ export function SwitchExport(itemId: string, label: string, stateTopic: string,
return { 'homekit': homekitOut, 'openhab': openhabOut }
}
export function ThermostatExport(itemId: string, label: string, temperatureTopic: string, temperatureFeedbackTopic: string) : ExportType {
return {'homekit': ThermostatHomekitExport(itemId, label, temperatureTopic, temperatureFeedbackTopic), 'openhab': ThermostatOpenHAPExport(itemId, label, temperatureTopic, temperatureFeedbackTopic)}
export function ThermostatExport(itemId: string, label: string, temperatureTopic: string, temperatureFeedbackTopic: string, presetTemperatureTopic: string, presetTemperatureFeedbackTopic: string) : ExportType {
return {'homekit': ThermostatHomekitExport(itemId, label, temperatureTopic, temperatureFeedbackTopic), 'openhab': ThermostatOpenHAPExport(itemId, label, temperatureTopic, temperatureFeedbackTopic, presetTemperatureTopic, presetTemperatureFeedbackTopic)}
}
export function ContactExport(itemId: string, label: string, status: string) : ExportType {
@ -145,8 +145,11 @@ function ContactOpenHABExport(id: string, label: string, status: string): string
return `Contact ${id} "${label}" {mqtt="<[localbroker:${status}:state:default]"}`
}
function ThermostatOpenHAPExport(id: string, label: string, setTemperature: string, statusTemperature: string) : string {
return `Number ${id} "${label}" {mqtt=">[localbroker:${setTemperature}:command:*:default],<[localbroker:${statusTemperature}:state:default]"}`
function ThermostatOpenHAPExport(id: string, label: string, setTemperature: string, statusTemperature: string, presetTemperature: string, presetStatusTemperature: string) : string[] {
let o : string[] = []
o.push(`Number ${id} "${label}" {mqtt=">[localbroker:${setTemperature}:command:*:default],<[localbroker:${statusTemperature}:state:default]"}`)
o.push(`Number Preset-${id} "Preset-${label}" {mqtt=">[localbroker:${presetTemperature}:command:*:default],<[localbroker:${presetStatusTemperature}:state:default]"}`)
return o
}
function HueColorLightHomekitExport(id: string, label: string,