several quick fixes
This commit is contained in:
16
dist/UrlSwitchItem.js
vendored
16
dist/UrlSwitchItem.js
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user