Homey Community Forum

HomeyScript App

thanks Volkov now I just need to understand it I got an error because of measure null and after put in a consol log I found that it was two unit that diden’t exist in reality it had a problem with.
question how can one found out the capoability of a device?
for examle as simple as temp on a xiaomi device.

You should have all the capabilities with their current values in device.capabilitiesObj. Try to log that to the console for your device and you will see the values.

A device that is not ready will not have a capabilitiesObj and can very well cause the error.

Now it feels a lot better a real jumpstart to get all capabilities. thanks for a fast response.
add my smsall program that list all devices capabilities
// list capabilityes
let devices = await Homey.devices.getDevices();

Object.values(devices).forEach(device => {
//write out name of device and all the capabilities
console.log(device.name, device.capabilitiesObj);
});

To use logic variabels you use code like this
let Logic = await Homey.logic.getVariables()
console.log(Logic);

updateVariable

await Homey.logic.updateVariable({id: yourid, variable: yourVar})

You have access to the API https://developer.athom.com/docs/api
so Homey.whatyouwannareach gives alot of options. send me a question if you need more help.

1 Like

How do I get the id if I only know the name of the variable?

Use get function and console log it. That will give you the I’d

let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {
console.log(device.name, ’ ',device.id);
});

This is for devices. Need this for logic variables.

@gagga Sorry, I did not read well, but how about this:

Did you try this?

Or go to: https://developer.athom.com/tools/api-playground
and add a new line: Homey.logic.getVariables(); and press Run :blush:

1 Like

Hi.

Does the HomeyScript “Run a script with an argument” (in Flow) support passing multiple arguments or only one?

Thank you.

Have a look at the old forum, if I remember well, there was an example:

I can get the id this way.
I also need to get a bunch of variables by their NAME. Any idea how to get the variable Id from a call to getVariables();?

All I know is from reading and copy - past the examples on this forum and the old forum, search, combine, test and get wiser.

Hi, any chance to explain or even better provide an example of how to use/modify this await Homey.logic.updateVariable({id: yourid, variable: yourVar})?

I have add the ID: something like dfb4ab9b-c711-4… but I do not know, how to modify the variable parametr…

If I add variable=“xy” I get An unkown error has occured [invalid_json]
If I try to add params inside the variable such name, value etc… I get You have no access to do this.

Thank you very much, M