Hi
I’m not any good at java script but have basic knowledge of Html, PHP and C++ and some understanding of python. With that said I manage to come up with a script toggling my lights, triggered by a switch in a flow.
However the issue is that it takes like 5s from I push the button until The lights change
Hardware
wall switch, brand Hue ( cabinet)
Ceiling light, brand Hue (plafond)
Wall plug, brand Fibaro double switch
Is it because bad scripting or is it because I use a flow to trigger every thing.
The next state of the script is to incorporate some logic to evaluate if it day or night.
if it night and the button is pressed only dim the ceiling to 10%
If it day turn on the wall switch and dim the ceiling to 100%
Can somebody point on the right direction?
The script so far
let plafond = await Homey.devices.getDevice({id : ‘de53b6b0-8032-4ca3-acd0-3054d9265565’});
let cabinet = await Homey.devices.getDevice({id : ‘68b5cf24-13a6-4e76-9823-cc7e9946c568’});
if (plafond.capabilitiesObj.onoff.value)
{ // Turn the light on by setting the capability onoff
to true
await plafond.setCapabilityValue(‘onoff’, false)
.then(() => log(‘OK’))
.catch(error => log(Error:
, error));
await cabinet.setCapabilityValue(‘onoff’, false)
.then(() => log(‘OK’))
.catch(error => log(Error:
, error));
} else {
// Turn the light off by setting the capability onoff
to false
await cabinet.setCapabilityValue(‘onoff’, true)
.then(() => log(‘OK’))
.catch(error => log(Error:
, error));
await plafond.setCapabilityValue(‘onoff’, true)
.then(() => log(‘OK’))
.catch(error => log(Error:
, error));
}