Where to find device capability type (number / boolean / text)

(did not find from earlier topics, so here we go…)

Tried to look field where type for each value would be defined in JSON of

const devices = await Homey.devices.getDevices();

On AVDs I can get it with (not the same for others devices)

let targetType = (capability.split(‘.’).pop()).replace(/[0-9]/g, ‘’);

Of can I only use “Try / error” method (by modifying below code) e.g. when writing value 0/1 and error should re-write as FALSE/TRUE due:

  • I know only device name but not its type (as user changeable)
  • My source values are text and numbers (where also 0/1 could be also boolean) )
      try {
        await device.setCapabilityValue(capability.id, newValue);
        return newValue; // Indicate the value has been updated
      } catch (error) {
        console.error("Failed to update value:", error);
        return -999.3; // Indicate update failure
      }

(to close the loop, will reply to self as) found it, while hard to understand why I missed it earlier :face_with_raised_eyebrow:

const devices = await Homey.devices.getDevices();

// Loop over all devices
for (const device of Object.values(devices)) {
if (device.name !== targetDevice) continue;

for (const [capability, capabilityObj] of Object.entries(device.capabilitiesObj)) {

  var {id, type, title, min, max, step, units, decimals, value, lastUpdated } = capabilityObj;

…etc…