Add function com.telldus.core.sensorValue() to script as wrapper for tdSensorValue(). See #96
This commit is contained in:
parent
486753d411
commit
b9fbd3a909
2 changed files with 14 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
#include "tellduscoreobject.h"
|
#include "tellduscoreobject.h"
|
||||||
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
TelldusCoreObject::TelldusCoreObject( QObject * parent )
|
TelldusCoreObject::TelldusCoreObject( QObject * parent )
|
||||||
|
@ -123,6 +124,18 @@ QVariant TelldusCoreObject::sensor() const {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant TelldusCoreObject::sensorValue(const QString &protocol, const QString &model, int id, int dataType) const {
|
||||||
|
const int DATA_LENGTH = 20;
|
||||||
|
char value[DATA_LENGTH];
|
||||||
|
time_t timestamp = 0;
|
||||||
|
|
||||||
|
tdSensorValue(protocol.toUtf8(), model.toUtf8(), id, dataType, value, DATA_LENGTH, (int *)×tamp);
|
||||||
|
QVariantMap retval;
|
||||||
|
retval["value"] = value;
|
||||||
|
retval["timestamp"] = QDateTime::fromTime_t(timestamp);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
|
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
|
||||||
char *errorString = tdGetErrorString( errorId );
|
char *errorString = tdGetErrorString( errorId );
|
||||||
QString message = QString::fromUtf8( errorString );
|
QString message = QString::fromUtf8( errorString );
|
||||||
|
|
|
@ -29,6 +29,7 @@ public slots:
|
||||||
int methods( int deviceId, int methodsSupported );
|
int methods( int deviceId, int methodsSupported );
|
||||||
|
|
||||||
QVariant sensor() const;
|
QVariant sensor() const;
|
||||||
|
QVariant sensorValue(const QString &protocol, const QString &model, int id, int dataType) const;
|
||||||
|
|
||||||
int turnOn( int deviceId );
|
int turnOn( int deviceId );
|
||||||
int turnOff( int deviceId );
|
int turnOff( int deviceId );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue