ubidots / ubidots-python

A python API client for Ubidots
ubidots.com/docs/libraries/python.html
MIT License
30 stars 13 forks source link

var.save_value() with timestamp is broken #7

Closed ddasilva closed 10 years ago

ddasilva commented 10 years ago

The error is: ubidots.apiclient.UbidotsInvalidInputError: Key "timestamp" must point to an int value.

However, int(time.time())*1000 yields a long. It looks like there is an explicit isinstance check to int.

Code to reproduce:

import math
import time
import ubidots

api = ubidots.ApiClient('ad7bd8a9df9371251945c1b61a8179e695729255',
                        base_url='http://localhost:8000/api/')

c = api.get_variable('5399ed0527a5141a63d55177')
s = api.get_variable('5399ed1127a5141a63d55178')

for i in range(1000):
    timestamp = int(time.time())*1000

    c.save_value({'value': math.cos(time.time() / 100.0),
                  'timestamp': timestamp})
    s.save_value({'value': math.sin(time.time() / 100.0),
                  'timestamp': timestamp})
    time.sleep(10)