diff --git a/bindings/python/native/example/poll.py b/bindings/python/native/example/poll.py index c8dcf618..088882c2 100644 --- a/bindings/python/native/example/poll.py +++ b/bindings/python/native/example/poll.py @@ -4,7 +4,7 @@ telldus.tdInit() while True: result = telldus.tdSensor() - if not result: + if not isinstance(result, tuple): break else: protocol, model, sensorId, dataTypes = result @@ -13,13 +13,13 @@ while True: # Retrieve the values the sensor supports if dataTypes & telldus.TELLSTICK_TEMPERATURE: result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE) - if result: + if isinstance(result, tuple): value, timestamp = result print "Temperature:\t%sC\t(%s)\n" % (value, str(timestamp)) if dataTypes & telldus.TELLSTICK_HUMIDITY: result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY) - if result: + if isinstance(result, tuple): value, timestamp = result print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp)) diff --git a/bindings/python/native/telldus.c b/bindings/python/native/telldus.c index 060299da..5ffc530b 100644 --- a/bindings/python/native/telldus.c +++ b/bindings/python/native/telldus.c @@ -31,17 +31,14 @@ estrdup(char *s) static PyObject * telldus_tdInit(PyObject *self) { - tdInit(); - Py_INCREF(Py_None); - return Py_None; + return PyLong_FromLong(tdInit()); } static PyObject * telldus_tdClose(PyObject *self) { - tdClose(); - Py_INCREF(Py_None); - return Py_None; + return PyLong_FromLong(tdClose();) + } static PyObject * @@ -573,8 +570,7 @@ telldus_tdSensor(PyObject *self, PyObject *args) } else { - Py_INCREF(Py_None); - return Py_None; + return PyLong_FromLong(result); } } @@ -614,8 +610,7 @@ telldus_tdSensorValue(PyObject *self, PyObject *args) } else { - Py_INCREF(Py_None); - return Py_None; + return PyLong_FromLong(result); } }