I’ve been writing my own “dashboard”-like web-app using JavaScript, running on an network-internal Apache web server. First to create a touchscreen interface only to trigger Flows by using the HTTP request app (by Erik van Dongen), which worked perfectly and was quite easy to do. Since then I’ve added the possibility to define different kinds of widgets and the ability to load more configurations (widget pages) so the same application can be used for multiple devices, whilst still being able to use different layouts per device and manage them from a central location.
Now however I’d like to extend the web application by adding the possibility to retrieve information from Homey, using JSON requests. I’ve added the athom-api.min.js to load as a script, but appear to be stuck at how to set up a connection to Homey’s API however. The documentation is not clear enough for me, I am not that experienced as a developer.
Would anyone here be willing to explain how to go about setting up that connection? Preferably without going to the cloud if that’s even possible these days. Once I have the connection set up I think I know how to use the API and get data… I hope…
Thanks Koktail,
Yes, I was/am aware of the documentation. That is exactly where I got stuck…
As I said, I’ve added the Athom javascript bit, but not sure how to proceed from there.
From what I gather, this bit of code should be a start:
function StartHomeyAPI() {
HomeyCloudAPI = new AthomAPI.AthomCloudAPI({
clientId: HomeyID,
clientSecret: HomeyBearer,
redirectUrl: 'http://localhost'
});
HUser = HomeyCloudAPI.getAuthenticatedUser();
alert(HUser);
}
HomeyID and HomeyBearer are defined elsewhere.
Calling the function alerts an Object promise, but from what I gather that could also be an error. Not sure how to proceed, as I said this API stuff is new to me.
Not recreating, but building something similar, yes. Just a learning project…
swtt is using a javascript framework, whereas I’m trying to keep it simple and use javascript\html\css only. The use of the framework makes the code all but unreadable to me.