Hi,
I’d like to control my Somfy Protect (formally known as MyFox) alarm system directly from Homey. Unfortunately, there is currently no app available. However, I have found a few developments that seem to work on other systems:
I’m trying to implement the same commands in HomeyScript using the fetch function, but I’m already stuck on the request to obtain a token.
const CLIENT_ID = "84eddf48-2b8e-11e5-b2a5-124cfab25595_475buqrf8v8kgwoo4gow08gkkc0ck80488wo44s8o48sg84k40";
const CLIENT_SECRET = "4dsqfntieu0wckwwo40kw848gw4o0c8k4owc80k4go0cs0k844";
const CLIENT_USERNAME = "***";
const CLIENT_PASSWORD = "***";
async function getNewToken(){
const token = await fetch('https://sso.myfox.io/oauth/oauth/v2/token', {
method: "POST",
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
username: CLIENT_USERNAME,
password: CLIENT_PASSWORD,
grant_type: 'password'
});
const data = await token.json();
return data;
};
log(await getNewToken());
I got the following answer, which is exactly the same as if I put the URL in my browser’s address bar :
{
message: 'error.invalid.token',
data: [],
uid: '655a49a09b474',
error: 'invalid_client'
}
Could someone help me or explain how to do this, if possible? I’m new to this type of request.
Thx