"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function SwitchExport(itemId, label, stateTopic, stateFeedbackTopic, type) { let homekitOut; switch (type) { case 'bulb': homekitOut = SwitchHomekitBulbExport(itemId, label, stateTopic, stateFeedbackTopic); break; case 'outlet': homekitOut = SwitchHomekitOutletExport(itemId, label, stateTopic, stateFeedbackTopic); break; default: throw new Error(`no homekit export function for type ${type}`); } let openhabOut = SwitchOpenHABExport(itemId, label, stateTopic, stateFeedbackTopic); return { 'homekit': homekitOut, 'openhab': openhabOut }; } exports.SwitchExport = SwitchExport; function ThermostatExport(itemId, label, temperatureTopic, temperatureFeedbackTopic, presetTemperatureTopic, presetTemperatureFeedbackTopic) { return { 'homekit': ThermostatHomekitExport(itemId, label, temperatureTopic, temperatureFeedbackTopic), 'openhab': ThermostatOpenHAPExport(itemId, label, temperatureTopic, temperatureFeedbackTopic, presetTemperatureTopic, presetTemperatureFeedbackTopic) }; } exports.ThermostatExport = ThermostatExport; function ContactExport(itemId, label, status) { return { 'homekit': ContactHomekitExport(itemId, label, status), 'openhab': ContactOpenHABExport(itemId, label, status) }; } exports.ContactExport = ContactExport; function HueColorLightExport(itemId, label, stateTopic, stateFeedbackTopic, brightnessTopic, brightnessFeedbackTopic, hueTopic, hueFeedbackTopic, saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic) { return { 'homekit': HueColorLightHomekitExport(itemId, label, stateTopic, stateFeedbackTopic, brightnessTopic, brightnessFeedbackTopic, hueTopic, hueFeedbackTopic, saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic), 'openhab': '' }; } exports.HueColorLightExport = HueColorLightExport; function RelayBoxExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) { return { 'homekit': RelayBoxHomekitExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames), 'openhab': RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) }; } exports.RelayBoxExport = RelayBoxExport; function HeatingMainSwitchExport(topic) { return { 'homekit': { 'id': '', 'object': {} }, 'openhab': `Switch HeatingMainSwitch "Heizung Hauptschalter" {mqtt=">[localbroker:${topic}:command:*:default],<[localbroker:${topic}:state:default]"}` }; } exports.HeatingMainSwitchExport = HeatingMainSwitchExport; function RelayBoxHomekitExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) { return { 'id': '', 'object': {} }; } function RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) { let o = []; itemNames.forEach((label, index) => { o.push(`Switch ${itemId}${index} "${label}" {mqtt=">[localbroker:${stateTopicPre}/${index}:command:*:default],<[localbroker:${feedbackTopicPre}/${index}:state:default]"}`); o.push(`String ${itemId}${index}Conflict "${label} [%s]" {mqtt="<[localbroker:${conflictTopicPre}/${index}:state:default]"}`); }); return o; } function SwitchHomekitBulbExport(id, label, setOn, statusOn) { let o = { "id": id, "name": label, "service": "Lightbulb", "topic": { "setOn": setOn, "statusOn": statusOn }, "payload": { "onTrue": "ON", "onFalse": "OFF", "brightnessFactor": "", "hueFactor": "", "saturationFactor": "" }, "config": {} }; return { 'id': id, 'object': o }; } function SwitchHomekitOutletExport(id, label, setOn, statusOn) { let o = { "id": id, "name": label, "service": "Outlet", "topic": { "setOn": setOn, "statusOn": statusOn }, "payload": { "onTrue": "ON", "onFalse": "OFF" }, "config": {} }; return { 'id': id, 'object': o }; } function ThermostatHomekitExport(id, label, setTemperature, statusTemperature) { let o = { "id": id, "name": label, "service": "Thermostat", "topic": { "setTargetTemperature": setTemperature, "statusTargetTemperature": statusTemperature, "statusCurrentTemperature": statusTemperature }, "payload": {} }; return { 'id': id, 'object': o }; } function ContactHomekitExport(id, label, status) { let o = { "id": id, "name": label, "service": "ContactSensor", "topic": { "statusContactSensorState": status }, "payload": { "onContactDetected": "CLOSED" } }; return { 'id': id, 'object': o }; } function SwitchOpenHABExport(id, label, setOn, statusOn) { // Switch windowLightKitchen {mqtt=">[localbroker:nodered/items/windowLightKitchen:command:*:default]", mqtt="<[localbroker:nodered/items/windowLightKitchen/feedback:state:default]"} return `Switch ${id} "${label}"{mqtt=">[localbroker:${setOn}:command:*:default],<[localbroker:${statusOn}:state:default]"}`; } function ContactOpenHABExport(id, label, status) { // Switch windowLightKitchen {mqtt=">[localbroker:nodered/items/windowLightKitchen:command:*:default]", mqtt="<[localbroker:nodered/items/windowLightKitchen/feedback:state:default]"} return `Contact ${id} "${label}" {mqtt="<[localbroker:${status}:state:default]"}`; } function ThermostatOpenHAPExport(id, label, setTemperature, statusTemperature, presetTemperature, presetStatusTemperature) { let o = []; o.push(`Number ${id} "${label} [%.1f °C]" {mqtt=">[localbroker:${setTemperature}:command:*:default],<[localbroker:${statusTemperature}:state:default]"}`); o.push(`Number Preset_${id} "Preset_${label} [%.1f °C]" {mqtt=">[localbroker:${presetTemperature}:command:*:default],<[localbroker:${presetStatusTemperature}:state:default]"}`); return o; } function HueColorLightHomekitExport(id, label, stateTopic, stateFeedbackTopic, brightnessTopic, brightnessFeedbackTopic, hueTopic, hueFeedbackTopic, saturationTopic, saturationFeedbackTopic, colorTemperatureTopic, colorTemperatureFeedbackTopic) { let o = { "id": id, "name": label, "service": "Lightbulb", "manufacturer": "hue2mqtt - Hue", "model": "color light", "topic": { "setOn": stateTopic, "statusOn": stateFeedbackTopic, "setBrightness": brightnessTopic, "statusBrightness": brightnessFeedbackTopic, "setHue": hueTopic, "statusHue": hueFeedbackTopic, "setSaturation": saturationTopic, "statusSaturation": saturationFeedbackTopic, "setColorTemperature": colorTemperatureTopic, "statusColorTemperature": colorTemperatureFeedbackTopic }, "payload": { "onTrue": "ON", "onFalse": "OFF", "brightnessFactor": 1, "hueFactor": 1, "saturationFactor": 1 } }; return { 'id': id, 'object': o }; } //# sourceMappingURL=Export.js.map