[APP][Pro] HomeyScript

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


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: Homey Developer Tools
and add a new line: Homey.logic.getVariables(); and press Run :blush:

1 Like


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.

1 Like

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

Why will this script doens’t disable all my Apps as a test?

// Restart apps in case of crash

let apps = await Homey.apps.getApps();
crash = false;

_.forEach(apps, app => {

//For test
Homey.apps.disableApp({id: app.id});
//End test

if(app.crashed == false) return;
console.log("App crashed, restart...");
crash = true;



return crash;

Here’s is some code that might help other diggers for data. especially the retrieving of tokens (which also contain Better Logic variables) which syntax is changed in the past (Homey 2.0?). It’s only outputting the names (To quickly see the contents), but if you want to see the complete object with all the data, uncomment the console log code:

// Log everything

let apps = await Homey.apps.getApps();
_.forEach(apps, app => {

let tokens = await Homey.flowToken.getFlowTokens();
_.forEach(tokens, token => {
       console.log(token.title+': '+token.value);

let devices = await Homey.devices.getDevices();
_.forEach(devices, device => {

let flows = await Homey.flow.getFlows();
_.forEach(flows, flow => {

let zones = await Homey.zones.getZones();
_.forEach(zones, zone => {

let logics = await Homey.logic.getVariables()
_.forEach(logics, logic => {


I cannot get the https://homeyscript.homey.app/ page to work. I says “Homey offline” while my Homey is definitely online! The page gives the following error in the console:
Failed to load resource: the server responded with a status of 401 ()

The sample scripts do not appear on the screen, but they can be selected in flows. However, the ones that are supposed to log to the console, don’t log to the console.

Am I missing something?

Log out and log back in again?

Thanks, worked! I feel a little stupid…