Hello. I am developing a smart app in Nodejs. I subscribe to the light devicehandler. when the value is “on”, I want to change the location mode to “Home”. here is the code:
.subscribedEventHandler(‘lightHandler’, async (context, event) => {
if (event.value === ‘on’) {
let homeModeId = ‘’;
const modeList = await context.api.modes.list();
modeList.forEach(element => {
if (element.name === ‘Home’) {
homeModeId = element.id;
}
});
// const current = await context.api.modes.getCurrent(event.locationId)
await context.api.modes.setCurrent(homeModeId , event.locationId);
console.log(“SmartThings changed your mode to ‘Home’, welcome back home!”);
}
})
I tested the API in the postman and it works. although for that, I am using the personal access token(PAT) with the permissions below:
r:locations:,x:devices:,l:devices,w:locations:,r:devices:,w:devices:,x:locations:
while registering the app in smartthings platform, there is a step for choosing the permissions. I checked all of them, but I don’t see all the permissions here(the ones I could have in generating PAT). for instance, there is no w:locations:* and x:locations:* permission which is related to changing the location mode. so I can not have the
although I gave this permissions in my code, like below:
app.permissions([‘r:locations:'], ['x:devices:’], [‘l:devices’], [‘w:locations:'],['x:locations:’])
but it doesn’t work. the getCurrent method is working since I have the read permission (r:locations:*). but the setCurrent function is not working.
so what is the reason? did smartthings limit the access for the smart apps? we don’t have permission to change the location mode from inside the code anymore?