add summer/winter switch
This commit is contained in:
5
dist/Export.js
vendored
5
dist/Export.js
vendored
@ -33,6 +33,11 @@ function RelayBoxExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPr
|
||||
'openhab': RelayBoxOpenHABExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) };
|
||||
}
|
||||
exports.RelayBoxExport = RelayBoxExport;
|
||||
function SummerSwitchExport(summerSwitchTopic) {
|
||||
return { 'homekit': { 'id': '', 'object': {} },
|
||||
'openhab': `Switch SummerSwitch "Winter?" {mqtt=">[localbroker:${summerSwitchTopic}:command:*:default],<[localbroker:${summerSwitchTopic}:state:default]"}` };
|
||||
}
|
||||
exports.SummerSwitchExport = SummerSwitchExport;
|
||||
function RelayBoxHomekitExport(itemId, stateTopicPre, feedbackTopicPre, conflictTopicPre, itemNames) {
|
||||
return { 'id': '', 'object': {} };
|
||||
}
|
||||
|
39
dist/MaxThermostat.js
vendored
39
dist/MaxThermostat.js
vendored
@ -6,15 +6,9 @@ const AHomegearItem_1 = require("./AHomegearItem");
|
||||
const Export_1 = require("./Export");
|
||||
const DISABLED_TEMPERATURE = 5.0;
|
||||
class MaxThermostat extends AHomegearItem_1.AHomegearItem {
|
||||
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
|
||||
getInTopic() {
|
||||
return this.commandTopic;
|
||||
}
|
||||
exportItem() {
|
||||
return Export_1.ThermostatExport(this.itemId, this.label, this.temperatureTopic, this.temperatureFeedbackTopic, this.presetTemperatureTopic, this.presetTemperatureFeedbackTopic);
|
||||
}
|
||||
constructor(floor, room, item, label, hmId, hardDisablers) {
|
||||
super(floor, room, item, label, hmId);
|
||||
this.summerFlag = false;
|
||||
this.temperatureTopic = `${this.topicFirstPart}/temperature`;
|
||||
this.temperatureFeedbackTopic = `${this.topicFirstPart}/temperature/feedback`;
|
||||
this.presetTemperatureTopic = `${this.topicFirstPart}/presetTemperature`;
|
||||
@ -26,7 +20,8 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem {
|
||||
this.temperatureTopic,
|
||||
this.presetTemperatureTopic,
|
||||
this.deviceFeedbackTopic,
|
||||
this.commandTopic
|
||||
this.commandTopic,
|
||||
MaxThermostat.summerSwitchTopic
|
||||
];
|
||||
this.hardDisabled = false;
|
||||
this.hardDisablerMap = {};
|
||||
@ -35,6 +30,16 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem {
|
||||
this.hardDisablerMap[hardDisabler.getStateFeedbackTopic()] = { disabler: hardDisabler, state: 'unknown' };
|
||||
});
|
||||
}
|
||||
// Thermostat: homegear/instance1/set/3/1/SET_TEMPERATURE
|
||||
getInTopic() {
|
||||
return this.commandTopic;
|
||||
}
|
||||
exportItem() {
|
||||
return Export_1.ThermostatExport(this.itemId, this.label, this.temperatureTopic, this.temperatureFeedbackTopic, this.presetTemperatureTopic, this.presetTemperatureFeedbackTopic);
|
||||
}
|
||||
static exportSummerSwitchItem() {
|
||||
return Export_1.SummerSwitchExport(MaxThermostat.summerSwitchTopic);
|
||||
}
|
||||
setPresetTemperature(presetTemperature) {
|
||||
this.presetTemperature = presetTemperature;
|
||||
}
|
||||
@ -48,13 +53,18 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem {
|
||||
setTemperature = true;
|
||||
}
|
||||
else if (topic == this.commandTopic) {
|
||||
if (payload == 'ON') {
|
||||
this.temperature = this.presetTemperature;
|
||||
if (!this.summerFlag) {
|
||||
if (payload == 'ON') {
|
||||
this.temperature = this.presetTemperature;
|
||||
}
|
||||
else if (payload == 'OFF') {
|
||||
this.temperature = DISABLED_TEMPERATURE;
|
||||
}
|
||||
setTemperature = true;
|
||||
}
|
||||
else if (payload == 'OFF') {
|
||||
this.temperature = DISABLED_TEMPERATURE;
|
||||
}
|
||||
setTemperature = true;
|
||||
}
|
||||
else if (topic == MaxThermostat.summerSwitchTopic) {
|
||||
this.summerFlag = (payload == 'ON');
|
||||
}
|
||||
else if (topic == this.presetTemperatureTopic) {
|
||||
this.presetTemperature = parseFloat(payload);
|
||||
@ -86,5 +96,6 @@ class MaxThermostat extends AHomegearItem_1.AHomegearItem {
|
||||
}
|
||||
}
|
||||
}
|
||||
MaxThermostat.summerSwitchTopic = 'dispatcher_ng/items/summerSwitch';
|
||||
exports.MaxThermostat = MaxThermostat;
|
||||
//# sourceMappingURL=MaxThermostat.js.map
|
5
dist/main.js
vendored
5
dist/main.js
vendored
@ -310,6 +310,11 @@ allLabeledItems.forEach((item) => {
|
||||
// logger.info(JSON.stringify(openhabList))
|
||||
}
|
||||
});
|
||||
let summerSwitchExport = MaxThermostat_1.MaxThermostat.exportSummerSwitchItem();
|
||||
if (summerSwitchExport != null) {
|
||||
let da = summerSwitchExport['openhab'];
|
||||
openhabList.push(da);
|
||||
}
|
||||
fs.writeFileSync(config.dict.homekitFile, JSON.stringify(homekitObject, null, 4));
|
||||
fs.writeFileSync(config.dict.openhabItemFile, openhabList.join('\n'));
|
||||
// ----------------------------------------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user