Files
dispatcher_ng/dist/Export.js
2018-04-03 00:25:59 +02:00

151 lines
6.4 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': ThermostatOpenHAPExport(itemId, label, temperatureTopic, temperatureFeedbackTopic) };
}
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 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]"}`);
});
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) {
return `Number ${id} "${label}" {mqtt=">[localbroker:${setTemperature}:command:*:default],<[localbroker:${statusTemperature}:state:default]"}`;
}
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