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

**URL:** <https://community.homey.app/t/where-to-find-device-capability-type-number-boolean-text/115256>\
**Category:** Questions & Help\
**Tags:** homeyscript\
**Created:** [August 31, 2024, 6:19am UTC](https://community.homey.app/t/where-to-find-device-capability-type-number-boolean-text/115256 "2024-08-31T06:19:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eko\_taas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eko_taas/32/74256_2.png) [@Eko\_taas](https://community.homey.app/u/Eko_taas)\
**Post date:** [August 31, 2024, 6:19am UTC](https://community.homey.app/t/where-to-find-device-capability-type-number-boolean-text/115256/1 "2024-08-31T06:19:07Z")

</div>

(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
      }

```

---

<div class="post-metadata">

**Author:** ![Eko\_taas](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/eko_taas/32/74256_2.png) [@Eko\_taas](https://community.homey.app/u/Eko_taas)\
**Post date:** [September 14, 2024, 5:32am UTC](https://community.homey.app/t/where-to-find-device-capability-type-number-boolean-text/115256/2 "2024-09-14T05:32:26Z")

</div>

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

> 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…
