I just started dabbling in HomeyScript, and am quite new to JavaScript (fortunately I have some background in C and Python to help me along) but I came upon an issue with the setCapabilityValue function.
Essentially, I’m trying to set the Hue of a light over a certain duration. I notice that the setCapabilityValue function has an option ‘duration’, so I call the function as follows:
But when the light changes hue, it does so instantly (i.e. it doesn’t gradually change the hue over the defined time). When I try the similar thing with a Flow card, it works perfectly (but for my purposes I would really like to do it within a homeyscript, as it allows me to combine 8 or more flows into one script…)
I’m not sure whether I’m supposed to provide this duration in milliseconds (as example) or as seconds, or whether I am wrong in any case to just provide the argument as an integer (maybe I have to generate some special Options Object or something?) Device - Homey Web API
In that case it’s likely that the documentation just isn’t correct. The SDK method to set a capability value doesn’t have a duration either, and I would think the Web API uses that method under the hood.
Thanks for the info on the time unit!
It still doesn’t work though
I’m somehow convinced it should be possible to do, as there as a simple flow action card that allows for this. Can I perhaps simply trigger this flow card from within homeyscript? It seems like a terrible workaround, but if it works…
Essentially I would then need a way to retrieve the action cards coupled to a given device, and launch one of those cards…
Of course, it would still be best if the duration option actually worked
No, SDK is using seconds too I believe, or is it just a facade in the app and web app that only seconds can be used.
But now thinking about the setCapabilityValue in Homeyscript isn’t possible anyway as it doesn’t have the rights to do so, triggering the action card will be the only way.
Hm Sounds strange to me as I would think the action card uses some type of SDK or similar under the hood as well?
Anyway, could you then help me along with an example on how to obtain and launch the action cards matching a given device id or name? I looks at the example script where all flow cards are listed, but I can’t figure out an efficient way of finding a particular flow card selectively for a given device. I’ll keep looking, but perhaps you experts simply know already