I currently have presence and sleep detection setup using BL. But was looking into using the built in one instead. I am no programmer, so I’m just going on by trial and error. So far, only error. How can I do a rest call to set the value?
I can read all users by calling /api/manager/users/user/ or
a specific user by /api/manager/users/user//
But no matter how I format the body I cannot change the value. It just stays as:
“asleep”: false
Hmm, guess I was a bit quick. Seems like I ran into another noob issue right away. It appears as it works as intended from the Web API Playground. But when trying in Postman or RESTask in Tasker it toggles the value every time I run a PUT. I was expecting it to change to or not change if already the same.
I’m probably not formatting the value {“asleep”:true} (and a few variants) in the body correctly. If I remove it completely, I still get the toggle behavior.
Maybe somethings have changed since 1.5 when it comes to the API? I also tried to set the value as header or parameter. Trying all variants of with or without curly brackets and dubble quotes. Still only toggles. Feel almost like the mad scientist here, trying everything without hitting the perfect combination
Maybe all this is for nothing since the Bearer tokens now expire after 24h. I thought it was a bug in 2.1.1 fixed in 2.1.2. But it seems not. If this is the case, then Homey just lost a point until I can figure out how to authenticate properly.
Before v2 it was possible from within an HomeyApp and from HomeyScript, since the new authorization this is not possible there as the scope is mostly *.readonly (sorry, cant find it in documentation)
Edit:
Found!!
use of Web API from Apps SDK: Changed in v2.0.0
Web API
Usage of the Web API has been limited in apps with the homey:manager:api permission to the following scopes: homey.alarmhomey.system.readonlyhomey.updates.readonlyhomey.geolocation.readonlyhomey.zone.readonlyhomey.device.readonlyhomey.device.controlhomey.flow.readonlyhomey.user.readonlyhomey.user.selfhomey.app.readonlyhomey.app.controlhomey.presence.readonlyhomey.insights.readonlyhomey.logichomey.speech .
Users wishing to use the Web API in their app must include athom-api v2.1 or higher in their app.
Blockquote Web API
Usage of the Web API has been limited in apps with the homey:manager:api permission to the following scopes: homey.alarmhomey.system.readonlyhomey.updates.readonlyhomey.geolocation.readonlyhomey.zone.readonlyhomey.device.readonlyhomey.device.controlhomey.flow.readonlyhomey.user.readonlyhomey.user.selfhomey.app.readonlyhomey.app.controlhomey.presence.readonlyhomey.insights.readonlyhomey.logichomey.speech .
Users wishing to use the Web API in their app must include athom-api v2.1 or higher in their app.
Since a lot of stuff is explicitly mentioned as readonly while some or not one would asume that homey.logic is not readonly.
Still I get the same “UnhandledPromiseRejectionWarning: missing_scopes: Je hebt geen toegang om dit te doen.” as with the presence stuff. Am I missing something here or is the SDK documentation unclear?