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

View File

@ -44,12 +44,16 @@ export class UrlSwitchItem extends AItem implements HasStateAndFeedbackTopic {
this.state = payload;
mqttHandler.send(this.stateFeedbackTopic, this.state);
if (this.state != this.oldState) {
try {
if (this.state == 'ON') {
http.get(this.onUrl,)
} else {
http.get(this.offUrl)
}
this.oldState = this.state;
} catch {
logger.error(`Failed to handle ${this.onUrl} or ${this.offUrl}`)
}
}
}
}

View File

@ -131,9 +131,9 @@ allRelevantLights.push(diningRoomCupboardLight)
// Esszimmer Regallicht
let diningRoomShelfLight = new UrlSwitchItem('Gnd', 'DiningRoom', 'ShelfLight', 'Regallicht Esszimmer', 'http://172.16.2.43/dv?dv=1023', 'http://172.16.2.43/dv?dv=0')
diningRoomShelfLight.start()
allLabeledItems.push(diningRoomShelfLight)
allRelevantLights.push(diningRoomShelfLight)
// diningRoomShelfLight.start()
// allLabeledItems.push(diningRoomShelfLight)
// allRelevantLights.push(diningRoomShelfLight)
let diningRoomNaehkaestchenLight = new HueColorBulbItem('Gnd', 'DiningRoom', 'NaehkaestchenLight', 'Lampe Naehkaestchen', 15)
diningRoomNaehkaestchenLight.start()
@ -553,6 +553,13 @@ let heartbeatTimer = setInterval(() => {
mqttHandler.send(config.dict.heartbeatTopic, `${heartbeatCounter}`)
}, config.dict.heartbeatInterval)
// watchdog
let watchdogCounter = 0
let watchdogTimer = setInterval(() => {
watchdogCounter += 1
mqttHandler.send(config.dict.watchdogTopic, `${config.dict.watchdogMessage} ${watchdogCounter}`)
}, config.dict.watchdogInterval)