Hi,
I’m trying to create my first homeyscript. I do have experience in programming but not in JavaScript, and I can’t wrap my head around this, in my opinion, very simple problem.
I have this Hue light, and I want to make a script that switches the light on when it’s off, and vice versa.
The switching on/off part is working, but getting the current state is the problem.
This is what I have:
let LightID = '1d81d3cd-f3ec-4025-8210-4cb930004577';
var MyLight = await Homey.devices.getDevice({ id: LightID });
await MyLight.setCapabilityValue('onoff', true);
I tried to read the onoff property in different ways (I found browsing scripts on this forum), but all below are not working (“is not a function” error):
MyLight.CapabilitiesObj.onoff.value
MyLight.getCapabilityValue('onoff')
MyLight.state.onoff
If anybody can help me get on my way, I’d most appreciate it!