Homeyscript Homey.flowToken.getFlowToken value is undefined


I’m new to homey pro and recently was playing around with HomeyScript. I have the new Homey Pro (2023) and I have trouble getting the values from my devices.

When I try to get my devices (even if it is in a loop or one specific device) the value stays undefined and I have no clue why. This script works perfectly on my friend’s old Homey Pro.

I was wondering if this is a bug in the new Homey Pro or if I’m doing something wrong?

Below is an example of what is returned. I redacted some ID’s for security purposes:

t {
__athom_api_type: ‘HomeyAPI.ManagerFlowToken.FlowToken’,
id: ‘measure_temperature’,
ownerId: ‘measure_temperature’,
ownerUri: ‘homey:device:ID’,
ownerName: ‘Weerstation’,
type: ‘number’,
title: ‘Temperature’,
example: null,
uri: ‘homey:device:ID’,
uriObj: { name: ‘Weerstation’ },
value: undefined

Thank you for your help!

What do you mean by “values from my devices”? Capability values?

If so, why is it showing a flow token?

Also, you’d probably get more responses if you post your actual code rather than just its output.

At my friend’s homey it shows some information from the specific token. In this case it should show the current temperature from the Weerstation under the Value variable in the object.

Please find the code below. The loop is to run through all existing tokens and show some information (including the value of each token). the second piece of code is one specific token. Both return undefined under the value variable.
again, the unique identifier in the uri is removed. I’m not sure if this is needed but I’d rather be safe.

let tokens = await Homey.flowToken.getFlowTokens();
_.forEach(tokens, token => {
console.log(‘uri: ’ + token.uri + ’ - id: ’ + token.id)
console.log(‘uriObj.name: ’ + token.uriObj.name + ’ - ’ + ‘Title: ’ + token.title + ’ Value => (’ + token.value +’)’);

console.log(await Homey.flowToken.getFlowToken({
uri: ‘homey:device:ID’,
id: ‘measure_temperature’

Edit: An image of the second console.log output in the foreach

It doesn’t make sense to use flow tokens for that, just read the device data directly:

const device = await Homey.devices.getDevice({ id : 'THE_DEVICE_ID' });
console.log( device.capabilitiesObj?.measure_temperature?.value );

Thank you! That works indeed :slight_smile:

I need a Token that is produced by another HomeyScript, so it is not available via a Device.

Well now, whenever I print the tokens on my old Homey 2016:

let tokens = await Homey.flowToken.getFlowTokens();
_.forEach(tokens, token => {
       console.log(token.title+': '+token.value);

It neatly returns all keys and values…

Helderheid: 0.04
Datum: 20-06-2023
Tijd: 21:54
Zonsopkomst: 05:11
Zonsondergang: 22:05
Weer: Gematigde Regen

…whereas my brand-spanking-new Homey Pro 2023 renders all values as ‘undefined’ just like Bananamoon’s statement above.

I have the same problem. Does anyone know a solution yet?

await tag('TestTagTitle', 'TestTagValue'); 

let flowTokens = await Homey.flowToken.getFlowTokens();

for (const flowToken of Object.values(flowTokens)) {
  if (flowToken.uri == 'homey:app:com.athom.homeyscript' 
      && flowToken.title == 'TestTagTitle') {
     log('flowToken.title: ' + flowToken.title + '; flowToken.value: ' + flowToken.value)

flowToken.title: TestTagTitle; flowToken.value: undefined