Device¶
In order to modify, add, delete or do anything else with the data inside buckets, it is necessary to use the device function.
To setup an device object, you need a token (that you need to get in our website). Be sure to use tokens with the correct write/read previlegies for the current function that you want to use. For example, a token with only read previlegies can’t create, modify or delete anything from a device.
.info¶
Get all information from the device
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
device_information = my_device.info()
print(device_information)
.insert¶
Insert a new data into a bucket. You can get more information about what information can be passed with insert in our api documentation
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
data = {
'variable': 'temperature',
'unit' : 'F',
'value' : 55,
'time' : '2015-11-03 13:44:33',
'location': {'lat': 42.2974279, 'lng': -85.628292}
}
result = my_device.insert(data)
print(result)
.find¶
Get a list of data from bucket respecting the query options passed. You can get more information about what information can be passed with .find in our get documentation
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
filter = {
'variable': 'myvar',
'query': 'last_value',
'end_date': '2014-12-25 23:33:22',
'start_date': '2014-12-20 23:33:22'
}
result = my_device.find(filter)
print(result)
.remove¶
Remove a data from the bucket using a JSON filter.
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
filter = {
'variable': 'myvar',
'query': 'last_value',
'end_date': '2014-12-25 23:33:22',
'start_date': '2014-12-20 23:33:22'
}
result = my_device.remove(filter)
print(result)
or
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
result = my_device.remove('myvariable')
print(result)
or
import tago
my_device = tago.Device('DEVICE_TOKEN_HERE')
result = my_device.remove('VARIABLE_ID_HERE')
print(result)