athombv / homey-web-api-issues

This issue tracker is for Homey Developers using the Web API.
4 stars 1 forks source link

setCapabilityValue with duration option does not acknowledge duration option #55

Open srussvoll opened 4 months ago

srussvoll commented 4 months ago

Calling the setCapabilityValue function as follows:

await Homey.devices.setCapabilityValue({
  deviceId: '[...]',
  capabilityId: 'dim',
  value: 1,
  opts: { duration: 10000 }
});

makes the light dim to 100 % immediately, not honoring the 10s duration option. The specific device I'm using is a Philips Hue White and Color with the Philips Hue without the bridge app as the driver. Checking the source code for that app, the duration option should be honored, which leads me to believe there is a bug in the setCapabilityValue function.


On a side note, running the corresponding flow card using the Web API works:

await this.webApi.flow.runFlowCardAction({
  id: `homey:device:[...]:dim`,
  uri: `homey:flowcardaction:homey:device:[...]:dim`,
  args: { dim: 1 },
  duration: 10,
});

How is the flow card implemented? What happens if a light does not support the "duration" capability option? Will the duration option simply not be honored, or is the flow card implementation able to detect this and not expose the duration option?

I'm currently running the runFlowCardAction function as a workaround. It is running inside an app on the Homey Pro, but the token I get from this.homey.api.getOwnerApiToken() does not have the scopes necessary to perform the runFlowCardAction call, so I have to use a token created in the Homey Web App, which is not ideal. Is there a way to get a token that has the necessary scopes directly from the app using the SDK? I noticed that if I change my app's name to "com.athom.homeyscript" I get a token with the scopes I need... Am I right in assuming that this behavior is reserved for Athom authored apps only?