[APP][Pro] HomeyScript

Current app version: 3.2.6 (stable)

HomeyScript App by Athom.



I want to make somewhat more complex script, but my coding skills are more “copy-paste & modify” then to build something from scratch.

Are there any way I can make a flow in Homey, and then open it in scripteditor and modify?


Hi @oPzOpZ,

On GitHub there are some examples. MAybe it will help you!
I never used it, because I don’t know something I can’t, with the available apps.

WOW, when you’ve installed the app, you could go to homeyscript.athom.com to create script. There are the same examples.

I have wrote small script to calculate dew temperature and vapour pressure based on environmental temperature and relative humidity. Now I want to set and read variables from Homey Logic, but I do not know how to do that. I have already searched the forums. Can somebody help me?

Thanks in advance.
Homey firmware 2.0.0 rc9

hi all…

after updating to 2.0, device.state.onoff is throwing an error as an unknown property.

i tried looking at the api but cant seem to find a replacement… anyone can point me in the right direction?

thanks in advance

Try device.capabilitiesObj.onoff.value

thanks. took me a long time but i found it as well. the documentation is not very good at the moment

HomeyScript uses the Web API, for which documentation can be found here. But I agree, it’s not very good.

Here’s the specific documentation for devices: https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.Device.html

thanks very much @robertklep

I have just updated to Homey 2.0 and have noticed that some of my HomeyScript scripts do not work anymore because of API changes. I could fix almost all of them with the help of the documentation, however I can one script I cannot fix: in this script I have checked the battery status of all devices. In case of low battery warnings I have set the screensaver to red and have added a notification to Homey.

Both of these do not work with 2.0:

  • The screensaver can be set with Homey.ledring.setOptionScreensaver. However, if I use this method, I only receive the error: “You have no access to do this.”
  • The notification is even more trickier, I cannot seem to find a method that corresponds to Homey.notifications.addNotification which I have used in the script.

Does anyone have an idea?

I have found a workaround - Homeyscript only sets a variable and a second flow reacts to the change of the variable and does what I need.

How do you set a variable with Homeyscript? Can’t seem to find that in the docs…

I am still using BetterLogic variables, an example script can be found in this topic: https://forum.athom.com/discussion/3666/homeyscript-share-your-scripts-main-discussion-topic/p2

(just search for “betterlogic”)

1 Like

With version 1.5 you could set a variable with setTagValue

let dayOfYear = testDay.getDayOfYear();
await setTagValue(name, {type: "number", title: "CV_On_Day"}, dayOfYear ); 

With version 2.0 you’ll receive a Script Error: Cannot set value, token is not registered

1 Like

Wait, Go in the app to More, Logic, then create variable.
Then you can use it in HomeyScript with setTagValue

nope, using await setTagValue("listalarm", {type: "text", title: "listalarm"}, sum); returns an error, without the await it just doesn’t set the value in the variable. :cry:

Darn, I guess it’s just broken.

I did send a request to Athom for not being able to restart apps in HomeyScript. HomeyScript generates an error: You have no access to do this.

Homey.apps.restartApp({id: 'nl.scanno.mqtt'});

Hello I am a complete new to this so I try copy modify I found an example on a old forum but then when tested I got measure_battery undefined.
Is it possible to get a copy of your script?’
how to find what data that can be found?
on https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.Device.html
I found some general data that could be found but not battery status

Here is a sniplet which logs battery status for all devices (works with Homey 2.x for me):

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

const MEASURE_BATTERY = 'measure_battery';
const ALARM_BATTERY = 'alarm_battery';

function logBatteryLevels() {
    _.forEach(devices, device => {
        if (device.capabilitiesObj[MEASURE_BATTERY]) {
            console.log(`Device ${device.name} has battery level: ${device.capabilitiesObj[MEASURE_BATTERY].value}`);       
        } if (device.capabilitiesObj[ALARM_BATTERY]) {
            console.log(`Device ${device.name} has ${device.capabilitiesObj[ALARM_BATTERY].value ? 'battery alarm' : 'no battery alarm'}`);            
1 Like