Finally purchased Cozify thanks to Lähivakuutus. First impressions are that it looks very nice on paper, but it's extremely locked down.
From the forum, it seems there have been many promises on providing an open API, but so far the only solution seem to be the unofficial python API. Are there any status updates at all on this? Overall it seems that Cozify has one of the most competent hardware solutions that covers a lot of sensors, but without an API it means I can either limit myself to what the app supports, or just go with something else.
1
Viestejä yhteensä
What kind of features you would be implementing?
Best Regards,
Samppa / Cozify
For example the developer Artanicus of the "unofficial python API" has our API documentation already.
https://github.com/Artanicus/python-cozify
Attach also your contact details (name, SSN, address, phone and email) so that I can prepare an NDA and after that has been signed I can send you the API with a few examples.
Later on our plan is to streamline this process and open the API to everyone, but since that requires a bit more effort, we have to limit the access to those developers that most probably can achieve something useful without excess need for support.
- Samppa / Cozify
But I have some good news as the apidoc has been developed further.
I will answer now to your ticket and you will get access to the documentation.
Soon we will publish it for everyone.
Best Regards,
Samppa
I tried it myself with Java in Android Studio using javax.net.ssl.HttpsURLConnection class and succeeded to login and access the API calls.
The documentation of Cozify API is not yet very thorough, so e.g. be careful with the "Content-type" and "Accept" headers that define the type of data sent or received ("application/json" or "text/plain") that varies depending on the API call. So admittedly the API is not very coherent.
The login sequence is as follows with some additional hints to avoid some of the most common caveats:
1. Emit temporary password to email with
https://api.cozify.fi:/ui/0.2/user/requestlogin?email=user@cozify.fi
call POST with email added to the URL and empty payload data and "text/plain" in "Content-Type" and "Accept" headers.
2. Once user has entered the password, confirm it with
https://api.cozify.fi/ui/0.2/user/emaillogin
call POST with data payload JSON as follows: {"email": "user@cozify.fi", "password": "XXYYZZ"} So this time Content-Type is "application/json" and "text/plain" as Accept the header. Return value is a string that you store as cloudtoken to be used as the "Authorization" header is all further calls.
3. Next you list all the hubs the user can control with
https://api.cozify.fi/ui/0.2/user/hubkeys
call GET. It returns JSON, so the "Accept"-header needs to be "application/json". Parse the returned JSON array of hub identifiers and JWT tokens to be also stored and used in all further calls to that hub as "X-Hub-Key" additional header field. Also you should decode the JWT by splitting the string with '.' delimiter and base64 decoding the parts to get JSON. The second part contains information about the hub e.g. the hub_name field that you need for listing the hubs to end user.
Now you have all the info needed for calling all the other commands to e.g. devices.
And if you store the tokens securely, you can avoid the login each time and re-use them for 4 weeks.
Easy start is to use all calls always through the cloud remotely, but you can also send the commands directly to the hub if connected in the same LAN (there is a simple call "https://api.cozify.fi/ui/0.2/hub/lan_ip" to discover if there are any hubs in the same lan available).
BR,
Samppa \ Cozify
My main worry is that it's tricky to since it requires semi-interactive login. Say for example an cozify 2 mqtt proxy could rather easily be written with your existing API, but if I want to run it in docker / kubernetes / etc, it's a bit complicated to do the initial login. It would be great if you had the option to generate a permanent api key that is not time restricted for these kind of cases. (preferably also a possibility to limit the key to read only calls)