diff --git a/debian/guh-plugins.install b/debian/guh-plugins.install index 2641b04f..58f93046 100644 --- a/debian/guh-plugins.install +++ b/debian/guh-plugins.install @@ -13,5 +13,4 @@ usr/lib/guh/plugins/libguh_devicepluginwifidetector.so usr/lib/guh/plugins/libguh_deviceplugindatetime.so usr/lib/guh/plugins/libguh_deviceplugingenericelements.so usr/lib/guh/plugins/libguh_deviceplugincommandlauncher.so -usr/lib/guh/plugins/libguh_devicepluginleynew.so - +usr/lib/guh/plugins/libguh_devicepluginunitec.so diff --git a/plugins/deviceplugins/deviceplugins.pro b/plugins/deviceplugins/deviceplugins.pro index d1fa88ec..4b9f4b19 100644 --- a/plugins/deviceplugins/deviceplugins.pro +++ b/plugins/deviceplugins/deviceplugins.pro @@ -13,7 +13,7 @@ SUBDIRS += elro \ datetime \ genericelements \ commandlauncher \ - leynew \ + unitec \ diff --git a/plugins/deviceplugins/unitec/devicepluginunitec.cpp b/plugins/deviceplugins/unitec/devicepluginunitec.cpp new file mode 100644 index 00000000..364ff729 --- /dev/null +++ b/plugins/deviceplugins/unitec/devicepluginunitec.cpp @@ -0,0 +1,115 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * 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. * + * * + * Guh 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*! + \page unitec.html + \title Unitec + + \ingroup plugins + \ingroup rf433 + + This plugin allows to controll RF 433 MHz actors an receive remote signals from \l{www.unitec-elektro.de}{Unitec} + devices. + + \chapter Plugin properties + Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses} + and \l{Vendor}{Vendors} of this \l{DevicePlugin}. + + Each \l{DeviceClass} has a list of \l{ParamType}{paramTypes}, \l{ActionType}{actionTypes}, \l{StateType}{stateTypes} + and \l{EventType}{eventTypes}. The \l{DeviceClass::CreateMethod}{createMethods} parameter describes how the \l{Device} + will be created in the system. A device can have more than one \l{DeviceClass::CreateMethod}{CreateMethod}. + The \l{DeviceClass::SetupMethod}{setupMethod} describes the setup method of the \l{Device}. + The detailed implementation of each \l{DeviceClass} can be found in the source code. + + \quotefile plugins/deviceplugins/elro/devicepluginelro.json +*/ + +#include "devicepluginunitec.h" +#include "devicemanager.h" +#include "plugininfo.h" + +#include +#include + +DevicePluginUnitec::DevicePluginUnitec() +{ +} + +DeviceManager::HardwareResources DevicePluginUnitec::requiredHardware() const +{ + return DeviceManager::HardwareResourceRadio433; +} + +DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, const Action &action) +{ + QList rawData; + QByteArray binCode; + + + // sync signal (20 * 1) + binCode.append("11111111111111111111"); + + // Button ID + if (device->paramValue("Channel").toString() == "A") { + binCode.append("000"); + } else if (device->paramValue("Channel").toString() == "B") { + binCode.append("100"); + } else if (device->paramValue("Channel").toString() == "C") { + binCode.append("010"); + } else if (device->paramValue("Channel").toString() == "D") { + binCode.append("110"); + } else if (device->paramValue("Channel").toString() == "ALL") { + binCode.append("001"); + } + + // power state + if (action.param("power").value().toBool() == true) { + binCode.append("11"); + } else { + binCode.append("01"); + } + + + // ======================================= + //create rawData timings list + int delay = 250; + + // add the code + foreach (QChar c, binCode) { + if(c == '0'){ + rawData.append(3); + rawData.append(1); + }else{ + rawData.append(1); + rawData.append(3); + } + } + + qDebug() << binCode; + qDebug() << rawData; + + // ======================================= + // send data to hardware resource + if(transmitData(delay, rawData)){ + qDebug() << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool(); + return DeviceManager::DeviceErrorNoError; + }else{ + qDebug() << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool(); + return DeviceManager::DeviceErrorHardwareNotAvailable; + } +} diff --git a/plugins/deviceplugins/unitec/devicepluginunitec.h b/plugins/deviceplugins/unitec/devicepluginunitec.h new file mode 100644 index 00000000..a1437f65 --- /dev/null +++ b/plugins/deviceplugins/unitec/devicepluginunitec.h @@ -0,0 +1,41 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * This file is part of guh. * + * * + * 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. * + * * + * Guh 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. * + * * + * You should have received a copy of the GNU General Public License * + * along with guh. If not, see . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef DEVICEPLUGINUNITEC_H +#define DEVICEPLUGINUNITEC_H + +#include "plugin/deviceplugin.h" + +class DevicePluginUnitec : public DevicePlugin +{ + Q_OBJECT + + Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginunitec.json") + Q_INTERFACES(DevicePlugin) + +public: + explicit DevicePluginUnitec(); + + DeviceManager::HardwareResources requiredHardware() const override; + +public slots: + DeviceManager::DeviceError executeAction(Device *device, const Action &action) override; + +}; + +#endif // DEVICEPLUGINUNITEC_H diff --git a/plugins/deviceplugins/unitec/devicepluginunitec.json b/plugins/deviceplugins/unitec/devicepluginunitec.json new file mode 100644 index 00000000..b87ed754 --- /dev/null +++ b/plugins/deviceplugins/unitec/devicepluginunitec.json @@ -0,0 +1,36 @@ + { + "name": "Unitec", + "id": "aefca391-f8bf-4f6c-a205-6764de3c2c3c", + "vendors": [ + { + "name": "Unitec", + "id": "f2cd9a76-5a7f-4c01-bf8c-5eae8b12e95c", + "deviceClasses": [ + { + "deviceClassId": "8468a15d-ecc0-43b6-98ca-e1e4ac9e2df3", + "name": "Unitec switch (48111)", + "createMethods": ["user"], + "paramTypes": [ + { + "name": "Channel", + "type": "QString", + "allowedValues": ["A", "B", "C", "D"] + } + ], + "actionTypes": [ + { + "id": "a85b5443-e91f-4814-a813-c75b04d7a823", + "name": "Set power", + "paramTypes": [ + { + "name": "power", + "type": "bool" + } + ] + } + ] + } + ] + } + ] +} diff --git a/plugins/deviceplugins/unitec/unitec.pro b/plugins/deviceplugins/unitec/unitec.pro new file mode 100644 index 00000000..21a03539 --- /dev/null +++ b/plugins/deviceplugins/unitec/unitec.pro @@ -0,0 +1,11 @@ +include(../../plugins.pri) + +TARGET = $$qtLibraryTarget(guh_devicepluginunitec) + +SOURCES += \ + devicepluginunitec.cpp + +HEADERS += \ + devicepluginunitec.h + +