added wol plugin

temporary goes every 433 data in every 433 plugin...for debugging
This commit is contained in:
Simon Stürz 2014-04-23 22:16:32 +02:00
parent 2a372dd240
commit b593360f6b
14 changed files with 264 additions and 55 deletions

View File

@ -409,9 +409,9 @@ void DeviceManager::loadConfiguredDevices()
QList<Param> params; QList<Param> params;
foreach (QString paramNameString, settings.childGroups()) { foreach (QString paramNameString, settings.childGroups()) {
settings.beginGroup(paramNameString); settings.beginGroup(paramNameString);
Param param(paramNameString.remove(QRegExp("^Param-"))); Param param(paramNameString.remove(QRegExp("Param-")));
param.setValue(settings.value("value")); param.setValue(settings.value("value"));
param.setOperand((Param::OperandType)settings.value("operand").toInt()); // param.setOperand((Param::OperandType)settings.value("operand").toInt());
settings.endGroup(); settings.endGroup();
} }
device->setParams(params); device->setParams(params);
@ -495,13 +495,20 @@ void DeviceManager::slotDeviceStateValueChanged(const QUuid &stateTypeId, const
void DeviceManager::radio433SignalReceived(QList<int> rawData) void DeviceManager::radio433SignalReceived(QList<int> rawData)
{ {
foreach (Device *device, m_configuredDevices) { // TODO: this is just temporary for debugging...
DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId()); foreach (DevicePlugin *plugin, plugins()) {
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
if (plugin->requiredHardware().testFlag(HardwareResourceRadio433)) { if (plugin->requiredHardware().testFlag(HardwareResourceRadio433)) {
plugin->radioData(rawData); plugin->radioData(rawData);
} }
} }
// foreach (Device *device, m_configuredDevices) {
// DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId());
// DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
// if (plugin->requiredHardware().testFlag(HardwareResourceRadio433)) {
// plugin->radioData(rawData);
// }
// }
} }
void DeviceManager::timerEvent() void DeviceManager::timerEvent()

View File

@ -135,12 +135,12 @@ void Radio433::handleInterrupt()
rawData.append(m_timings[i]); rawData.append(m_timings[i]);
m_timings[i] = 0; m_timings[i] = 0;
} }
// qDebug() << "-----------------------------------------------------------"; qDebug() << "-----------------------------------------------------------";
// qDebug() << "| GENERIC signal |"; qDebug() << "| GENERIC signal |";
// qDebug() << "-----------------------------------------------------------"; qDebug() << "-----------------------------------------------------------";
// qDebug() << "signal length :" << 49; qDebug() << "signal length :" << 49;
// qDebug() << "delay :" << rawData.first() /31; qDebug() << "delay :" << rawData.first() /31;
// qDebug() << rawData; qDebug() << rawData;
emit dataReceived(rawData); emit dataReceived(rawData);
break; break;

View File

