# \[APP\]\[Pro\] HomeyScript

**URL:** <https://community.homey.app/t/app-pro-homeyscript/854>\
**Category:** Apps\
**Tags:** app, homey-pro\
**Created:** [August 30, 2018, 7:34am UTC](https://community.homey.app/t/app-pro-homeyscript/854 "2018-08-30T07:34:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![FantomNotaBene](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fantomnotabene/32/129_2.png) [@FantomNotaBene](https://community.homey.app/u/FantomNotaBene)\
**Post date:** [August 30, 2018, 7:34am UTC](https://community.homey.app/t/app-pro-homeyscript/854/1 "2018-08-30T07:34:20Z")

</div>

_Current app version: 3.2.6 (stable)_

HomeyScript App by Athom.

## Links:

- App Store: [HomeyScript | Homey](https://apps.athom.com/app/com.athom.homeyscript)
- GitHub: [https://github.com/athombv/com.athom.homeyscript](https://github.com/athombv/com.athom.homeyscript/tree/791dff79646165747f2148bb55702b0cbaeb613b)

---

<div class="post-metadata">

**Author:** ![oPzOpZ](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/opzopz/32/941_2.png) [@oPzOpZ](https://community.homey.app/u/oPzOpZ)\
**Post date:** [December 8, 2018, 10:01am UTC](https://community.homey.app/t/app-pro-homeyscript/854/2 "2018-12-08T10:01:05Z")

</div>

Hi

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?

BR

---

<div class="post-metadata">

**Author:** ![Wessel](https://avatars.discourse-cdn.com/v4/letter/w/53a042/32.png) [@Wessel](https://community.homey.app/u/Wessel)\
**Post date:** [December 23, 2018, 6:56pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/3 "2018-12-23T18:56:04Z")

</div>

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.

> **[athombv/com.athom.homeyscript](https://github.com/athombv/com.athom.homeyscript/tree/791dff79646165747f2148bb55702b0cbaeb613b/examples)**
>
> Script your home. Contribute to athombv/com.athom.homeyscript development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Wessel](https://avatars.discourse-cdn.com/v4/letter/w/53a042/32.png) [@Wessel](https://community.homey.app/u/Wessel)\
**Post date:** [December 23, 2018, 7:07pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/4 "2018-12-23T19:07:40Z")

</div>

WOW, when you’ve installed the app, you could go to [homeyscript.athom.com](http://homeyscript.athom.com) to create script. There are the same examples.

---

<div class="post-metadata">

**Author:** ![Ton\_Meek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ton_meek/32/149_2.png) [@Ton\_Meek](https://community.homey.app/u/Ton_Meek)\
**Post date:** [December 23, 2018, 7:45pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/5 "2018-12-23T19:45:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![khangwei](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/khangwei/32/9687_2.png) [@khangwei](https://community.homey.app/u/khangwei)\
**Post date:** [January 17, 2019, 3:41am UTC](https://community.homey.app/t/app-pro-homeyscript/854/6 "2019-01-17T03:41:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 17, 2019, 7:40am UTC](https://community.homey.app/t/app-pro-homeyscript/854/7 "2019-01-17T07:40:43Z")

</div>

Try `device.capabilitiesObj.onoff.value`

---

<div class="post-metadata">

**Author:** ![khangwei](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/khangwei/32/9687_2.png) [@khangwei](https://community.homey.app/u/khangwei)\
**Post date:** [January 17, 2019, 7:41am UTC](https://community.homey.app/t/app-pro-homeyscript/854/8 "2019-01-17T07:41:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 17, 2019, 8:44am UTC](https://community.homey.app/t/app-pro-homeyscript/854/9 "2019-01-17T08:44:13Z")

</div>

HomeyScript uses the Web API, for which documentation can be found [here](https://developer.athom.com/docs/api). 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](https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.Device.html)

---

<div class="post-metadata">

**Author:** ![khangwei](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/khangwei/32/9687_2.png) [@khangwei](https://community.homey.app/u/khangwei)\
**Post date:** [January 17, 2019, 8:55am UTC](https://community.homey.app/t/app-pro-homeyscript/854/10 "2019-01-17T08:55:37Z")

</div>

thanks very much @robertklep

---

<div class="post-metadata">

**Author:** ![Volkov](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/volkov/32/4664_2.png) [@Volkov](https://community.homey.app/u/Volkov)\
**Post date:** [January 23, 2019, 10:02am UTC](https://community.homey.app/t/app-pro-homeyscript/854/11 "2019-01-23T10:02:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Volkov](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/volkov/32/4664_2.png) [@Volkov](https://community.homey.app/u/Volkov)\
**Post date:** [January 24, 2019, 8:38am UTC](https://community.homey.app/t/app-pro-homeyscript/854/12 "2019-01-24T08:38:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bvdbos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bvdbos/32/2352_2.png) [@bvdbos](https://community.homey.app/u/bvdbos)\
**Post date:** [February 7, 2019, 5:18pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/13 "2019-02-07T17:18:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Volkov](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/volkov/32/4664_2.png) [@Volkov](https://community.homey.app/u/Volkov)\
**Post date:** [February 8, 2019, 6:04pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/14 "2019-02-08T18:04:10Z")

</div>

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](https://forum.athom.com/discussion/3666/homeyscript-share-your-scripts-main-discussion-topic/p2)

(just search for “betterlogic”)

---

<div class="post-metadata">

**Author:** ![Marlon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marlon/32/3794_2.png) [@Marlon](https://community.homey.app/u/Marlon)\
**Post date:** [February 8, 2019, 6:21pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/15 "2019-02-08T18:21:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Marlon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marlon/32/3794_2.png) [@Marlon](https://community.homey.app/u/Marlon)\
**Post date:** [February 8, 2019, 6:24pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/16 "2019-02-08T18:24:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bvdbos](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bvdbos/32/2352_2.png) [@bvdbos](https://community.homey.app/u/bvdbos)\
**Post date:** [February 8, 2019, 7:01pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/17 "2019-02-08T19:01:41Z")

</div>

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. 😢

---

<div class="post-metadata">

**Author:** ![Marlon](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marlon/32/3794_2.png) [@Marlon](https://community.homey.app/u/Marlon)\
**Post date:** [February 9, 2019, 6:36am UTC](https://community.homey.app/t/app-pro-homeyscript/854/18 "2019-02-09T06:36:53Z")

</div>

Darn, I guess it’s just broken.

I did send a [request](https://support.athom.com/hc/en-us/requests/new) 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'});`

---

<div class="post-metadata">

**Author:** ![mats\_karlsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mats_karlsson/32/7887_2.png) [@mats\_karlsson](https://community.homey.app/u/mats_karlsson)\
**Post date:** [March 12, 2019, 9:36pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/19 "2019-03-12T21:36:32Z")

</div>

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](https://developer.athom.com/docs/api/HomeyAPI.ManagerDevices.Device.html)  
I found some general data that could be found but not battery status

---

<div class="post-metadata">

**Author:** ![Volkov](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/volkov/32/4664_2.png) [@Volkov](https://community.homey.app/u/Volkov)\
**Post date:** [March 14, 2019, 7:35pm UTC](https://community.homey.app/t/app-pro-homeyscript/854/20 "2019-03-14T19:35:26Z")

</div>

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'}`);            
        }
    });
}
```

[Next page](https://community.homey.app/t/app-pro-homeyscript/854.md?page=2)
