After my first week of Homey App programming I’m able to interface with my device.
Got some flow cards to turn on- and color lights and make some sounds. Still in a premature state but we are getting somewhere.
I ‘have looked at sample coding and I’m still overwhelmed with the many possibilities and solutions, so I’m scratching only the top of the ice berg at this moment.
What, I want to improve is to get my Homey app updated if for example a user changes the light color from the device externally.
There must be a link to update the homey side also, to adapt to the new color.
And I have seen some possibilities about setIntervals to query the device status every x period but I want to use the Web API that also seems to be available.
So, my device will ‘push’ the change to Homey if a status is changed, Locally to my App that’s running on the Homey Pro 2023.
In the docs:
Your app’s API endpoints are available under the following url: /api/app/com.yourapp.id/. All endpoints are protected by default, and the requesting user needs permission to your app (which is granted by default after installation). You can override this by setting “public”: true.
But I tried all possible URL’s before /api/app/com.yourapp.id/ but none off them work.
What must it be? my app is called nl.woordklok.my:
https ://my.homey.app/api/app/nl.woordklok.my/getSomething?color=456789 does not work and gives an unknow page:
Unknown route
No match for /api/app/nl.woordklok.my/getSomething
If have created the endpoint in the app.json:
"api": {
"getSomething": {
"method": "GET",
"path": "/"
}
}
And created an api.js in the root:
module.exports = {
async getSomething({ homey, query }) {
// you can access the App instance through homey.app
const result = await homey.app.getSomething();
console.log("getSometing");
return result;
}
};
What I’m missing here? must the api.js included somehere or are there other things to solve?