several quick fixes

This commit is contained in:
Wolfgang Hottgenroth
2018-06-03 21:50:40 +02:00
parent ea04fae523
commit 718ac667d1
8 changed files with 39 additions and 31 deletions

16
dist/UrlSwitchItem.js vendored
View File

@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logger = require("./log");
const MqttDispatcher_1 = require("./MqttDispatcher");
const AItem_1 = require("./AItem");
const Export_1 = require("./Export");
@ -30,13 +31,18 @@ class UrlSwitchItem extends AItem_1.AItem {
this.state = payload;
MqttDispatcher_1.mqttHandler.send(this.stateFeedbackTopic, this.state);
if (this.state != this.oldState) {
if (this.state == 'ON') {
http.get(this.onUrl);
try {
if (this.state == 'ON') {
http.get(this.onUrl);
}
else {
http.get(this.offUrl);
}
this.oldState = this.state;
}
else {
http.get(this.offUrl);
catch (_a) {
logger.error(`Failed to handle ${this.onUrl} or ${this.offUrl}`);
}
this.oldState = this.state;
}
}
}