Homeyscript functionality

I posted the question on GitHub as well and this is Jeroen Wienk’s answer. I thought good to share here because “there are many ways to do this’ :grinning: and because as Jeroen mentioned values are cached and he gives the solution to circumvent this.

It’s possible with the API but it’s not a very clear solution since the values are cached. But you can do this;

await tag('my-tag', false);

// value is false
console.log(await Homey.flowToken.getFlowToken({
  uri: 'homey:app:com.athom.homeyscript',
  id: 'my-tag'
}));

await tag('my-tag', true);

// value is false (cached)
console.log(await Homey.flowToken.getFlowToken({
  uri: 'homey:app:com.athom.homeyscript',
  id: 'my-tag'
}));

// value is true (skipped cache)
console.log(await Homey.flowToken.getFlowToken({
  $skipCache: true,
  uri: 'homey:app:com.athom.homeyscript',
  id: 'my-tag'
}));

Notice the last call with $skipCache.

So apparently it depends on the use case if you want to call the value between multiple executions or call the value you just updated within the script.

6 Likes