Homeyscript Homey.flowToken.getFlowToken value is undefined

Hello,

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.

console.log(‘\n-------------TOKENS----------’);
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: