resolved issue with not connect error msg
This commit is contained in:
parent
bb1b53d4ff
commit
a79f1ca62c
2 changed files with 18 additions and 12 deletions
12
main.js
12
main.js
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue