Get Device's Data From Zipato's API

Thibaud Dahan shared this question 5 years ago
Need Answer

Hi,


I'm writing a python program that gets the devices's data from Zipato's API and store it in a database.

I managed to get the list of my devices (with their link, uuid and name) but i dont understand where i can get the data for each device.


When i run a full getStatus() on a thermometer device i get that : (I removed all the uuid cause i dont know if i should share that or not)


As you can see there isn't any temperature value i can get from this =/


Thank you.

Thibaud.

  1. {

    "link": "devices/UUID_OF_THIS_DEVICE",

    "config": {

    "className": "com.zipato.network.avidsen.AvidsenDevice",

    "tags": null,

    "firmware": null,

    "model": null,

    "periodicallyWakeUp": false,

    "manufacturerId": null,

    "status": "ENABLED",

    "wakeUpInterval": 0,

    "locationId": null,

    "descriptorFlags": null,

    "productId": 80,

    "order": null,

    "description": "",

    "hidden": false,

    "name": "Temperature/Humidity sensor (516119)",

    "xmitUnAck": 0,

    "alwaysReachable": false,

    "uuid": "UUID_OF_THIS_DEVICE",

    "serial": null,

    "user": null,

    "deviceId": 134,

    "room": null

    },

    "descriptor": {

    "link": "https://my.zipato.com/zipato-web/v2/descriptors/device/459";,

    "id": 459

    },

    "endpoints": [

    {

    "link": "https://my.zipato.com/zipato-web/v2/endpoints/ENDPOINT_UUID_OF_THIS_DEVICE";,

    "name": "N1T2b",

    "uuid": "ENDPOINT_UUID_OF_THIS_DEVICE"

    }

    ],

    "icon": {

    "link": "https://my.zipato.com/zipato-web/v2/types/system/Pilot+wire";,

    "name": "Pilot wire",

    "endpointType": "actuator.pilot_wire",

    "relativeUrl": "/actuator.pilot_wire.png"

    },

    "network": {

    "link": "https://my.zipato.com/zipato-web/v2/networks/NETWORK_UUID_OF_THIS_DEVICE";,

    "name": "Avidsen",

    "uuid": "NETWORK_UUID_OF_THIS_DEVICE"

    },

    "showIcon": false,

    "state": {

    "timestamp": "2015-05-07T14:00:04Z",

    "trouble": false,

    "failCount": 0,

    "receiveTimestamp": "2015-05-07T14:00:04Z",

    "batteryTimestamp": "2015-04-23T14:34:26Z",

    "batteryLevel": 100,

    "sentTimestamp": 0,

    "onlineState": "ONLINE",

    "mainsPower": false,

    "online": true

    },

    "templateId": "",

    "userIcon": null,

    "uuid": "UUID_OF_THIS_DEVICE"

    }

Comments (7)

photo
5

Hi Thibaud,


Here is what you need to do, and yes I will expose my UUID, have no clue yet if, it's global or bound to my account...;)


1. Get a list of all your devices - GET /devices (https://my.zipato.com:443/zipato-web/v2/devices)


Loop through the json output and locate the device name/uuid you need to extract data from.


I will use my flood sensor in this example...:


  1. {
  2. "link": "https://my.zipato.com/zipato-web/v2/devices/94740c55-5211-4f4c-af20-3e5437b65573";,
  3. "name": "Fibaro FGFS-101 flood sensor v2.1-2.3",
  4. "uuid": "94740c55-5211-4f4c-af20-3e5437b65573"
  5. }


2. Locate the device's endpoints with - GET /devices/94740c55-5211-4f4c-af20-3e5437b65573/endpoints (https://my.zipato.com:443/zipato-web/v2/devices/94740c55-5211-4f4c-af20-3e5437b65573/endpoints

)


Locate the endpoint needed...:


  1. {
  2. "link": "https://my.zipato.com/zipato-web/v2/endpoints/ea28066e-6077-464f-9b4a-67c7d1953c81";,
  3. "name": "Temperature meter - Flood Sensor",
  4. "tags": [
  5. "favorite-15357"
  6. ],
  7. "uuid": "ea28066e-6077-464f-9b4a-67c7d1953c81"
  8. }


