# HomeyScript scopes / authorization

**URL:** <https://community.homey.app/t/homeyscript-scopes-authorization/21513>\
**Category:** Apps\
**Tags:** homeyscript\
**Created:** [November 29, 2019, 2:02pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513 "2019-11-29T14:02:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![martzonneveld](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martzonneveld/32/13129_2.png) [@martzonneveld](https://community.homey.app/u/martzonneveld)\
**Post date:** [November 29, 2019, 2:02pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/1 "2019-11-29T14:02:00Z")

</div>

I’m having a lot of fun with HomeyScript. Reading through several topics on this forum taught me a lot. Although now I’m running into a problem that is not yet answered.

(I focussed this on updating a variable, but this also applies to i.e. triggering flows)

When I want to update a logic variable, I should do as followed:

```auto
Homey.logic.updateVariable({id: <String>, variable: <Variable object>});

```

**Confusion #1** : `id`? What ID? For now I’m going to use my own ID.

```auto
let me = await Homey.users.getUserMe();
let variable = await Homey.logic.getVariable({id: 'variable-id'});
Homey.logic.updateVariable({id: me.id, variable: variable});

```

This will return:

```auto
Script Error:
Je hebt geen toegang om dit te doen. (translation: You have no permission to do this)

```

**Confusion #2** : Why can’t I update variables when I can change things on a device with `setCapabilityValue()`?

When I check my permissions:

```auto
let session = await Homey.sessions.getSessionMe();
log(session);

```

I see indeed that I have almost only `readonly` permissions:

```auto
t {
  __athom_api_type: 'HomeyAPI.ManagerSessions.Session',
  id: ...',
  type: 'APP',
  agent: 'com.athom.homeyscript',
  scopes: 
   [ 'resource',
     'homey.alarm',
     'homey.system.readonly',
     'homey.updates.readonly',
     'homey.geolocation.readonly',
     'homey.zone.readonly',
     'homey.device.readonly',
     'homey.device.control',
     'homey.flow.readonly',
     'homey.user.readonly',
     'homey.user.self',
     'homey.app.readonly',
     'homey.app.control',
     'homey.presence.readonly',
     'homey.insights.readonly',
     'homey.logic.readonly',
     'homey.speech' ],

```

**Confusion #3** : When I check _my session_, why is `'com.athom.homeyscript'` my agent?  
**Confusion #4** : When I check out the `me`-object, my user role is `role: 'owner'`, I should be able to do everything I want, because I really own Homey.

**Question:**  
How can I update my variables? How can I trigger my flows?  
Is it:

- HomeyScript needs more permissions?  
Edit: after research for app permissions I think HomeyScript already has all the permissions it possibly could get, so problem might be with Athom itself then?  
All existing permissions: [https://github.com/athombv/node-homey-lib/blob/master/assets/app/permissions.json](https://github.com/athombv/node-homey-lib/blob/master/assets/app/permissions.json)  
HomeyScript asks for the “homey:manager:api” permission
- I need something like OAuth to be configured?
- I need an other entry point? Right now I’m using the WebAPI for developers: [https://developer.athom.com/docs/api/HomeyAPI.html](https://developer.athom.com/docs/api/HomeyAPI.html)
- Something I am overlooking?

Homey version: 3.1.0  
HomeyScript version: 1.1.1

---

<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:** [November 29, 2019, 3:53pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/2 "2019-11-29T15:53:05Z")

</div>

> [@martzonneveld](#):
>
> I should be able to do everything I want, because I really own Homey.

Yet somehow, Athom has decided that Homeyscript should have limited permissions.

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [November 29, 2019, 5:31pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/3 "2019-11-29T17:31:11Z")

</div>

> [@martzonneveld](#):
>
> I want to update a logic variable,

You can change variables (tag) in HomeyScript only when they are created in HomeyScript and that variables are gone after a restart of Homey.

> await setTagValue(“bas”, {type: “string”, title: “bas”}, b);

---

<div class="post-metadata">

**Author:** ![martzonneveld](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martzonneveld/32/13129_2.png) [@martzonneveld](https://community.homey.app/u/martzonneveld)\
**Post date:** [November 30, 2019, 5:30pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/4 "2019-11-30T17:30:18Z")

</div>

> [@JPe4619](#):
>
> You can change variables (tag) in HomeyScript only when they are created in HomeyScript and that variables are gone after a restart of Homey.
> 
> > await setTagValue(“bas”, {type: “string”, title: “bas”}, b);

HomeySript states that the `setTagValue` is used to “Create, edit, remove a flow tag.”

What I have is a loop in a script that executes every x-minutes. In this loop I’d like to use variables that can be changed by other flows. I haven’t tried yet, but I doubt that the flow-tags are editable by separate triggered flows ☹

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [November 30, 2019, 5:32pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/5 "2019-11-30T17:32:04Z")

</div>

> [@martzonneveld](#):
>
> I doubt that the flow-tags are editable by separate triggered flows ☹

They are! Even a better advise is “Try before you doubt”

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [May 21, 2021, 5:30pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/6 "2021-05-21T17:30:54Z")

</div>

> [@JPe4619](#):
>
> You can change variables (tag) in HomeyScript only when they are created in HomeyScript and that variables are gone after a restart of Homey.

i doubt if that is really true. can you explain how this happend? and… how to get rid of them? trust me, my homey has been rebooted multiple times since then.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/7/57861bb132f8b1c2bd8b9a057589adaea5f95e4f.jpeg)

---

<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:** [May 21, 2021, 5:41pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/7 "2021-05-21T17:41:24Z")

</div>

> [@Edgar](#):
>
> and… how to get rid of them

[“Delete a Flow Token by providing `null` as value.”](https://github.com/athombv/com.athom.homeyscript#tagstring-id-stringnumberboolean-value---promise)

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://community.homey.app/u/Edgar)\
**Post date:** [May 21, 2021, 5:55pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/8 "2021-05-21T17:55:14Z")

</div>

that indeed works… i have a lot to do ☹

thanks!

but… somehow it is possible then…

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 21, 2021, 10:51pm UTC](https://community.homey.app/t/homeyscript-scopes-authorization/21513/9 "2021-05-21T22:51:40Z")

</div>

That was nov. 2019, now they are kept after restart.  
In the new examples it is shown how te create, edit and delete the tags.
