HomeyScript and variables

Hi,

for receiving a Bearer token I have created an HomeyScript. This script returns a variable and is saved as FSRBearerToken. I can see this variable in Homey and can use it in flows.

But now I have created another HomeyScript for collection some data and want to use this variable as well. Have tried several options but no luck. Anybody?

Tried the following:

async function run() {
  const token = await Homey.tags.getValue('FSRBearerToken');
  if (!token) throw new Error('FSRBearerToken tag empty');
  }

And use the HomeyScript card adding an argument

async function run(args) {
  const token = args.FSRBearerToken;
  if (!token) {
    throw new Error('FSRBearerToken argument missing');
  }

Using the direct token works perfectly

async function run() {
  const token = 'ACTUAL_TOKEN';
  if (!token) {
    throw new Error('Token not found');
  }

Was this code AI-generated?

@robertklep, thats correct

Figures, it just basically hallucinated code that makes no sense.

If you want to share data between scripts, the easiest way is to use get()/set().

If you really want to use tags, look here.

Thanks for this, sometimes it is a great help :blush: , but not this time.