Skip to content

vchawla3/tago-sdk-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tago - Python Lib

Official Python lib for Tago

Code Status

wercker status

Documentation

Installation

$ sudo pip install -U tago

Usage

Insert Data

.insert(OBJECT)

from tago import Tago

MY_DEVICE_TOKEN = 'add your device token here'
my_device = Tago(MY_DEVICE_TOKEN).device

data_to_insert = {
    'variable' : 'temperature',
    'location' : {'lat': 42.2974279, 'lng': -85.628292},
    'time'     : '2014-01-20 03:43:59',
    'unit'     : 'C',
    'value'    : 63
}

my_device.insert(data_to_insert) # Without response
# or
result = my_device.insert(data_to_insert) # With response
if result['status']:
    print 'Data added'
else:
    print result['message']
Find Data

.find(OBJECT)

result = my_device.find({'query': 'last_value'})
if result['status']:
    print result['message'] # Array with data
else:
    print result['message'] # Error (if status is False)
Delete Data

.delete(/ID/)

my_device.delete('Data_ID') # Without response
# or
result = my_device.delete('Data_ID') # With response
if result['status']:
    print 'Data Removed'
else:
    print result['message']
Listening new data by Socket

.listening(CALLBACK)

When new data arrives into Tago.io for you, it will be sent it to your device if you configure for this in the ‘Action’ (Left Menu in Admin). For this purpose, you need to create a new action and select the option ‘Send to Device’. All devices using the token associated with the bucket will receive the data.

def func_callback_data(data):
    print data

my_device.listening(func_callback_data)

License

Tago SDK for Python is released under the Apache-2.0 License.

Packages

No packages published

Languages

  • Python 100.0%