Is there a public mechanism to subscribe to Zipabox updates using the API?

Innodron shared this question 9 years ago
Need Answer

Listening for update notifications to the underlying data is always cheaper for both the client and server. Zipato API is very useful and one can build customized front-ends for specific customer needs. However it does not seem to reveal a method to subscribe to updates.


Yet I am certain that exists since both the Web and Mobile clients seem to be utilizing it. Does anyone know how to access that, or does Zipato have any plans to publicise it?

Replies (5)

photo
1

I am guessing that Zipato uses the built-in push mechanism of iOs and Android for updates in the official app.

On the web, on the other hand, it looks like plain old polling of the API. Every two second or so, the following url is polled:

&update=true]&update=true]&update=true]https://my.zipato.com/zipato-web/v2/devices/statuses?_dc=[SOMELONGNUMBER]&update=true (with some request parameters)

If there are no changes to device values, the response is HTTP 306 "Not modified".

The SOMELONGNUMBER seems to be increasing between the calls. It consists of a Unix timestamp (first 9 numbers) and three numbers that are fluctuating (I am not sure what they are, they might just be milliseconds).

When a value has changed, the request returns with HTTP 200 and a JSON payload containing the device's statuses, like this


  1. [ {

    "uuid" : "[removed by me]",

    "state" : {

    "timestamp" : null,

    "trouble" : false,

    "receiveTimestamp" : "2015-09-23T10:35:23Z",

    "batteryTimestamp" : "2015-09-22T00:09:40Z",

    "batteryLevel" : 100,

    "sentTimestamp" : "2015-09-22T00:09:40Z",

    "onlineState" : "ONLINE",

    "mainsPower" : false,

    "online" : true

    }

    }, {

    "uuid" : "[removed by me]",

    "state" : {

    "timestamp" : null,

    "trouble" : false,

    "receiveTimestamp" : "2015-09-22T17:30:17Z",

    "batteryTimestamp" : 0,

    "batteryLevel" : 0,

    "sentTimestamp" : 0,

    "onlineState" : "OFFLINE",

    "mainsPower" : false,

    "online" : false

    }

    } ]


photo
1

Marius, thanks for your comments. I was not aware that web GUI was periodically pulling instead of being pushed to. The URL you mentioned is documented in the API, except the parameter _dc you mentioned above.


Indeed, both https://my.zipato.com:443/zipato-web/v2/attributes/values?update=true and https://my.zipato.com:443/zipato-web/v2/devices/statuses?update=true API calls can be used to fetch the updates (with an HTTP GET request with request header parameter "If-None-Match", whose value must be set to the "Etag" parameter value from the response header of previous HTTP GET)


What I am after is the service to subscribe to, in order to get push notifications for an android service I am working on to integrate Zipato with an external device.


Note: currently I have a rule in Zipabox to call a web service in my Android app when changes occur, which triggers the app to start synchronisation. However, Zipa rules are known to be failing sometimes now with the .998 version of the firmware.

photo
1

Nice catch on the extra request header parameters :)

>> currently I have a rule in Zipabox to call a web service in my Android app

Is it the backend/server you requests from the Zipabox rule?

If you have a server, you could make the server do the API polling (it seems Zipato does not have a "push" service) and then use Android cloud messaging to do the notifcation?

Or you could have your app long poll (the way android push works in the background, I think) your server, i.e hold a single http connection open to the backend which the backend responds to when it has news for you. But this would be reinventing the wheel since you could use cloud messaging.

photo
1

Right. It's a cache buster mechanism. I have implemented something similar myself, a long time ago.


Thanks for updating!

Leave a Comment
 
Attach a file