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:
Homey.logic.updateVariable({id: <String>, variable: <Variable object>});
Confusion #1: id
? What ID? For now I’m going to use my own ID.
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:
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:
let session = await Homey.sessions.getSessionMe();
log(session);
I see indeed that I have almost only readonly
permissions:
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
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
- Something I am overlooking?
Homey version: 3.1.0
HomeyScript version: 1.1.1