Add function com.telldus.core.sensor() to script as wrapper for tdSensor(). See #96
This commit is contained in:
parent
6c325fd0e6
commit
486753d411
2 changed files with 23 additions and 0 deletions
|
@ -103,6 +103,26 @@ int TelldusCoreObject::stop(int deviceId) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
QVariant TelldusCoreObject::sensor() const {
|
||||
const int DATA_LENGTH = 20;
|
||||
char protocol[DATA_LENGTH], model[DATA_LENGTH];
|
||||
int sensorId = 0, dataTypes = 0;
|
||||
|
||||
|
||||
if (tdSensor(protocol, DATA_LENGTH, model, DATA_LENGTH, &sensorId, &dataTypes) != TELLSTICK_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
QVariantMap retval;
|
||||
|
||||
retval["protocol"] = protocol;
|
||||
retval["model"] = model;
|
||||
retval["sensorId"] = sensorId;
|
||||
retval["dataTypes"] = dataTypes;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
|
||||
char *errorString = tdGetErrorString( errorId );
|
||||
QString message = QString::fromUtf8( errorString );
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define TELLDUSCOREOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
#include <telldus-core.h>
|
||||
|
||||
class TelldusCoreObject : public QObject
|
||||
|
@ -27,6 +28,8 @@ public slots:
|
|||
QString lastSentValue( int deviceId );
|
||||
int methods( int deviceId, int methodsSupported );
|
||||
|
||||
QVariant sensor() const;
|
||||
|
||||
int turnOn( int deviceId );
|
||||
int turnOff( int deviceId );
|
||||
int up( int deviceId );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue