Get Device's Data From Zipato's API
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.
- {
"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"
}
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...:
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...:
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...:
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...:
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
Perhaps it could be done in a smarter way - but this is just me looking at the API for 11 minutes...
Cheers...
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...:
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...:
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...:
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...:
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
Perhaps it could be done in a smarter way - but this is just me looking at the API for 11 minutes...
Cheers...
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.
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.
Actually, you need 4 steps to get the device. Later you can get status of all attributes with the single call...
Actually, you need 4 steps to get the device. Later you can get status of all attributes with the single call...
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.
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.
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...
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...
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.
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.
Does it work with local access or do you need to be connected always to the Zipato Cloud servers?
Does it work with local access or do you need to be connected always to the Zipato Cloud servers?
Replies have been locked on this page!