make sure errorcodes are returned
This commit is contained in:
parent
5cfd91717f
commit
c9588af3c3
2 changed files with 8 additions and 13 deletions
|
@ -4,7 +4,7 @@ telldus.tdInit()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
result = telldus.tdSensor()
|
result = telldus.tdSensor()
|
||||||
if not result:
|
if not isinstance(result, tuple):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
protocol, model, sensorId, dataTypes = result
|
protocol, model, sensorId, dataTypes = result
|
||||||
|
@ -13,13 +13,13 @@ while True:
|
||||||
# Retrieve the values the sensor supports
|
# Retrieve the values the sensor supports
|
||||||
if dataTypes & telldus.TELLSTICK_TEMPERATURE:
|
if dataTypes & telldus.TELLSTICK_TEMPERATURE:
|
||||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE)
|
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_TEMPERATURE)
|
||||||
if result:
|
if isinstance(result, tuple):
|
||||||
value, timestamp = result
|
value, timestamp = result
|
||||||
print "Temperature:\t%sC\t(%s)\n" % (value, str(timestamp))
|
print "Temperature:\t%sC\t(%s)\n" % (value, str(timestamp))
|
||||||
|
|
||||||
if dataTypes & telldus.TELLSTICK_HUMIDITY:
|
if dataTypes & telldus.TELLSTICK_HUMIDITY:
|
||||||
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY)
|
result = telldus.tdSensorValue(protocol, model, sensorId, telldus.TELLSTICK_HUMIDITY)
|
||||||
if result:
|
if isinstance(result, tuple):
|
||||||
value, timestamp = result
|
value, timestamp = result
|
||||||
print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp))
|
print "Humidity:\t%s\t(%s)\n" % (value, str(timestamp))
|
||||||
|
|
||||||
|
|
|
@ -31,17 +31,14 @@ estrdup(char *s)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdInit(PyObject *self)
|
telldus_tdInit(PyObject *self)
|
||||||
{
|
{
|
||||||
tdInit();
|
return PyLong_FromLong(tdInit());
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
telldus_tdClose(PyObject *self)
|
telldus_tdClose(PyObject *self)
|
||||||
{
|
{
|
||||||
tdClose();
|
return PyLong_FromLong(tdClose();)
|
||||||
Py_INCREF(Py_None);
|
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -573,8 +570,7 @@ telldus_tdSensor(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Py_INCREF(Py_None);
|
return PyLong_FromLong(result);
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -614,8 +610,7 @@ telldus_tdSensorValue(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Py_INCREF(Py_None);
|
return PyLong_FromLong(result);
|
||||||
return Py_None;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue