Device vs homey.devices

Hi.
I find a Device object from it’s name, via Homey.devices.getDevices(). The object variable I call “device”. It is a switch which I would like to toggle.
Now, if I use

device.setCapabilityValue({
    capabilityId: 'onoff',
    value: true,
  });

it does not turn on, but if I use

 Homey.devices.setCapabilityValue({
    deviceId: device.id, //same object as above
    capabilityId: 'onoff',
    value: true
  });

it works just fine. What is this newbie doing wrong?
1 Like