Migrate to nymea
This commit is contained in:
parent
d223ca9caf
commit
1eb94bea51
@ -1,20 +1,23 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2017 Bernhard Trinnes <bernhard.trinnes@guh.io> *
|
||||
* Copyright (C) 2018 Simon Stürz <simon.stuerz@guh.io> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* This file is part of nymea. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2.1 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
@ -22,18 +25,156 @@
|
||||
#include "plugininfo.h"
|
||||
#include <QJsonDocument>
|
||||
|
||||
|
||||
|
||||
DevicePluginUniPi::DevicePluginUniPi()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DevicePluginUniPi::~DevicePluginUniPi()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == neuronDeviceClassId) {
|
||||
|
||||
int port = device->paramValue(neuronPortParamTypeId).toInt();
|
||||
|
||||
m_webSocket = new QWebSocket();
|
||||
connect(m_webSocket, &QWebSocket::connected, this, &DevicePluginUniPi::onWebSocketConnected);
|
||||
connect(m_webSocket, &QWebSocket::disconnected, this, &DevicePluginUniPi::onWebSocketDisconnected);
|
||||
|
||||
QUrl url = QUrl("ws://localhost/ws");
|
||||
url.setPort(port);
|
||||
qCDebug(dcUniPi()) << "Conneting to:" << url.toString();
|
||||
m_webSocket->open(url);
|
||||
m_parentId = device->id();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Relay Ouput %1").arg(device->paramValue(relayOutputRelayNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(relayOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Digital Output %1").arg(device->paramValue(digitalOutputDigitalOutputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(digitalOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalInputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Digital Input %1").arg(device->paramValue(digitalInputDigitalInputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(digitalInputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogInputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Analog Input %1").arg(device->paramValue(analogInputAnalogInputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(analogInputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Analog Output %1").arg(device->paramValue(analogOutputAnalogOutputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(analogOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::postSetupDevice(Device *device)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::deviceRemoved(Device *device)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
|
||||
m_webSocket->close();
|
||||
m_webSocket->deleteLater();
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
if (action.actionTypeId() == relayOutputRelayStatusActionTypeId) {
|
||||
QString relayNumber = device->paramValue(relayOutputRelayNumberParamTypeId).toString();
|
||||
int stateValue = action.param(relayOutputRelayStatusStateParamTypeId).value().toInt();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "relay";
|
||||
json["circuit"] = relayNumber;
|
||||
json["value"] = stateValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson(QJsonDocument::Compact);
|
||||
qCDebug(dcUniPi()) << "Send command" << bytes;
|
||||
m_webSocket->sendBinaryMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
if (action.actionTypeId() == digitalOutputDigitalOutputStatusActionTypeId) {
|
||||
int digitalOutputNumber = device->paramValue(digitalOutputDigitalOutputNumberParamTypeId).toInt();
|
||||
int stateValue = action.param(digitalOutputDigitalOutputStatusStateParamTypeId).value().toInt();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "do";
|
||||
json["circuit"] = digitalOutputNumber;
|
||||
json["value"] = stateValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson();
|
||||
m_webSocket->sendTextMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
|
||||
if (action.actionTypeId() == analogOutputAnalogOutputValueActionTypeId) {
|
||||
int analogOutputNumber = device->paramValue(analogOutputAnalogOutputNumberParamTypeId).toInt();
|
||||
double analogValue = device->paramValue(analogOutputAnalogOutputValueStateParamTypeId).toDouble();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "ao";
|
||||
json["circuit"] = analogOutputNumber;
|
||||
json["value"] = analogValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson();
|
||||
m_webSocket->sendTextMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::createAutoDevice(GPIOType gpioType, DeviceId parentDeviceId, QString deviceName)
|
||||
{
|
||||
@ -101,147 +242,9 @@ void DevicePluginUniPi::createAutoDevice(GPIOType gpioType, DeviceId parentDevic
|
||||
}
|
||||
}
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginUniPi::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == neuronDeviceClassId) {
|
||||
|
||||
int port = device->paramValue(neuronPortParamTypeId).toInt();
|
||||
|
||||
m_webSocket = new QWebSocket();
|
||||
connect(m_webSocket, &QWebSocket::connected, this, &DevicePluginUniPi::onWebSocketConnected);
|
||||
connect(m_webSocket, &QWebSocket::disconnected, this, &DevicePluginUniPi::onWebSocketDisconnected);
|
||||
|
||||
QUrl url = QUrl("ws://localhost/ws");
|
||||
url.setPort(port);
|
||||
qDebug(dcUniPi()) << "Conneting to:" << url.toString();
|
||||
m_webSocket->open(url);
|
||||
m_parentId = device->id();
|
||||
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Relay Ouput %1").arg(device->paramValue(relayOutputRelayNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(relayOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Digital Output %1").arg(device->paramValue(digitalOutputDigitalOutputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(digitalOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == digitalInputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Digital Input %1").arg(device->paramValue(digitalInputDigitalInputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(digitalInputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogInputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Analog Input %1").arg(device->paramValue(analogInputAnalogInputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(analogInputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
|
||||
device->setName(QString("Analog Output %1").arg(device->paramValue(analogOutputAnalogOutputNumberParamTypeId).toString()));
|
||||
device->setParentId(device->paramValue(analogOutputParentIdParamTypeId).toString());
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
void DevicePluginUniPi::postSetupDevice(Device *device)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUniPi::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
if (device->deviceClassId() == relayOutputDeviceClassId) {
|
||||
|
||||
if (action.actionTypeId() == relayOutputRelayStatusActionTypeId) {
|
||||
QString relayNumber = device->paramValue(relayOutputRelayNumberParamTypeId).toString();
|
||||
int stateValue = action.param(relayOutputRelayStatusStateParamTypeId).value().toInt();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "relay";
|
||||
json["circuit"] = relayNumber;
|
||||
json["value"] = stateValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson(QJsonDocument::Compact);
|
||||
qDebug(dcUniPi()) << "Send command" << bytes;
|
||||
m_webSocket->sendBinaryMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
if (action.actionTypeId() == digitalOutputDigitalOutputStatusActionTypeId) {
|
||||
int digitalOutputNumber = device->paramValue(digitalOutputDigitalOutputNumberParamTypeId).toInt();
|
||||
int stateValue = action.param(digitalOutputDigitalOutputStatusStateParamTypeId).value().toInt();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "do";
|
||||
json["circuit"] = digitalOutputNumber;
|
||||
json["value"] = stateValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson();
|
||||
m_webSocket->sendTextMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == analogOutputDeviceClassId) {
|
||||
|
||||
if (action.actionTypeId() == analogOutputAnalogOutputValueActionTypeId) {
|
||||
int analogOutputNumber = device->paramValue(analogOutputAnalogOutputNumberParamTypeId).toInt();
|
||||
double analogValue = device->paramValue(analogOutputAnalogOutputValueStateParamTypeId).toDouble();
|
||||
|
||||
QJsonObject json;
|
||||
json["cmd"] = "set";
|
||||
json["dev"] = "ao";
|
||||
json["circuit"] = analogOutputNumber;
|
||||
json["value"] = analogValue;
|
||||
|
||||
QJsonDocument doc(json);
|
||||
QByteArray bytes = doc.toJson();
|
||||
m_webSocket->sendTextMessage(bytes);
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return DeviceManager::DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
|
||||
void DevicePluginUniPi::deviceRemoved(Device *device)
|
||||
{
|
||||
Q_UNUSED(device);
|
||||
|
||||
m_webSocket->close();
|
||||
m_webSocket->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void DevicePluginUniPi::onWebSocketConnected()
|
||||
{
|
||||
qDebug(dcUniPi()) << "WebSocket connected";
|
||||
qCDebug(dcUniPi()) << "WebSocket connected";
|
||||
|
||||
connect(m_webSocket, &QWebSocket::textMessageReceived,
|
||||
this, &DevicePluginUniPi::onWebSocketTextMessageReceived);
|
||||
@ -256,7 +259,7 @@ void DevicePluginUniPi::onWebSocketConnected()
|
||||
|
||||
void DevicePluginUniPi::onWebSocketDisconnected()
|
||||
{
|
||||
qDebug(dcUniPi()) << "WebSocket disconnected";
|
||||
qCDebug(dcUniPi()) << "WebSocket disconnected";
|
||||
|
||||
//send signal device Setup was successfull
|
||||
}
|
||||
@ -275,10 +278,10 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
} else if (doc.isArray()){
|
||||
array = doc.array();
|
||||
}else {
|
||||
qDebug(dcUniPi()) << "Document is not an object nor an array";
|
||||
qCDebug(dcUniPi()) << "Document is not an object nor an array";
|
||||
}
|
||||
} else {
|
||||
qDebug(dcUniPi()) << "Invalid JSON";
|
||||
qCDebug(dcUniPi()) << "Invalid JSON";
|
||||
}
|
||||
|
||||
for (int levelIndex = 0; levelIndex < array.size(); ++levelIndex) {
|
||||
@ -286,12 +289,12 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
|
||||
if (obj["cmd"] == "all") {
|
||||
//read model number
|
||||
qDebug(dcUniPi()) << message;
|
||||
qCDebug(dcUniPi()) << message;
|
||||
|
||||
}
|
||||
|
||||
if (obj["dev"] == "relay") {
|
||||
qDebug(dcUniPi()) << "Relay:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
qCDebug(dcUniPi()) << "Relay:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
|
||||
bool newDevice = true;
|
||||
foreach (Device *device, myDevices()) {
|
||||
@ -304,13 +307,13 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
}
|
||||
if (newDevice) {
|
||||
qDebug(dcUniPi()) << "New Device detected";
|
||||
qCDebug(dcUniPi()) << "New Device detected";
|
||||
createAutoDevice(GPIOType::relay, m_parentId, obj["circuit"].toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (obj["dev"] == "input") {
|
||||
qDebug(dcUniPi()) << "Input:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
qCDebug(dcUniPi()) << "Input:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
|
||||
bool newDevice = true;
|
||||
foreach (Device *device, myDevices()) {
|
||||
@ -329,7 +332,7 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
|
||||
if (obj["dev"] == "output") {
|
||||
qDebug(dcUniPi()) << "Output:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
qCDebug(dcUniPi()) << "Output:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt();
|
||||
|
||||
bool newDevice = true;
|
||||
foreach (Device *device, myDevices()) {
|
||||
@ -349,7 +352,7 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
|
||||
if (obj["dev"] == "ao") {
|
||||
qDebug(dcUniPi()) << "Analog Output:" << obj["dev"] << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toDouble();
|
||||
qCDebug(dcUniPi()) << "Analog Output:" << obj["dev"] << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toDouble();
|
||||
|
||||
bool newDevice = true;
|
||||
foreach (Device *device, myDevices()) {
|
||||
@ -369,7 +372,7 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
|
||||
if (obj["dev"] == "ai") {
|
||||
qDebug(dcUniPi()) << "Analog Input:" << obj["dev"] << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toDouble();
|
||||
qCDebug(dcUniPi()) << "Analog Input:" << obj["dev"] << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toDouble();
|
||||
|
||||
bool newDevice = true;
|
||||
foreach (Device *device, myDevices()) {
|
||||
|
||||
@ -1,20 +1,23 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2017 Bernhard Trinnes <bernhard.trinnes@guh.io> *
|
||||
* Copyright (C) 2018 Simon Stürz <simon.stuerz@guh.io> *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* This file is part of nymea. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2.1 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* Guh is distributed in the hope that it will be useful, *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; If not, see *
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
@ -29,17 +32,18 @@ class DevicePluginUniPi : public DevicePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginunipi.json")
|
||||
Q_PLUGIN_METADATA(IID "io.nymea.DevicePlugin" FILE "devicepluginunipi.json")
|
||||
Q_INTERFACES(DevicePlugin)
|
||||
|
||||
public:
|
||||
|
||||
explicit DevicePluginUniPi();
|
||||
~DevicePluginUniPi();
|
||||
|
||||
void init() override;
|
||||
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
void init() override;
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private:
|
||||
@ -53,7 +57,7 @@ private:
|
||||
};
|
||||
|
||||
DeviceId m_parentId;
|
||||
QWebSocket *m_webSocket;
|
||||
QWebSocket *m_webSocket = nullptr;
|
||||
|
||||
void createAutoDevice(GPIOType gpioType, DeviceId parentDeviceId, QString deviceName);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"displayName": "uni pi",
|
||||
"displayName": "Uni pi",
|
||||
"name": "UniPi",
|
||||
"id": "26cba644-35ae-40a6-9c48-924198893a5f",
|
||||
"vendors": [
|
||||
@ -14,46 +14,39 @@
|
||||
"displayName": "Neuron",
|
||||
"deviceIcon": "Gateway",
|
||||
"createMethods": ["user"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Device",
|
||||
"Gateway"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Device", "Gateway"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "5329655d-7e91-4b16-9abf-2abc82bf1b3c",
|
||||
"name": "port",
|
||||
"displayName": "port",
|
||||
"displayName": "Port",
|
||||
"type": "int",
|
||||
"defaultValue": "8080"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
],
|
||||
"stateTypes": [
|
||||
]
|
||||
"actionTypes": [ ],
|
||||
"stateTypes": [ ]
|
||||
},
|
||||
{
|
||||
"id": "58f9db7f-fd33-45af-8c98-047b67ae5267",
|
||||
"name": "relayOutput",
|
||||
"displayName": "Relay Output",
|
||||
"displayName": "Relay output",
|
||||
"deviceIcon": "Power",
|
||||
"createMethods": ["auto"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Device"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Device"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "7a09e3ad-452c-4bf4-a00c-f8114ed9a7a1",
|
||||
"name": "relayNumber",
|
||||
"displayName": "relay number",
|
||||
"displayName": "Relay number",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "ebbf4c9c-25a9-45c1-be72-cc01aaea959c",
|
||||
"id": "84d4474b-86b4-4da1-8776-61d587cb9d0f",
|
||||
"name": "parentId",
|
||||
"displayName": "parent ID",
|
||||
"displayName": "Parent ID",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
@ -61,10 +54,10 @@
|
||||
{
|
||||
"id": "f9c01e7b-0523-4cac-905a-d5b20028e021",
|
||||
"name": "relayStatus",
|
||||
"displayName": "relay",
|
||||
"displayName": "Relay",
|
||||
"displayNameEvent": "Relay power changed",
|
||||
"displayNameAction": "Set relay power",
|
||||
"type": "bool",
|
||||
"displayNameAction": "set relay",
|
||||
"displayNameEvent": "relay changed",
|
||||
"defaultValue": false,
|
||||
"writable": true
|
||||
}
|
||||
@ -73,13 +66,11 @@
|
||||
{
|
||||
"id": "0bec278a-98f1-416b-b496-6d00740f178a",
|
||||
"name": "digitalInput",
|
||||
"displayName": "digital input",
|
||||
"displayName": "Digital input",
|
||||
"deviceIcon": "Switch",
|
||||
"createMethods": ["auto"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Sensor"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Sensor"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "9c84d9b8-fdc7-41c1-9559-08f061ffc7a6",
|
||||
@ -98,34 +89,32 @@
|
||||
{
|
||||
"id": "fa4f2764-b7ff-45e7-993b-b6af1840fd3d",
|
||||
"name": "digitalInputStatus",
|
||||
"displayName": "input",
|
||||
"displayName": "Digital input",
|
||||
"displayNameEvent": "Digital input changed",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"displayNameEvent": "input changed"
|
||||
"defaultValue": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "f3a3c5ed-461a-4ca8-930b-df3af821b9e0",
|
||||
"name": "digitalOutput",
|
||||
"displayName": "digital output",
|
||||
"displayName": "Digital output",
|
||||
"deviceIcon": "Power",
|
||||
"createMethods": ["auto"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Device"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Device"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "c01d5bde-de5d-42c5-b462-79745827875a",
|
||||
"name": "digitalOutputNumber",
|
||||
"displayName": "input number",
|
||||
"displayName": "Input number",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "ebbf4c9c-25a9-45c1-be72-cc01aaea959c",
|
||||
"id": "c697d10d-28ba-4680-9db9-094d4af7c6da",
|
||||
"name": "parentId",
|
||||
"displayName": "parent ID",
|
||||
"displayName": "Parent ID",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
@ -134,9 +123,9 @@
|
||||
"id": "470a0e30-a170-47ed-9ed3-c41db919555f",
|
||||
"name": "digitalOutputStatus",
|
||||
"displayName": "digital output",
|
||||
"type": "bool",
|
||||
"displayNameAction": "set digital output",
|
||||
"displayNameEvent": "digital output changed",
|
||||
"type": "bool",
|
||||
"defaultValue": false,
|
||||
"writable": true
|
||||
}
|
||||
@ -145,24 +134,22 @@
|
||||
{
|
||||
"id": "9094a69f-f475-4050-a345-5ab52cb19774",
|
||||
"name": "analogOutput",
|
||||
"displayName": "Analog Output",
|
||||
"displayName": "Analog output",
|
||||
"deviceIcon": "Power",
|
||||
"createMethods": ["auto"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Device"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Device"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "46e606cc-67ee-4891-bc39-8fb0565c87da",
|
||||
"name": "analogOutputNumber",
|
||||
"displayName": "analog output number",
|
||||
"displayName": "Analog output number",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "ebbf4c9c-25a9-45c1-be72-cc01aaea959c",
|
||||
"id": "120ed3a4-bd76-4e86-b550-3b1f1daabfa2",
|
||||
"name": "parentId",
|
||||
"displayName": "parent ID",
|
||||
"displayName": "Parent ID",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
@ -170,11 +157,11 @@
|
||||
{
|
||||
"id": "6d825eb8-6d2a-4ac3-9125-9df8173116c9",
|
||||
"name": "analogOutputValue",
|
||||
"displayName": "analog output",
|
||||
"displayName": "Analog output",
|
||||
"displayNameEvent": "Analog output changed",
|
||||
"displayNameAction": "Set analog output",
|
||||
"type": "double",
|
||||
"unit": "Volt",
|
||||
"displayNameAction": "set analog output",
|
||||
"displayNameEvent": "analog output changed",
|
||||
"minValue": 0.00,
|
||||
"maxValue": 10.00,
|
||||
"defaultValue": 0.00,
|
||||
@ -188,21 +175,19 @@
|
||||
"displayName": "Analog Input",
|
||||
"deviceIcon": "Power",
|
||||
"createMethods": ["auto"],
|
||||
"interface": [],
|
||||
"basicTags": [
|
||||
"Sensor"
|
||||
],
|
||||
"interface": [ ],
|
||||
"basicTags": ["Sensor"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"id": "cc6eb664-9fd2-457d-9d0d-0eb9703db4a2",
|
||||
"name": "analogInputNumber",
|
||||
"displayName": "analog input number",
|
||||
"displayName": "Analog input number",
|
||||
"type": "QString"
|
||||
},
|
||||
{
|
||||
"id": "ebbf4c9c-25a9-45c1-be72-cc01aaea959c",
|
||||
"id": "a4688cb3-54fa-478c-a108-d48cbb3d10e1",
|
||||
"name": "parentId",
|
||||
"displayName": "parent ID",
|
||||
"displayName": "Parent ID",
|
||||
"type": "QString"
|
||||
}
|
||||
],
|
||||
@ -210,10 +195,10 @@
|
||||
{
|
||||
"id": "2296f575-cc53-48ef-9086-6a412abfdde5",
|
||||
"name": "analogInputValue",
|
||||
"displayName": "analog output",
|
||||
"displayName": "Analog input",
|
||||
"displayNameEvent": "Analog input changed",
|
||||
"type": "double",
|
||||
"unit": "Volt",
|
||||
"displayNameEvent": "analog input changed",
|
||||
"defaultValue": 0.00
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
include(../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginunipi)
|
||||
TARGET = $$qtLibraryTarget(nymea_devicepluginunipi)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginunipi.cpp \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user