Add function com.telldus.core.controller() to the script engine to iterate over controllers

This commit is contained in:
Micke Prag 2012-02-23 12:38:56 +01:00
parent 5238978d32
commit d5166d26f8
2 changed files with 22 additions and 0 deletions

View file

@ -136,6 +136,26 @@ QVariant TelldusCoreObject::sensorValue(const QString &protocol, const QString &
return retval;
}
QVariant TelldusCoreObject::controller() const {
const int DATA_LENGTH = 255;
char name[DATA_LENGTH];
int controllerId = 0, available = 0, controllerType = 0;
if (tdController(&controllerId, &controllerType, name, DATA_LENGTH, &available) != TELLSTICK_SUCCESS) {
qDebug() << "Return null";
return 0;
}
QVariantMap retval;
retval["id"] = controllerId;
retval["type"] = controllerType;
retval["name"] = name;
retval["available"] = available;
return retval;
}
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
char *errorString = tdGetErrorString( errorId );
QString message = QString::fromUtf8( errorString );

View file

@ -32,6 +32,8 @@ public slots:
QVariant sensor() const;
QVariant sensorValue(const QString &protocol, const QString &model, int id, int dataType) const;
QVariant controller() const;
int turnOn( int deviceId );
int turnOff( int deviceId );
int up( int deviceId );