@ -62,6 +62,7 @@
VendorId conradVendorId = VendorId("986cf06f-3ef1-4271-b2a3-2cc277ebecb6"); VendorId conradVendorId = VendorId("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b"); DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
EventTypeId conradRemoteButtonEventTypeId = EventTypeId("1f4050f5-4c90-4799-8d6d-e4069f3a2519");
DevicePluginConrad::DevicePluginConrad() DevicePluginConrad::DevicePluginConrad()
{ {
@ -85,25 +86,41 @@ QList<DeviceClass> DevicePluginConrad::supportedDevices() const
DeviceClass deviceClassConradRemote(pluginId(), conradVendorId, conradRemoteId); DeviceClass deviceClassConradRemote(pluginId(), conradVendorId, conradRemoteId);
deviceClassConradRemote.setName("Conrad Remote"); deviceClassConradRemote.setName("Conrad Remote");
QVariantList deviceParamsRemote; // Params
QVariantMap channelParam; QList<ParamType> deviceParamsRemote;
// channelParam.insert("name", "channel1");
// channelParam.insert("type", "bool"); QVariantList deviceParamRemote;
// deviceParamsRemote.append(channelParam); QVariantMap nameParam;
// channelParam.insert("name", "channel2"); nameParam.insert("name", "name");
// channelParam.insert("type", "bool"); nameParam.insert("type", "string");
// deviceParamsRemote.append(channelParam); deviceParamRemote.append(nameParam);
// channelParam.insert("name", "channel3");
// channelParam.insert("type", "bool"); // Events
// deviceParamsRemote.append(channelParam); QList<EventType> buttonEvents;
// channelParam.insert("name", "channel4");
// channelParam.insert("type", "bool"); QVariantList paramsRemote;
// deviceParamsRemote.append(channelParam); QVariantMap paramButton;
// channelParam.insert("name", "channel5"); paramButton.insert("name", "button");
// channelParam.insert("type", "bool"); paramButton.insert("type", "int");
// deviceParamsRemote.append(channelParam); paramsRemote.append(paramButton);
QVariantMap paramGroup;
paramGroup.insert("name", "group");
paramGroup.insert("type", "int");
paramsRemote.append(paramGroup);
QVariantMap paramPower;
paramPower.insert("name", "power");
paramPower.insert("type", "bool");
paramsRemote.append(paramPower);
EventType buttonEvent(conradRemoteButtonEventTypeId);
buttonEvent.setName("Button Pressed");
buttonEvent.setParameters(paramsRemote);
buttonEvents.append(buttonEvent);
deviceClassConradRemote.setParams(deviceParamsRemote); deviceClassConradRemote.setParams(deviceParamsRemote);
deviceClassConradRemote.setEvents(buttonEvents);
ret.append(deviceClassConradRemote); ret.append(deviceClassConradRemote);
return ret; return ret;
@ -135,17 +152,11 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con
void DevicePluginConrad::radioData(QList<int> rawData) void DevicePluginConrad::radioData(QList<int> rawData)
{ {
qDebug() << "!!!!!!!!!!!! called conrad radioData";
// filter right here a wrong signal length // filter right here a wrong signal length
if(rawData.length() != 65){ if(rawData.length() != 65){
return; return;
} }
// QList<Device*> deviceList = deviceManager()->findConfiguredDevices(intertechnoRemote);
// if(deviceList.isEmpty()){
// return;
// }
int delay = rawData.first()/10; int delay = rawData.first()/10;
QByteArray binCode; QByteArray binCode;
@ -158,13 +169,13 @@ void DevicePluginConrad::radioData(QList<int> rawData)
int divNext; int divNext;
// if short // if short
if(rawData.at(i) <= 800){ if(rawData.at(i) <= 900){
div = 1; div = 1;
}else{ }else{
div = 2; div = 2;
} }
// if long // if long
if(rawData.at(i+1) < 800){ if(rawData.at(i+1) < 900){
divNext = 1; divNext = 1;
}else{ }else{
divNext = 2; divNext = 2;
@ -187,11 +198,11 @@ void DevicePluginConrad::radioData(QList<int> rawData)
return; return;
} }
// ======================================= qDebug() << "CONRAD plugin understands this protocol: " << binCode;
qDebug() << "-----------------------------------------------------------";
qDebug() << "got conrad device...";
qDebug() << binCode;
// // FIXME: find a better way to get to the remote DeviceClass // // FIXME: find a better way to get to the remote DeviceClass
// DeviceClass deviceClass = supportedDevices().first(); // DeviceClass deviceClass = supportedDevices().first();

View File

@ -3,12 +3,12 @@ SUBDIRS += elro \
intertechno \ intertechno \
# meisteranker \ # meisteranker \
wifidetector \ wifidetector \
# conrad \ conrad \
mock \ mock \
# weatherground \
openweathermap \ openweathermap \
lircd \ lircd \
googlemail \ googlemail \
wakeonlan \
boblight { boblight {
SUBDIRS += boblight SUBDIRS += boblight

View File

@ -64,6 +64,8 @@ VendorId mumbiVendorId = VendorId("5f91c01c-0168-4bdf-a5ed-37cb6971b775");
DeviceClassId elroRemoteId = DeviceClassId("d85c1ef4-197c-4053-8e40-707aa671d302"); DeviceClassId elroRemoteId = DeviceClassId("d85c1ef4-197c-4053-8e40-707aa671d302");
DeviceClassId elroSwitchId = DeviceClassId("308ae6e6-38b3-4b3a-a513-3199da2764f8"); DeviceClassId elroSwitchId = DeviceClassId("308ae6e6-38b3-4b3a-a513-3199da2764f8");
DeviceClassId elroMotionDetectorId = DeviceClassId("4c64aee6-7a4f-41f2-b278-edc55f0da0d3");
DevicePluginElro::DevicePluginElro() DevicePluginElro::DevicePluginElro()
{ {
@ -141,6 +143,20 @@ QList<DeviceClass> DevicePluginElro::supportedDevices() const
deviceClassElroRemote.setEvents(buttonEvents); deviceClassElroRemote.setEvents(buttonEvents);
ret.append(deviceClassElroRemote); ret.append(deviceClassElroRemote);
// =======================================
// Motion Detector
DeviceClass deviceClassElroMotionDetector(pluginId(), elroVendorId, elroMotionDetectorId);
deviceClassElroMotionDetector.setName("Elro Motion Detector");
deviceClassElroMotionDetector.setCreateMethod(DeviceClass::CreateMethodDiscovery);
QList<EventType> motionDetectorEvents;
QList<ParamType> deviceParamsMotionDetector;
// ======================================= // =======================================
// Switch // Switch
DeviceClass deviceClassElroSwitch(pluginId(), elroVendorId, elroSwitchId); DeviceClass deviceClassElroSwitch(pluginId(), elroVendorId, elroSwitchId);
@ -311,7 +327,7 @@ void DevicePluginElro::radioData(QList<int> rawData)
QByteArray binCode; QByteArray binCode;
// average 314 // average 314
if(delay > 300 && delay < 400){ if(delay > 290 && delay < 400){
// go trough all 48 timings (without sync signal) // go trough all 48 timings (without sync signal)
for(int i = 1; i <= 48; i+=2 ){ for(int i = 1; i <= 48; i+=2 ){
int div; int div;
@ -348,6 +364,15 @@ void DevicePluginElro::radioData(QList<int> rawData)
}else{ }else{
return; return;
} }
qDebug() << "ELRO understands this protocol: " << binCode;
if(binCode.left(20) == "00000100000000000001"){
if(binCode.right(4) == "0100"){
qDebug() << "Motion Detector OFF";
}else{
qDebug() << "Motion Detector ON";
}
}
// get the channel of the remote signal (5 channels, true=1, false=0) // get the channel of the remote signal (5 channels, true=1, false=0)
QList<bool> group; QList<bool> group;
@ -404,7 +429,6 @@ void DevicePluginElro::radioData(QList<int> rawData)
} }
} }
if (!device) { if (!device) {
qWarning() << "couldn't find any configured device for elro:" << binCode.left(10) ;
return; return;
} }
@ -416,7 +440,7 @@ void DevicePluginElro::radioData(QList<int> rawData)
DeviceClass deviceClass = supportedDevices().first(); DeviceClass deviceClass = supportedDevices().first();
foreach (const EventType &eventType, deviceClass.events()) { foreach (const EventType &eventType, deviceClass.events()) {
if (eventType.name() == button) { if (eventType.name() == button) {
qDebug() << "emit event " << pluginName() << group << eventType.name() << power; //qDebug() << "emit event " << pluginName() << group << eventType.name() << power;
Event event = Event(eventType.id(), device->id(), params); Event event = Event(eventType.id(), device->id(), params);
emit emitEvent(event); emit emitEvent(event);
return; return;

View File

@ -115,7 +115,6 @@ DeviceManager::DeviceError DevicePluginGoogleMail::executeAction(Device *device,
if(!m_smtpClient->login(device->paramValue("user").toString(), device->paramValue("password").toString())){ if(!m_smtpClient->login(device->paramValue("user").toString(), device->paramValue("password").toString())){
return DeviceManager::DeviceErrorDeviceParameterError; return DeviceManager::DeviceErrorDeviceParameterError;
} }
m_smtpClient->sendMail(device->paramValue("user").toString(), device->paramValue("sendTo").toString(), action.param("subject").value().toString(), action.param("body").value().toString()); m_smtpClient->sendMail(device->paramValue("user").toString(), device->paramValue("sendTo").toString(), action.param("subject").value().toString(), action.param("body").value().toString());
m_smtpClient->logout(); m_smtpClient->logout();
} }

View File

@ -29,7 +29,6 @@ SmtpClient::SmtpClient(const QString &host, int port, SmtpClient::ConnectionType
m_sendMessageTimeout = 60000; m_sendMessageTimeout = 60000;
connect(m_socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError))); connect(m_socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(socketError(QAbstractSocket::SocketError)));
connect(m_socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
connect(m_socket,SIGNAL(connected()),this,SLOT(connected())); connect(m_socket,SIGNAL(connected()),this,SLOT(connected()));
connect(m_socket,SIGNAL(disconnected()),this,SLOT(disconnected())); connect(m_socket,SIGNAL(disconnected()),this,SLOT(disconnected()));

View File

@ -0,0 +1,104 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* 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 <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "devicepluginwakeonlan.h"
#include "plugin/device.h"
#include "devicemanager.h"
#include <QDebug>
#include <QStringList>
#include <QUdpSocket>
extern VendorId guhVendorId;
DeviceClassId wolDeviceClassId = DeviceClassId("3c8f2447-dcd0-4882-8c09-99e579e4d24c");
ActionTypeId wolActionTypeId = ActionTypeId("fb9b9d87-218f-4f0d-9e16-39f8a105029a");
DevicePluginWakeOnLan::DevicePluginWakeOnLan()
{
}
QList<Vendor> DevicePluginWakeOnLan::supportedVendors() const
{
QList<Vendor> ret;
Vendor guh(guhVendorId, "guh");
ret.append(guh);
return ret;
}
QList<DeviceClass> DevicePluginWakeOnLan::supportedDevices() const
{
QList<DeviceClass> ret;
DeviceClass deviceClassWakeOnLan(pluginId(), guhVendorId, wolDeviceClassId);
deviceClassWakeOnLan.setName("Wake On Lan");
QList<ParamType> wolParams;
ParamType wolParam("mac", QVariant::String);
wolParams.append(wolParam);
QList<ActionType> wolActions;
ActionType wolAction(wolActionTypeId);
wolAction.setName("wakeup");
wolActions.append(wolAction);
deviceClassWakeOnLan.setParams(wolParams);
deviceClassWakeOnLan.setActions(wolActions);
ret.append(deviceClassWakeOnLan);
return ret;
}
DeviceManager::HardwareResources DevicePluginWakeOnLan::requiredHardware() const
{
return DeviceManager::HardwareResourceNone;
}
QString DevicePluginWakeOnLan::pluginName() const
{
return "Wake On Lan";
}
PluginId DevicePluginWakeOnLan::pluginId() const
{
return PluginId("b5a87848-de56-451e-84a6-edd26ad4958f");
}
DeviceManager::DeviceError DevicePluginWakeOnLan::executeAction(Device *device, const Action &action)
{
qDebug() << "execute action " << action.actionTypeId().toString();
if(action.actionTypeId() == wolActionTypeId){
wakeup(device->paramValue("mac").toString());
}
return DeviceManager::DeviceErrorNoError;
}
void DevicePluginWakeOnLan::wakeup(QString mac)
{
const char header[] = {char(0xff), char(0xff), char(0xff), char(0xff), char(0xff), char(0xff)};
QByteArray packet = QByteArray::fromRawData(header, sizeof(header));
for(int i = 0; i < 16; ++i) {
packet.append(QByteArray::fromHex(mac.remove(':').toLocal8Bit()));
}
qDebug() << "created magic packet:" << packet.toHex();
QUdpSocket udpSocket;
udpSocket.writeDatagram(packet.data(), packet.size(), QHostAddress::Broadcast, 9);
}

View File

@ -0,0 +1,50 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* 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 <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef DEVICEPLUGINWAKEONLAN_H
#define DEVICEPLUGINWAKEONLAN_H
#include "plugin/deviceplugin.h"
#include <QProcess>
class DevicePluginWakeOnLan : public DevicePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginwakeonlan.json")
Q_INTERFACES(DevicePlugin)
public:
explicit DevicePluginWakeOnLan();
QList<Vendor> supportedVendors() const override;
QList<DeviceClass> supportedDevices() const override;
DeviceManager::HardwareResources requiredHardware() const override;
QString pluginName() const override;
PluginId pluginId() const override;
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
private slots:
void wakeup(QString mac);
};
#endif // DEVICEPLUGINWAKEONLAN_H

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,13 @@
include(../../plugins.pri)
TARGET = $$qtLibraryTarget(guh_devicepluginwakeonlan)
QT += network
SOURCES += \
devicepluginwakeonlan.cpp
HEADERS += \
devicepluginwakeonlan.h

View File

@ -25,12 +25,12 @@ Q_IMPORT_PLUGIN(DevicePluginElro)
Q_IMPORT_PLUGIN(DevicePluginIntertechno) Q_IMPORT_PLUGIN(DevicePluginIntertechno)
//Q_IMPORT_PLUGIN(DevicePluginMeisterAnker) //Q_IMPORT_PLUGIN(DevicePluginMeisterAnker)
Q_IMPORT_PLUGIN(DevicePluginWifiDetector) Q_IMPORT_PLUGIN(DevicePluginWifiDetector)
//Q_IMPORT_PLUGIN(DevicePluginConrad) Q_IMPORT_PLUGIN(DevicePluginConrad)
Q_IMPORT_PLUGIN(DevicePluginMock) Q_IMPORT_PLUGIN(DevicePluginMock)
//Q_IMPORT_PLUGIN(DevicePluginWeatherground)
Q_IMPORT_PLUGIN(DevicePluginOpenweathermap) Q_IMPORT_PLUGIN(DevicePluginOpenweathermap)
Q_IMPORT_PLUGIN(DevicePluginLircd) Q_IMPORT_PLUGIN(DevicePluginLircd)
Q_IMPORT_PLUGIN(DevicePluginGoogleMail) Q_IMPORT_PLUGIN(DevicePluginGoogleMail)
Q_IMPORT_PLUGIN(DevicePluginWakeOnLan)
#if USE_BOBLIGHT #if USE_BOBLIGHT
Q_IMPORT_PLUGIN(DevicePluginBoblight) Q_IMPORT_PLUGIN(DevicePluginBoblight)

View File

@ -19,12 +19,12 @@ LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
#LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker #LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
#LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad
LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock
#LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground
LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap
LIBS += -L../plugins/deviceplugins/lircd -lguh_devicepluginlircd LIBS += -L../plugins/deviceplugins/lircd -lguh_devicepluginlircd
LIBS += -L../plugins/deviceplugins/googlemail -lguh_deviceplugingooglemail LIBS += -L../plugins/deviceplugins/googlemail -lguh_deviceplugingooglemail
LIBS += -L../plugins/deviceplugins/wakeonlan -lguh_devicepluginwakeonlan
boblight { boblight {
xcompile { xcompile {

View File

@ -10,7 +10,7 @@ elif [ -z $2 ]; then
else else
if [ $2 == "elroremote" ]; then if [ $2 == "elroremote" ]; then
# Adds an ELRO remote control on channel 00000 # Adds an ELRO remote control on channel 00000
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{d85c1ef4-197c-4053-8e40-707aa671d302}","deviceParams":{"channel1":"true", "channel2":"false", "channel3":"false", "channel4": "false", "channel5":"false" }}}'; sleep 1) | nc $1 1234 (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{d85c1ef4-197c-4053-8e40-707aa671d302}","deviceParams":{"channel1":"false", "channel2":"false", "channel3":"false", "channel4": "false", "channel5":"false" }}}'; sleep 1) | nc $1 1234
elif [ $2 == "elroswitch" ]; then elif [ $2 == "elroswitch" ]; then
# Adds a ELRO power switch on channel 00000 and group E # Adds a ELRO power switch on channel 00000 and group E
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{308ae6e6-38b3-4b3a-a513-3199da2764f8}","deviceParams":{"channel1":"false","channel2":"false", "channel3":"false", "channel4": "false","channel5":"false","A":"false","B":"true","C":"false","D":"false","E":"false" }}}'; sleep 1) | nc $1 1234 (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{308ae6e6-38b3-4b3a-a513-3199da2764f8}","deviceParams":{"channel1":"false","channel2":"false", "channel3":"false", "channel4": "false","channel5":"false","A":"false","B":"true","C":"false","D":"false","E":"false" }}}'; sleep 1) | nc $1 1234
@ -30,8 +30,9 @@ else
# Adds a Mock device # Adds a Mock device
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{753f0d32-0468-4d08-82ed-1964aab03298}","deviceParams":{"httpport":"8082"}}}'; sleep 1) | nc $1 1234 (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{753f0d32-0468-4d08-82ed-1964aab03298}","deviceParams":{"httpport":"8082"}}}'; sleep 1) | nc $1 1234
elif [ $2 == "openweathermap" ]; then elif [ $2 == "openweathermap" ]; then
# Adds a openweathermap device
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{985195aa-17ad-4530-88a4-cdd753d747d7}","deviceDescriptorId":"'$4'"}}'; sleep 1) | nc $1 1234 (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{985195aa-17ad-4530-88a4-cdd753d747d7}","deviceDescriptorId":"'$4'"}}'; sleep 1) | nc $1 1234
elif [ $2 == "wol" ]; then
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{3c8f2447-dcd0-4882-8c09-99e579e4d24c}","deviceParams":{"mac":"'$3'"}}}'; sleep 1) | nc $1 1234
elif [ $2 == "lirc" ]; then elif [ $2 == "lirc" ]; then
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{5c2bc4cd-ba6c-4052-b6cd-1db83323ea22}","deviceParams":{"remoteName":"'$3'"}}}'; sleep 1) | nc $1 1234 (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{5c2bc4cd-ba6c-4052-b6cd-1db83323ea22}","deviceParams":{"remoteName":"'$3'"}}}'; sleep 1) | nc $1 1234
elif [ $2 == "discovered" ]; then elif [ $2 == "discovered" ]; then