some more device -> thing
This commit is contained in:
parent
0c205e3edc
commit
3032e5f2df
@ -450,7 +450,7 @@ void LogsModelNg::newLogEntryReceived(const QVariantMap &data)
|
||||
m_list.prepend(entry);
|
||||
if (m_graphSeries) {
|
||||
|
||||
Thing *dev = m_engine->thingManager()->devices()->getThing(entry->thingId());
|
||||
Thing *dev = m_engine->thingManager()->things()->getThing(entry->thingId());
|
||||
|
||||
StateType *entryStateType = dev->thingClass()->stateTypes()->getStateType(entry->typeId());
|
||||
|
||||
|
||||
@ -96,11 +96,6 @@ ThingClass *ThingClasses::getThingClass(QUuid thingClassId) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ThingClass *ThingClasses::getDeviceClass(QUuid thingClassId) const
|
||||
{
|
||||
return getThingClass(thingClassId);
|
||||
}
|
||||
|
||||
void ThingClasses::addThingClass(ThingClass *thingClass)
|
||||
{
|
||||
thingClass->setParent(this);
|
||||
|
||||
@ -28,8 +28,8 @@
|
||||
*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef DEVICECLASSMODEL_H
|
||||
#define DEVICECLASSMODEL_H
|
||||
#ifndef THINGCLASSES_H
|
||||
#define THINGCLASSES_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
@ -60,7 +60,6 @@ public:
|
||||
Q_INVOKABLE int count() const;
|
||||
Q_INVOKABLE ThingClass *get(int index) const;
|
||||
Q_INVOKABLE ThingClass *getThingClass(QUuid thingClassId) const;
|
||||
Q_INVOKABLE ThingClass *getDeviceClass(QUuid thingClassId) const;
|
||||
|
||||
void addThingClass(ThingClass *thingClass);
|
||||
|
||||
@ -77,4 +76,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif // DEVICECLASSMODEL_H
|
||||
#endif // THINGCLASSES_H
|
||||
|
||||
@ -69,7 +69,7 @@ QHash<int, QByteArray> ThingDiscovery::roleNames() const
|
||||
return roles;
|
||||
}
|
||||
|
||||
void ThingDiscovery::discoverThings(const QUuid &deviceClassId, const QVariantList &discoveryParams)
|
||||
void ThingDiscovery::discoverThings(const QUuid &thingClassId, const QVariantList &discoveryParams)
|
||||
{
|
||||
if (m_busy) {
|
||||
qWarning() << "Busy... not restarting discovery";
|
||||
@ -81,20 +81,20 @@ void ThingDiscovery::discoverThings(const QUuid &deviceClassId, const QVariantLi
|
||||
emit countChanged();
|
||||
|
||||
if (!m_engine) {
|
||||
qWarning() << "Cannot discover devices. No Engine set";
|
||||
qWarning() << "Cannot discover things. No Engine set";
|
||||
return;
|
||||
}
|
||||
if (!m_engine->jsonRpcClient()->connected()) {
|
||||
qWarning() << "Cannot discover devices. Not connected.";
|
||||
qWarning() << "Cannot discover things. Not connected.";
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap params;
|
||||
params.insert("deviceClassId", deviceClassId.toString());
|
||||
params.insert("thingClassId", thingClassId.toString());
|
||||
if (!discoveryParams.isEmpty()) {
|
||||
params.insert("discoveryParams", discoveryParams);
|
||||
}
|
||||
m_engine->jsonRpcClient()->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverThingsResponse");
|
||||
m_engine->jsonRpcClient()->sendCommand("Integrations.DiscoverThings", params, this, "discoverThingsResponse");
|
||||
m_busy = true;
|
||||
m_displayMessage.clear();
|
||||
emit busyChanged();
|
||||
|
||||
@ -87,11 +87,6 @@ Plugins *ThingManager::plugins() const
|
||||
return m_plugins;
|
||||
}
|
||||
|
||||
Things *ThingManager::devices() const
|
||||
{
|
||||
return m_things;
|
||||
}
|
||||
|
||||
Things *ThingManager::things() const
|
||||
{
|
||||
return m_things;
|
||||
@ -102,11 +97,6 @@ ThingClasses *ThingManager::thingClasses() const
|
||||
return m_thingClasses;
|
||||
}
|
||||
|
||||
ThingClasses *ThingManager::deviceClasses() const
|
||||
{
|
||||
return m_thingClasses;
|
||||
}
|
||||
|
||||
IOConnections *ThingManager::ioConnections() const
|
||||
{
|
||||
return m_ioConnections;
|
||||
@ -241,9 +231,9 @@ void ThingManager::getVendorsResponse(int /*commandId*/, const QVariantMap ¶
|
||||
void ThingManager::getThingClassesResponse(int /*commandId*/, const QVariantMap ¶ms)
|
||||
{
|
||||
if (params.keys().contains("thingClasses")) {
|
||||
QVariantList deviceClassList = params.value("thingClasses").toList();
|
||||
foreach (QVariant deviceClassVariant, deviceClassList) {
|
||||
ThingClass *thingClass = unpackThingClass(deviceClassVariant.toMap());
|
||||
QVariantList thingClassList = params.value("thingClasses").toList();
|
||||
foreach (QVariant thingClassVariant, thingClassList) {
|
||||
ThingClass *thingClass = unpackThingClass(thingClassVariant.toMap());
|
||||
m_thingClasses->addThingClass(thingClass);
|
||||
}
|
||||
}
|
||||
@ -325,7 +315,7 @@ void ThingManager::getThingsResponse(int /*commandId*/, const QVariantMap ¶m
|
||||
thing->setStateValue(stateTypeId, value);
|
||||
// qDebug() << "Set thing state value:" << thing->stateValue(stateTypeId) << value;
|
||||
}
|
||||
devices()->addThing(thing);
|
||||
things()->addThing(thing);
|
||||
}
|
||||
}
|
||||
qDebug() << "Initializing thing manager took" << m_connectionBenchmark.msecsTo(QDateTime::currentDateTime()) << "ms";
|
||||
@ -422,7 +412,7 @@ int ThingManager::savePluginConfig(const QUuid &pluginId)
|
||||
|
||||
ThingGroup *ThingManager::createGroup(Interface *interface, ThingsProxy *things)
|
||||
{
|
||||
ThingGroup* group = new ThingGroup(this, interface->createDeviceClass(), things, this);
|
||||
ThingGroup* group = new ThingGroup(this, interface->createThingClass(), things, this);
|
||||
group->setSetupStatus(Thing::ThingSetupStatusComplete, QString());
|
||||
return group;
|
||||
}
|
||||
|
||||
@ -55,9 +55,7 @@ class ThingManager : public JsonHandler
|
||||
Q_PROPERTY(Vendors* vendors READ vendors CONSTANT)
|
||||
Q_PROPERTY(Plugins* plugins READ plugins CONSTANT)
|
||||
Q_PROPERTY(Things* things READ things CONSTANT)
|
||||
Q_PROPERTY(Things* devices READ devices CONSTANT)
|
||||
Q_PROPERTY(ThingClasses* thingClasses READ thingClasses CONSTANT)
|
||||
Q_PROPERTY(ThingClasses* deviceClasses READ thingClasses CONSTANT)
|
||||
Q_PROPERTY(IOConnections* ioConnections READ ioConnections CONSTANT)
|
||||
|
||||
Q_PROPERTY(bool fetchingData READ fetchingData NOTIFY fetchingDataChanged)
|
||||
@ -80,10 +78,8 @@ public:
|
||||
|
||||
Vendors* vendors() const;
|
||||
Plugins* plugins() const;
|
||||
Things* devices() const;
|
||||
Things* things() const;
|
||||
ThingClasses* thingClasses() const;
|
||||
ThingClasses* deviceClasses() const;
|
||||
IOConnections* ioConnections() const;
|
||||
|
||||
bool fetchingData() const;
|
||||
@ -158,7 +154,7 @@ signals:
|
||||
private:
|
||||
static Vendor *unpackVendor(const QVariantMap &vendorMap);
|
||||
static Plugin *unpackPlugin(const QVariantMap &pluginMap, QObject *parent);
|
||||
static ThingClass *unpackThingClass(const QVariantMap &deviceClassMap);
|
||||
static ThingClass *unpackThingClass(const QVariantMap &thingClassMap);
|
||||
static void unpackParam(const QVariantMap ¶mMap, Param *param);
|
||||
static ParamType *unpackParamType(const QVariantMap ¶mTypeMap, QObject *parent);
|
||||
static StateType *unpackStateType(const QVariantMap &stateTypeMap, QObject *parent);
|
||||
|
||||
@ -78,7 +78,6 @@ QVariant Things::data(const QModelIndex &index, int role) const
|
||||
return thing->name();
|
||||
case RoleId:
|
||||
return thing->id().toString();
|
||||
case RoleDeviceClass:
|
||||
case RoleThingClass:
|
||||
return thing->thingClassId().toString();
|
||||
case RoleParentId:
|
||||
@ -145,7 +144,6 @@ QHash<int, QByteArray> Things::roleNames() const
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[RoleName] = "name";
|
||||
roles[RoleId] = "id";
|
||||
roles[RoleDeviceClass] = "deviceClassId";
|
||||
roles[RoleThingClass] = "thingClassId";
|
||||
roles[RoleParentId] = "parentId";
|
||||
roles[RoleSetupStatus] = "setupStatus";
|
||||
|
||||
@ -45,7 +45,6 @@ public:
|
||||
RoleName,
|
||||
RoleId,
|
||||
RoleParentId,
|
||||
RoleDeviceClass,
|
||||
RoleThingClass,
|
||||
RoleSetupStatus,
|
||||
RoleSetupDisplayMessage,
|
||||
|
||||
@ -71,7 +71,7 @@ ActionTypes* Interface::actionTypes() const
|
||||
return m_actionTypes;
|
||||
}
|
||||
|
||||
ThingClass *Interface::createDeviceClass()
|
||||
ThingClass *Interface::createThingClass()
|
||||
{
|
||||
ThingClass* dc = new ThingClass();
|
||||
dc->setName(m_name);
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
StateTypes* stateTypes() const;
|
||||
ActionTypes* actionTypes() const;
|
||||
|
||||
ThingClass* createDeviceClass();
|
||||
ThingClass* createThingClass();
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
|
||||
@ -263,7 +263,7 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||
RuleAction *ra = rule->actions()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) {
|
||||
dbg << "Device ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl;
|
||||
dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl;
|
||||
} else {
|
||||
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;
|
||||
}
|
||||
@ -284,7 +284,7 @@ QDebug operator <<(QDebug &dbg, Rule *rule)
|
||||
RuleAction *ra = rule->exitActions()->get(i);
|
||||
dbg << " " << i << ":";
|
||||
if (!ra->thingId().isNull() && !ra->actionTypeId().isNull()) {
|
||||
dbg << "Device ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl;;
|
||||
dbg << "Thing ID:" << ra->thingId() << "Action Type ID:" << ra->actionTypeId() << endl;;
|
||||
} else {
|
||||
dbg << "Interface Name:" << ra->interfaceName() << "Action Name:" << ra->interfaceAction() << endl;;
|
||||
}
|
||||
@ -306,7 +306,7 @@ QDebug printStateEvaluator(QDebug &dbg, StateEvaluator *stateEvaluator, int inde
|
||||
for (int i = 0; i < indentLevel; i++) { dbg << " "; }
|
||||
dbg << "State Descriptor:";
|
||||
if (!stateEvaluator->stateDescriptor()->thingId().isNull() && !stateEvaluator->stateDescriptor()->stateTypeId().isNull()) {
|
||||
dbg << "Device ID:" << stateEvaluator->stateDescriptor()->thingId().toString() << "State Type ID:" << stateEvaluator->stateDescriptor()->stateTypeId().toString();
|
||||
dbg << "Thing ID:" << stateEvaluator->stateDescriptor()->thingId().toString() << "State Type ID:" << stateEvaluator->stateDescriptor()->stateTypeId().toString();
|
||||
} else {
|
||||
dbg << "Interface name:" << stateEvaluator->stateDescriptor()->interfaceName() << "State Name:" << stateEvaluator->stateDescriptor()->interfaceState();
|
||||
}
|
||||
|
||||
@ -69,11 +69,6 @@ void Thing::setId(const QUuid &id)
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QUuid Thing::deviceClassId() const
|
||||
{
|
||||
return m_thingClass->id();
|
||||
}
|
||||
|
||||
QUuid Thing::thingClassId() const
|
||||
{
|
||||
return m_thingClass->id();
|
||||
|
||||
@ -45,7 +45,6 @@ class Thing : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUuid id READ id CONSTANT)
|
||||
Q_PROPERTY(QUuid deviceClassId READ deviceClassId CONSTANT)
|
||||
Q_PROPERTY(QUuid thingClassId READ thingClassId CONSTANT)
|
||||
Q_PROPERTY(QUuid parentId READ parentId CONSTANT)
|
||||
Q_PROPERTY(bool isChild READ isChild CONSTANT)
|
||||
@ -55,7 +54,6 @@ class Thing : public QObject
|
||||
Q_PROPERTY(Params *params READ params NOTIFY paramsChanged)
|
||||
Q_PROPERTY(Params *settings READ settings NOTIFY settingsChanged)
|
||||
Q_PROPERTY(States *states READ states NOTIFY statesChanged)
|
||||
Q_PROPERTY(ThingClass *deviceClass READ thingClass CONSTANT)
|
||||
Q_PROPERTY(ThingClass *thingClass READ thingClass CONSTANT)
|
||||
|
||||
public:
|
||||
@ -106,7 +104,6 @@ public:
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
QUuid deviceClassId() const;
|
||||
QUuid thingClassId() const;
|
||||
QUuid parentId() const;
|
||||
bool isChild() const;
|
||||
|
||||
@ -217,15 +217,15 @@ MainPageTile {
|
||||
|
||||
property int currentDeviceIndex: 0
|
||||
readonly property Thing currentDevice: thingsProxy.get(currentDeviceIndex)
|
||||
readonly property StateType playbackStateType: currentDevice.deviceClass.stateTypes.findByName("playbackStatus")
|
||||
readonly property StateType playbackStateType: currentDevice.thingClass.stateTypes.findByName("playbackStatus")
|
||||
readonly property State playbackState: currentDevice.states.getState(playbackStateType.id)
|
||||
readonly property StateType artworkStateType: currentDevice.deviceClass.stateTypes.findByName("artwork")
|
||||
readonly property StateType artworkStateType: currentDevice.thingClass.stateTypes.findByName("artwork")
|
||||
readonly property State artworkState: artworkStateType ? currentDevice.states.getState(artworkStateType.id) : null
|
||||
|
||||
Component.onCompleted: {
|
||||
for (var i = 0; i < thingsProxy.count; i++) {
|
||||
var d = thingsProxy.get(i);
|
||||
var st = d.deviceClass.stateTypes.findByName("playbackStatus")
|
||||
var st = d.thingClass.stateTypes.findByName("playbackStatus")
|
||||
var s = d.states.getState(st.id)
|
||||
s.valueChanged.connect(function() {inlineMediaControl.updateTile()})
|
||||
}
|
||||
@ -237,7 +237,7 @@ MainPageTile {
|
||||
var pausedIndex = -1;
|
||||
for (var i = 0; i < thingsProxy.count; i++) {
|
||||
var d = thingsProxy.get(i);
|
||||
var st = d.deviceClass.stateTypes.findByName("playbackStatus");
|
||||
var st = d.thingClass.stateTypes.findByName("playbackStatus");
|
||||
if (!st) continue;
|
||||
var s = d.states.getState(st.id);
|
||||
if (playingIndex === -1 && s.value === "Playing") {
|
||||
|
||||
@ -44,11 +44,11 @@ Item {
|
||||
readonly property Thing duwWpDevice: duwWpFilterModel.count > 0 ? duwWpFilterModel.get(0) : null
|
||||
readonly property Thing duwLuDevice: duwLuFilterModel.count > 0 ? duwLuFilterModel.get(0) : null
|
||||
|
||||
readonly property State temperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.deviceClass.stateTypes.findByName("temperature").id) : null
|
||||
readonly property State targetTemperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.deviceClass.stateTypes.findByName("targetTemperature").id) : null
|
||||
readonly property State co2LevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("co2").id) : null
|
||||
readonly property State ventilationModeState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("ventilationMode").id) : null
|
||||
readonly property State ventilationLevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.deviceClass.stateTypes.findByName("activeVentilationLevel").id) : null
|
||||
readonly property State temperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.thingClass.stateTypes.findByName("temperature").id) : null
|
||||
readonly property State targetTemperatureState: duwWpDevice ? duwWpDevice.states.getState(duwWpDevice.thingClass.stateTypes.findByName("targetTemperature").id) : null
|
||||
readonly property State co2LevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.thingClass.stateTypes.findByName("co2").id) : null
|
||||
readonly property State ventilationModeState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.thingClass.stateTypes.findByName("ventilationMode").id) : null
|
||||
readonly property State ventilationLevelState: duwLuDevice ? duwLuDevice.states.getState(duwLuDevice.thingClass.stateTypes.findByName("activeVentilationLevel").id) : null
|
||||
|
||||
function ventilationModeToSliderValue(ventilationMode) {
|
||||
switch (ventilationMode) {
|
||||
|
||||
@ -44,7 +44,6 @@ Page {
|
||||
|
||||
// Optional: If set, it will be reconfigred, otherwise a new one will be created
|
||||
property Thing thing: null
|
||||
property alias device: root.thing // Transitional, use thing instead
|
||||
|
||||
signal done();
|
||||
|
||||
@ -89,14 +88,14 @@ Page {
|
||||
}
|
||||
} else if (root.thingClass.createMethods.indexOf("CreateMethodUser") !== -1) {
|
||||
print("CreateMethodUser")
|
||||
// Setting up a new device
|
||||
// Setting up a new thing
|
||||
if (!root.thing) {
|
||||
print("New thing setup")
|
||||
internalPageStack.push(paramsPage)
|
||||
|
||||
// Reconfigure
|
||||
} else if (root.thing) {
|
||||
print("Existing device")
|
||||
print("Existing thing")
|
||||
// There are params. Open params page in any case
|
||||
if (root.thingClass.paramTypes.count > 0) {
|
||||
print("Params:", root.thingClass.paramTypes.count)
|
||||
|
||||
Reference in New Issue
Block a user