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