resolved issue with not connect error msg

This commit is contained in:
Marcus Westin 2019-12-13 13:32:05 +01:00
parent bb1b53d4ff
commit a79f1ca62c
2 changed files with 18 additions and 12 deletions

12
main.js
View file

@ -41,20 +41,20 @@ async function main() {
});
// subscribe to changes from HA
client.on('stateChanged', (deviceId, state) => {
client.on('stateChanged', async (deviceId, state) => {
if (state) {
controller.turnOn(deviceId);
await controller.turnOn(deviceId);
}
else {
controller.turnOff(deviceId);
await controller.turnOff(deviceId);
}
});
client.on('brightnessChanged', (deviceId, brightness) => {
client.on('brightnessChanged', async (deviceId, brightness) => {
if (brightness > 0) {
controller.turnOn(deviceId, brightness);
await controller.turnOn(deviceId, brightness);
}
else {
controller.turnOff(deviceId);
await controller.turnOff(deviceId);
}
});