I have a HomeyScript that sets/updates three tags. This script is then run in Advanced Flows, before assigning the three tags to three separate virtual devices.
Lately, I have noticed that the tags are not really updated. It feels like the tags are cached in some weird way.
Therefore, I have decided to first delete the tags in my script, and after that create them again. Result? My virtual devices are now always updated correctly.
await tag('Tibber-todays-sold-electricity-kr', null);
await tag('Tibber-todays-sold-electricity-kwh', null);
await tag('Tibber-todays-sold-electricity-updatetime', null);
await wait(500);
await tag('Tibber-todays-sold-electricity-kr', totalProfit);
await tag('Tibber-todays-sold-electricity-kwh', totalProduction);
await tag('Tibber-todays-sold-electricity-updatetime', latestUpdateTime);
So far, so good, but now the script sometimes throws an error:
A FlowToken with ID homey:app:com.athom.homeyscript:Tibber-todays-sold-electricity-kr already exists.
The script runs every hour, and it might happen once per day.
Any idea why and how I can prevent it from happening?