Add discoveryParams to DeviceClass

Fixes #12
This commit is contained in:
Michael Zanetti 2014-05-05 20:40:02 +02:00
parent 1ffe5ee721
commit b07433a8b5
6 changed files with 35 additions and 4 deletions

11
debian/changelog vendored
View File

@ -1,9 +1,14 @@
guh (0.1.3) UNRELEASED; urgency=medium guh (0.1.4) trusty; urgency=medium
* Add discoveryParams to DeviceClass
-- Michael Zanetti <micha@noneyet> Mon, 05 May 2014 20:30:49 +0200
guh (0.1.3) trusty; urgency=medium
* Added Actions.GetActionType(actionTypeId) to JSONRPC * Added Actions.GetActionType(actionTypeId) to JSONRPC
*
-- Michael Zanetti <micha@noneyet> Mon, 05 May 2014 20:26:49 +0200 -- Michael Zanetti <micha@noneyet> Mon, 05 May 2014 20:30:38 +0200
guh (0.1.2) trusty; urgency=medium guh (0.1.2) trusty; urgency=medium

View File

@ -141,6 +141,16 @@ void DeviceClass::setParams(const QList<ParamType> &params)
m_params = params; m_params = params;
} }
QList<ParamType> DeviceClass::discoveryParams() const
{
return m_discoveryParams;
}
void DeviceClass::setDiscoveryParams(const QList<ParamType> &params)
{
m_discoveryParams = params;
}
DeviceClass::CreateMethod DeviceClass::createMethod() const DeviceClass::CreateMethod DeviceClass::createMethod() const
{ {
return m_createMethod; return m_createMethod;

View File

@ -66,6 +66,9 @@ public:
QList<ParamType> params() const; QList<ParamType> params() const;
void setParams(const QList<ParamType> &params); void setParams(const QList<ParamType> &params);
QList<ParamType> discoveryParams() const;
void setDiscoveryParams(const QList<ParamType> &params);
CreateMethod createMethod() const; CreateMethod createMethod() const;
void setCreateMethod(CreateMethod createMethod); void setCreateMethod(CreateMethod createMethod);
SetupMethod setupMethod() const; SetupMethod setupMethod() const;
@ -82,6 +85,7 @@ private:
QList<EventType> m_events; QList<EventType> m_events;
QList<ActionType> m_actions; QList<ActionType> m_actions;
QList<ParamType> m_params; QList<ParamType> m_params;
QList<ParamType> m_discoveryParams;
CreateMethod m_createMethod; CreateMethod m_createMethod;
SetupMethod m_setupMethod; SetupMethod m_setupMethod;
}; };

View File

@ -325,6 +325,9 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
ParamType locationParam("location", QVariant::String); ParamType locationParam("location", QVariant::String);
params.append(locationParam); params.append(locationParam);
//Location is all we need for discovery.
deviceClassOpenweathermap.setDiscoveryParams(params);
ParamType countryParam("country", QVariant::String); ParamType countryParam("country", QVariant::String);
params.append(countryParam); params.append(countryParam);

View File

@ -128,6 +128,7 @@ void JsonTypes::init()
s_deviceClass.insert("events", QVariantList() << eventTypeRef()); s_deviceClass.insert("events", QVariantList() << eventTypeRef());
s_deviceClass.insert("actions", QVariantList() << actionTypeRef()); s_deviceClass.insert("actions", QVariantList() << actionTypeRef());
s_deviceClass.insert("params", QVariantList() << paramTypeRef()); s_deviceClass.insert("params", QVariantList() << paramTypeRef());
s_deviceClass.insert("discoveryParams", QVariantList() << paramTypeRef());
s_deviceClass.insert("setupMethod", setupMethodTypesRef()); s_deviceClass.insert("setupMethod", setupMethodTypesRef());
s_deviceClass.insert("createMethod", createMethodTypesRef()); s_deviceClass.insert("createMethod", createMethodTypesRef());
@ -319,8 +320,13 @@ QVariantMap JsonTypes::packDeviceClass(const DeviceClass &deviceClass)
foreach (const ParamType &paramType, deviceClass.params()) { foreach (const ParamType &paramType, deviceClass.params()) {
paramTypes.append(packParamType(paramType)); paramTypes.append(packParamType(paramType));
} }
QVariantList discoveryParamTypes;
foreach (const ParamType &paramType, deviceClass.discoveryParams()) {
discoveryParamTypes.append(packParamType(paramType));
}
variant.insert("params", paramTypes); variant.insert("params", paramTypes);
variant.insert("discoveryParams", discoveryParamTypes);
variant.insert("states", stateTypes); variant.insert("states", stateTypes);
variant.insert("events", eventTypes); variant.insert("events", eventTypes);
variant.insert("actions", actionTypes); variant.insert("actions", actionTypes);

View File

@ -1,4 +1,4 @@
0.1.3 0.1.4
{ {
"methods": { "methods": {
"Actions.ExecuteAction": { "Actions.ExecuteAction": {
@ -296,6 +296,9 @@
"$ref:ActionType" "$ref:ActionType"
], ],
"createMethod": "$ref:CreateMethodType", "createMethod": "$ref:CreateMethodType",
"discoveryParams": [
"$ref:ParamType"
],
"events": [ "events": [
"$ref:EventType" "$ref:EventType"
], ],