3. Query the endpoints the endpoint with the attribute parameter to true GET /endpoints/ea28066e-6077-464f-9b4a-67c7d1953c81 (https://my.zipato.com:443/zipato-web/v2/endpoints/ea28066e-6077-464f-9b4a-67c7d1953c81?attributes=true

)


Locate the attribute uuid...:


  1. {
  2. "link": "https://my.zipato.com/zipato-web/v2/attributes/6e2246f9-0a86-4944-b03b-8f884c199744";,
  3. "name": "TEMPERATURE",
  4. "attributeId": 95,
  5. "attributeName": "value1",
  6. "uuid": "6e2246f9-0a86-4944-b03b-8f884c199744"
  7. }


4. Get the latest value of the attribute GET /attributes/{uuid}/value (https://my.zipato.com:443/zipato-web/v2/attributes/6e2246f9-0a86-4944-b03b-8f884c199744/value

)


Locate the value...:


  1. {
  2. "value": "9.09",
  3. "timestamp": "2015-05-07T19:14:54Z"
  4. }


And there you go...you have the value...of 9.09 degrees celsius


5. Bonus


From here you could just pass the attribute value to the log, and voila you have all attribute values from the log for this device endpoint, have no clue if the log over time will be flushed on the device, but here is what you need the do...:


Pass the attribute value GET /log/attribute/6e2246f9-0a86-4944-b03b-8f884c199744 (https://my.zipato.com:443/zipato-web/v2/log/attribute/6e2246f9-0a86-4944-b03b-8f884c199744?count=100&order=desc


  1. )
  2. "values": [
  3. {
  4. "t": "2015-05-07T19:25:06Z",
  5. "v": "8.79"
  6. },
  7. {
  8. "t": "2015-05-07T19:14:54Z",
  9. "v": "9.09"
  10. },
  11. {
  12. "t": "2015-05-07T19:04:42Z",
  13. "v": "9.46"
  14. },
  15. {
  16. "t": "2015-05-07T18:34:06Z",
  17. "v": "9.31"
  18. },
  19. {
  20. "t": "2015-05-07T17:53:21Z",
  21. "v": "10.15"
  22. },
  23. {


Perhaps it could be done in a smarter way - but this is just me looking at the API for 11 minutes...


Cheers...

photo
1

Wow, thanks a lot for your help !

I didn't imagine that i needed 4 steps to get the data from a device =/


I'll try and do that on my python program, but it should be easy with the example you just gave me !


Thank you,

Thibaud.

photo
2

Actually, you need 4 steps to get the device. Later you can get status of all attributes with the single call...

photo
1

Thanks for all those answers. I'm running some test at the moment but i have a little problem :

When i do some query via google chrome on the API it works but on my python program i get a time out.


Sometimes it's on the init (/zipato-web/v2/user/init) or the login (/zipato-web/v2/user/login), sometimes on the getDevices (/zipato-web/v2/devices/), and sometimes (once every ~10 attempt) everything work.


I had the same problem Friday for ~20min and then it worked again (without any change on the code).


Any idea where it could come from ?


Thanks,

Thibaud.

photo
1

Hi Thibaud,


I have kind of like - lets say exactly the same issues.


My conclusion was, that perhaps or maybe that Zipato have some kind of max query limits (API throttling) that are setup to restrictive/cautiously or something - that doesn't provide, as of yet, the proper feedback for us to know, what the issues are/might be!


Perhaps we could get a Zipato person to elaborate...

photo
1

I just tried on an other router and it works now.

I dont know what was wrong with the other one though (it's the same SIM Card).


Cheers,

Thibaud.

photo
1

Hello, did you manage to store the zipato data in some database or cloud? I jave no knowledge about these things, but I would like to have data in some database which get be the used for showing some charts

photo
1

I am also very interesting of the solution to have 1 year of data

photo
photo
1

Does it work with local access or do you need to be connected always to the Zipato Cloud servers?