Files
dispatcher_ng/dist/Export.js
Wolfgang Hottgenroth 32a57408d9 change kitchen heating
2018-01-25 16:00:43 +01:00

96 lines
3.2 KiB
JavaScript

"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) {
return { 'homekit': ThermostatHomekitExport(itemId, label, temperatureTopic, temperatureFeedbackTopic), 'openhab': '' };
}
exports.ThermostatExport = ThermostatExport;
function ContactExport(itemId, label, status) {
return { 'homekit': ContactHomekitExport(itemId, label, status), 'openhab': '' };
}
exports.ContactExport = ContactExport;
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} {mqtt=">[localbroker:${setOn}:command:*:default],<[localbroker:${statusOn}:state:default]"}`;
}
//# sourceMappingURL=Export.js.map