mirror of https://github.com/nymea/nymea.git
made RF433 GPIO selectable
removed receiving devices temporary added elro devices added name param for 433 devices cleanup 433 pluginspull/135/head
parent
1c008d0bef
commit
ae1335f392
5
guh.pri
5
guh.pri
|
|
@ -14,6 +14,11 @@ coverage {
|
|||
QMAKE_LFLAGS += -fprofile-arcs
|
||||
}
|
||||
|
||||
# Enable Radio 433 MHz for GPIO's
|
||||
enable433gpio {
|
||||
DEFINES += GPIO433
|
||||
}
|
||||
|
||||
top_srcdir=$$PWD
|
||||
top_builddir=$$shadowed($$PWD)
|
||||
|
||||
|
|
|
|||
8
guh.pro
8
guh.pro
|
|
@ -22,6 +22,14 @@ test.commands = LD_LIBRARY_PATH=$$top_builddir/libguh make check
|
|||
|
||||
QMAKE_EXTRA_TARGETS += licensecheck doc test
|
||||
|
||||
message("Building guh version $${GUH_VERSION_STRING}")
|
||||
|
||||
coverage {
|
||||
message("Building coverage.")
|
||||
}
|
||||
|
||||
contains(DEFINES, GPIO433){
|
||||
message("Radio 433 for GPIO's enabled")
|
||||
} else {
|
||||
message("Radio 433 for GPIO's disabled")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@
|
|||
The second possibility to sent data to a 433 MHz device is the \l{http://www.brennenstuhl.de/de-DE/steckdosenleisten-schaltgeraete-und-adapter/brematic-hausautomation/brematic-home-automation-gateway-gwy-433-1.html}
|
||||
{Brennenstuhl 433 MHz LAN Gateway}. If there is a Gateway in the local network, this class will automaticaly detect
|
||||
it and will be used. If both transmitter are available (Gateway + GPIO), each signal will be transmitted over both sender.
|
||||
|
||||
\note: Radio 433 on GPIO's is by default disabled. If you want to enable it, you need to compile the source with the qmake config \tt{CONFIG+=radio433gpio}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*! \fn void Radio433::dataReceived(QList<int> rawData)
|
||||
|
|
@ -50,20 +54,26 @@
|
|||
Radio433::Radio433(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
#ifdef GPIO433
|
||||
m_receiver = new Radio433Receiver(this,27);
|
||||
m_transmitter = new Radio433Trasmitter(this,22);
|
||||
m_brennenstuhlTransmitter = new Radio433BrennenstuhlGateway(this);
|
||||
|
||||
connect(m_receiver, &Radio433Receiver::readingChanged, this, &Radio433::readingChanged);
|
||||
connect(m_receiver, &Radio433Receiver::dataReceived, this, &Radio433::dataReceived);
|
||||
#endif
|
||||
|
||||
m_brennenstuhlTransmitter = new Radio433BrennenstuhlGateway(this);
|
||||
connect(m_brennenstuhlTransmitter, &Radio433BrennenstuhlGateway::availableChanged, this, &Radio433::brennenstuhlAvailableChanged);
|
||||
}
|
||||
|
||||
/*! Destroys the hardware resource Radio433 object. */
|
||||
Radio433::~Radio433()
|
||||
{
|
||||
#ifdef GPIO433
|
||||
m_receiver->quit();
|
||||
m_transmitter->quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! Enables GPIO transmitter and receiver and the Brennenstuhl Lan Gateway.
|
||||
|
|
@ -72,6 +82,7 @@ bool Radio433::enable()
|
|||
{
|
||||
m_brennenstuhlTransmitter->enable();
|
||||
|
||||
#ifdef GPIO433
|
||||
// check if GPIOs are available
|
||||
QFileInfo gpioFile("/sys/class/gpio/export");
|
||||
if (gpioFile.exists()) {
|
||||
|
|
@ -91,6 +102,8 @@ bool Radio433::enable()
|
|||
}
|
||||
}
|
||||
qDebug() << "--> Radio 433 MHz GPIO's enabled.";
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -98,19 +111,14 @@ bool Radio433::enable()
|
|||
bool Radio433::disabel()
|
||||
{
|
||||
m_brennenstuhlTransmitter->disable();
|
||||
|
||||
#ifdef GPIO433
|
||||
if (m_receiver->stopReceiver()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Radio433::readingChanged(bool reading)
|
||||
{
|
||||
if (reading) {
|
||||
m_transmitter->allowSending(false);
|
||||
} else {
|
||||
m_transmitter->allowSending(true);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void Radio433::brennenstuhlAvailableChanged(const bool &available)
|
||||
|
|
@ -132,10 +140,12 @@ bool Radio433::sendData(int delay, QList<int> rawData, int repetitions)
|
|||
sendBrennenstuhl = m_brennenstuhlTransmitter->sendData(delay, rawData, repetitions);
|
||||
}
|
||||
|
||||
#ifdef GPIO433
|
||||
if (m_transmitter->available()) {
|
||||
m_transmitter->sendData(delay, rawData, repetitions);
|
||||
sendGpio = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (sendGpio || sendBrennenstuhl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef GPIO433
|
||||
#include "radio433receiver.h"
|
||||
#include "radio433transmitter.h"
|
||||
#endif
|
||||
|
||||
#include "radio433brennenstuhlgateway.h"
|
||||
|
||||
class Radio433 : public QObject
|
||||
|
|
@ -36,15 +39,17 @@ public:
|
|||
bool disabel();
|
||||
|
||||
private:
|
||||
#ifdef GPIO433
|
||||
Radio433Receiver *m_receiver;
|
||||
Radio433Trasmitter *m_transmitter;
|
||||
#endif
|
||||
|
||||
Radio433BrennenstuhlGateway *m_brennenstuhlTransmitter;
|
||||
|
||||
signals:
|
||||
void dataReceived(QList<int> rawData);
|
||||
|
||||
private slots:
|
||||
void readingChanged(bool reading);
|
||||
void brennenstuhlAvailableChanged(const bool &available);
|
||||
|
||||
public slots:
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ Radio433BrennenstuhlGateway::Radio433BrennenstuhlGateway(QObject *parent) :
|
|||
|
||||
// Timer for discovery of the Gateway
|
||||
m_discoverTimer = new QTimer(this);
|
||||
m_discoverTimer->setInterval(2000);
|
||||
m_discoverTimer->setInterval(5000);
|
||||
connect(m_discoverTimer, &QTimer::timeout, this, &Radio433BrennenstuhlGateway::discover);
|
||||
|
||||
// Timer to detect discovery timeout
|
||||
m_timeout = new QTimer(this);
|
||||
m_timeout->setSingleShot(true);
|
||||
m_timeout->setInterval(1500);
|
||||
m_timeout->setInterval(3000);
|
||||
connect(m_timeout, &QTimer::timeout, this, &Radio433BrennenstuhlGateway::timeout);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
|
|||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginConrad::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == conradRemoteDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() + " (Conrad Remote)");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == conradShutterDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() + " (Conrad shutter RSM900R)");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
|
|
@ -186,15 +181,4 @@ void DevicePluginConrad::radioData(const QList<int> &rawData)
|
|||
}
|
||||
|
||||
qDebug() << "CONRAD: " << binCode.left(binCode.length() - 24) << " ID = " << binCode.right(24);
|
||||
|
||||
// // FIXME: find a better way to get to the remote DeviceClass
|
||||
// DeviceClass deviceClass = supportedDevices().first();
|
||||
// foreach (const EventType &eventType, deviceClass.events()) {
|
||||
// if (eventType.name() == buttonCode) {
|
||||
// qDebug() << "emit event " << pluginName() << familyCode << eventType.name() << power;
|
||||
// Event event = Event(eventType.id(), device->id(), params);
|
||||
// emit emitEvent(event);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,40 +6,6 @@
|
|||
"name": "Conrad Electronic SE",
|
||||
"id": "986cf06f-3ef1-4271-b2a3-2cc277ebecb6",
|
||||
"deviceClasses": [
|
||||
{
|
||||
"deviceClassId": "17cd2492-28ab-4827-ba6e-5ef35be23f1b",
|
||||
"name": "Conrad Remote",
|
||||
"idName": "conradRemote",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "1f4050f5-4c90-4799-8d6d-e4069f3a2519",
|
||||
"name": "Button pressed",
|
||||
"idName": "remoteButtonPressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "button",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"name": "group",
|
||||
"type": "int"
|
||||
},
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "2bb14180-aa5d-4999-992d-e6d464cff486",
|
||||
"name": "Conrad shutter RSM900R",
|
||||
|
|
|
|||
|
|
@ -57,73 +57,78 @@ DeviceManager::HardwareResources DevicePluginElro::requiredHardware() const
|
|||
|
||||
DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
if (action.actionTypeId() != powerOnActionTypeId && action.actionTypeId() != powerOffActionTypeId) {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
|
||||
// =======================================
|
||||
// create the bincode
|
||||
// channels
|
||||
if(device->paramValue("channel 1").toBool()){
|
||||
if (device->paramValue("channel 1").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("channel 2").toBool()){
|
||||
if (device->paramValue("channel 2").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("channel 3").toBool()){
|
||||
if (device->paramValue("channel 3").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("channel 4").toBool()){
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("channel 5").toBool()){
|
||||
if (device->paramValue("channel 5").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Buttons
|
||||
if(device->paramValue("A").toBool()){
|
||||
if (device->paramValue("A").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("B").toBool()){
|
||||
if (device->paramValue("B").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("C").toBool()){
|
||||
if (device->paramValue("C").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("D").toBool()){
|
||||
if (device->paramValue("D").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
if(device->paramValue("E").toBool()){
|
||||
if (device->paramValue("E").toBool()) {
|
||||
binCode.append("00");
|
||||
}else{
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
// Power
|
||||
if(action.param("power").value().toBool()){
|
||||
binCode.append("0001");
|
||||
}else{
|
||||
binCode.append("0100");
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Power
|
||||
if (action.actionTypeId() == powerOnActionTypeId) {
|
||||
binCode.append("0001");
|
||||
} else if (action.actionTypeId() == powerOffActionTypeId) {
|
||||
binCode.append("0100");
|
||||
} else {
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
//create rawData timings list
|
||||
int delay = 350;
|
||||
|
||||
|
|
@ -133,21 +138,20 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const
|
|||
|
||||
// add the code
|
||||
foreach (QChar c, binCode) {
|
||||
if(c == '0'){
|
||||
if (c == '0') {
|
||||
rawData.append(1);
|
||||
rawData.append(3);
|
||||
}else{
|
||||
} else {
|
||||
rawData.append(3);
|
||||
rawData.append(1);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// send data to hardware resource
|
||||
if(transmitData(delay, rawData)){
|
||||
if (transmitData(delay, rawData)) {
|
||||
qDebug() << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}else{
|
||||
} else {
|
||||
qDebug() << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
|
|
@ -156,7 +160,7 @@ DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const
|
|||
void DevicePluginElro::radioData(const QList<int> &rawData)
|
||||
{
|
||||
// filter right here a wrong signal length
|
||||
if(rawData.length() != 49){
|
||||
if (rawData.length() != 49) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -164,61 +168,60 @@ void DevicePluginElro::radioData(const QList<int> &rawData)
|
|||
QByteArray binCode;
|
||||
|
||||
// average 314
|
||||
if(delay > 290 && delay < 400){
|
||||
if (delay > 290 && delay < 400) {
|
||||
// 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 divNext;
|
||||
|
||||
// if short
|
||||
if(rawData.at(i) <= 700){
|
||||
if (rawData.at(i) <= 700) {
|
||||
div = 1;
|
||||
}else{
|
||||
} else {
|
||||
div = 3;
|
||||
}
|
||||
// if long
|
||||
if(rawData.at(i+1) < 700){
|
||||
if (rawData.at(i+1) < 700) {
|
||||
divNext = 1;
|
||||
}else{
|
||||
} else {
|
||||
divNext = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
* _
|
||||
* | |___ = 0 -> in 4 delays => 1000
|
||||
* _
|
||||
* ___| | = 1 -> in 4 delays => 0001
|
||||
*/
|
||||
// _
|
||||
// | |___ = 0 -> in 4 delays => 1000
|
||||
// _
|
||||
// ___| | = 1 -> in 4 delays => 0001
|
||||
|
||||
if(div == 1 && divNext == 3){
|
||||
if (div == 1 && divNext == 3) {
|
||||
binCode.append('0');
|
||||
}else if(div == 3 && divNext == 1){
|
||||
} else if(div == 3 && divNext == 1) {
|
||||
binCode.append('1');
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
//qDebug() << "ELRO understands this protocol: " << binCode;
|
||||
|
||||
if(binCode.left(20) == "00000100000000000001"){
|
||||
if(binCode.right(4) == "0100"){
|
||||
qDebug() << "ELRO understands this protocol: " << binCode;
|
||||
|
||||
if (binCode.left(20) == "00000100000000000001") {
|
||||
if (binCode.right(4) == "0100") {
|
||||
qDebug() << "Motion Detector OFF";
|
||||
}else{
|
||||
} else {
|
||||
qDebug() << "Motion Detector ON";
|
||||
}
|
||||
}
|
||||
|
||||
// get the channel of the remote signal (5 channels, true=1, false=0)
|
||||
QList<bool> group;
|
||||
for(int i = 1; i < 10; i+=2){
|
||||
if(binCode.at(i-1) == '0' && binCode.at(i) == '1'){
|
||||
for (int i = 1; i < 10; i+=2) {
|
||||
if (binCode.at(i-1) == '0' && binCode.at(i) == '1') {
|
||||
group << false;
|
||||
}else if(binCode.at(i-1) == '0' && binCode.at(i) == '0'){
|
||||
} else if(binCode.at(i-1) == '0' && binCode.at(i) == '0') {
|
||||
group << true;
|
||||
}else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -227,59 +230,29 @@ void DevicePluginElro::radioData(const QList<int> &rawData)
|
|||
QString button;
|
||||
QByteArray buttonCode = binCode.mid(10,10);
|
||||
|
||||
if(buttonCode == "0001010101"){
|
||||
if (buttonCode == "0001010101") {
|
||||
button = "A";
|
||||
}else if(buttonCode == "0100010101"){
|
||||
} else if (buttonCode == "0100010101") {
|
||||
button = "B";
|
||||
}else if(buttonCode == "0101000101"){
|
||||
} else if (buttonCode == "0101000101") {
|
||||
button = "C";
|
||||
}else if(buttonCode == "0101010001"){
|
||||
} else if(buttonCode == "0101010001") {
|
||||
button = "D";
|
||||
}else if(buttonCode == "0101010100"){
|
||||
} else if(buttonCode == "0101010100") {
|
||||
button = "E";
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// get power status -> On = 0100, Off = 0001
|
||||
bool power;
|
||||
if(binCode.right(4).toInt(0,2) == 1){
|
||||
if (binCode.right(4).toInt(0,2) == 1) {
|
||||
power = true;
|
||||
}else if(binCode.right(4).toInt(0,2) == 4){
|
||||
} else if(binCode.right(4).toInt(0,2) == 4) {
|
||||
power = false;
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
Device *device = 0;
|
||||
QList<Device*> deviceList = deviceManager()->findConfiguredDevices(elroRemoteDeviceClassId);
|
||||
foreach (Device *dev, deviceList) {
|
||||
if (dev->hasParam("channel 1") && dev->paramValue("channel 1").toBool() == group.at(0) &&
|
||||
dev->hasParam("channel 2") && dev->paramValue("channel 2").toBool() == group.at(1) &&
|
||||
dev->hasParam("channel 3") && dev->paramValue("channel 3").toBool() == group.at(2) &&
|
||||
dev->hasParam("channel 4") && dev->paramValue("channel 4").toBool() == group.at(3) &&
|
||||
dev->hasParam("channel 5") && dev->paramValue("channel 5").toBool() == group.at(4)
|
||||
) {
|
||||
// Yippie! We found the device.
|
||||
device = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
|
||||
ParamList params;
|
||||
Param powerParam("power", power);
|
||||
params.append(powerParam);
|
||||
|
||||
// FIXME: find a better way to get to the remote DeviceClass
|
||||
DeviceClass deviceClass = supportedDevices().first();
|
||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||
if (eventType.name() == button) {
|
||||
Event event = Event(eventType.id(), device->id(), params);
|
||||
emit emitEvent(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
qDebug() << "ELRO:" << group << buttonCode << power;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,91 +6,17 @@
|
|||
"name": "Elro",
|
||||
"id": "435a13a0-65ca-4f0c-94c1-e5873b258db5",
|
||||
"deviceClasses": [
|
||||
{
|
||||
"deviceClassId": "d85c1ef4-197c-4053-8e40-707aa671d302",
|
||||
"idName": "elroRemote",
|
||||
"name": "Elro Remote",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 2",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 3",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 4",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 5",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "9dd3f862-35f3-4b69-954e-fa3c8bd68e39",
|
||||
"name": "A",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "733226eb-91ba-4e37-9d78-12c87eb5e763",
|
||||
"name": "B",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "47aaeaec-485a-4775-a543-33f339fd28c8",
|
||||
"name": "C",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "db3d484c-add9-44ab-80a4-a0664e0c87c8",
|
||||
"name": "D",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a",
|
||||
"name": "E",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "308ae6e6-38b3-4b3a-a513-3199da2764f8",
|
||||
"name": "Elro switch",
|
||||
"name": "Elro Socket (AB440D)",
|
||||
"idName": "socketAB440D",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
|
|
@ -135,20 +61,204 @@
|
|||
"actionTypes": [
|
||||
{
|
||||
"id": "31c9758e-6567-4f89-85bb-29e1a7c55d44",
|
||||
"name": "Set power",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
"idName": "powerOn",
|
||||
"name": "On"
|
||||
},
|
||||
{
|
||||
"id": "9ceb3233-20a3-46bf-b2af-faed1b7ab1ad",
|
||||
"idName": "powerOff",
|
||||
"name": "Off"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "4c64aee6-7a4f-41f2-b278-edc55f0da0d3",
|
||||
"name": "Elro motion detector",
|
||||
"createMethods": ["discovery"]
|
||||
"deviceClassId": "d29cf309-8a3e-4bcc-90ab-87d1adfb8985",
|
||||
"name": "Elro Bulb (AB440L)",
|
||||
"idName": "bulbAB440L",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 2",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 3",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 4",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 5",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "B",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "C",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "D",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "E",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "31c9758e-6567-4f89-85bb-29e1a7c55d44",
|
||||
"name": "On"
|
||||
},
|
||||
{
|
||||
"id": "9ceb3233-20a3-46bf-b2af-faed1b7ab1ad",
|
||||
"name": "Off"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "9516c818-7cbe-4ec2-a961-f29d7b918437",
|
||||
"name": "Elro Socket (AB440S)",
|
||||
"idName": "socketAB440S",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 2",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 3",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 4",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 5",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "B",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "C",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "D",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "E",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "31c9758e-6567-4f89-85bb-29e1a7c55d44",
|
||||
"name": "On"
|
||||
},
|
||||
{
|
||||
"id": "9ceb3233-20a3-46bf-b2af-faed1b7ab1ad",
|
||||
"name": "Off"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "e03adc74-b972-451a-afd5-b562a7ab91cd",
|
||||
"name": "Elro outdoor socket (AB440WD)",
|
||||
"idName": "socketAB440WD",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 2",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 3",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 4",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "channel 5",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "A",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "B",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "C",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "D",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"name": "E",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "31c9758e-6567-4f89-85bb-29e1a7c55d44",
|
||||
"name": "On"
|
||||
},
|
||||
{
|
||||
"id": "9ceb3233-20a3-46bf-b2af-faed1b7ab1ad",
|
||||
"name": "Off"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ DeviceManager::DeviceError DevicePluginIntertechno::executeAction(Device *device
|
|||
|
||||
// =======================================
|
||||
// generate bin from button code
|
||||
if(familyCode == "1") {
|
||||
if (familyCode == "1") {
|
||||
binCode.append("00000000");
|
||||
} else if (familyCode == "2") {
|
||||
binCode.append("01000000");
|
||||
|
|
@ -190,10 +190,10 @@ void DevicePluginIntertechno::radioData(const QList<int> &rawData)
|
|||
return;
|
||||
}
|
||||
|
||||
QList<Device*> deviceList = deviceManager()->findConfiguredDevices(intertechnoRemoteDeviceClassId);
|
||||
if (deviceList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// QList<Device*> deviceList = deviceManager()->findConfiguredDevices(intertechnoRemoteDeviceClassId);
|
||||
// if (deviceList.isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
int delay = rawData.first()/31;
|
||||
QByteArray binCode;
|
||||
|
|
@ -378,34 +378,6 @@ void DevicePluginIntertechno::radioData(const QList<int> &rawData)
|
|||
return;
|
||||
}
|
||||
|
||||
qDebug() << "family code = " << familyCode << "button code =" << buttonCode << power;
|
||||
qDebug() << "INTERTECHNO: family code = " << familyCode << "button code =" << buttonCode << power;
|
||||
|
||||
// ===================================================
|
||||
Device *device = 0;
|
||||
foreach (Device *dev, deviceList) {
|
||||
if (dev->paramValue("familyCode").toString() == familyCode) {
|
||||
// Yippie! We found the device.
|
||||
device = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!device) {
|
||||
qWarning() << "couldn't find any configured device for intertech familyCode:" << familyCode;
|
||||
return;
|
||||
}
|
||||
|
||||
ParamList params;
|
||||
Param powerParam("power", power);
|
||||
params.append(powerParam);
|
||||
|
||||
// FIXME: find a better way to get to the remote DeviceClass
|
||||
DeviceClass deviceClass = supportedDevices().first();
|
||||
foreach (const EventType &eventType, deviceClass.eventTypes()) {
|
||||
if (eventType.name() == buttonCode) {
|
||||
qDebug() << "emit event " << pluginName() << familyCode << eventType.name() << power;
|
||||
Event event = Event(eventType.id(), device->id(), params);
|
||||
emit emitEvent(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,187 +6,16 @@
|
|||
"name": "Intertechno",
|
||||
"id": "6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba",
|
||||
"deviceClasses": [
|
||||
{
|
||||
"deviceClassId": "ab73ad2f-6594-45a3-9063-8f72d365c5e5",
|
||||
"idName": "intertechnoRemote",
|
||||
"name": "Intertechno Remote",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "familyCode",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"]
|
||||
}
|
||||
],
|
||||
"eventTypes": [
|
||||
{
|
||||
"id": "785c1b30-a3f2-4696-af7c-d532acf3d6f7",
|
||||
"name": "Button 1 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "1d42c850-7b43-452f-b205-e1aac14eb3ee",
|
||||
"name": "Button 2 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "77a4780e-2355-4a77-870d-2f675bf986ce",
|
||||
"name": "Button 3 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "bd6a8b4b-f946-4f3b-992f-e7cff10187b8",
|
||||
"name": "Button 4 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0f20782e-0acc-45f1-8c42-5dc5f5b29f1b",
|
||||
"name": "Button 5 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "f7cb439a-0528-4905-9583-06b6bfeb3ba1",
|
||||
"name": "Button 6 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "a0b0d8d8-2b43-4897-98e0-05b6b408a950",
|
||||
"name": "Button 7 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "ae5833a2-bc43-4462-ae47-e45dac1fb0ce",
|
||||
"name": "Button 8 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "52c13828-d047-4256-b488-0bf84abbc87c",
|
||||
"name": "Button 9 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "22c5afbc-835e-47cc-8211-4429eb9d9fee",
|
||||
"name": "Button 10 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa",
|
||||
"name": "Button 11 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "8b71edd2-8135-4c8b-bf44-380efadf1942",
|
||||
"name": "Button 12 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "192f36a4-1e58-41aa-9618-83d46e329a4b",
|
||||
"name": "Button 13 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "6c76de60-5e19-4a29-b027-e71e66caa2d6",
|
||||
"name": "Button 14 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "c2f56c10-1f81-4477-88fa-fc0f4a6383df",
|
||||
"name": "Button 15 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4",
|
||||
"name": "Button 16 pressed",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"deviceClassId": "324219e8-7c53-41b5-b314-c2900cd15252",
|
||||
"name": "Intertechno switch",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "familyCode",
|
||||
"type": "QString",
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@
|
|||
"name": "RF Controller (LN-CON-RF20B)",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "ID",
|
||||
"type": "QString",
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
LircClient::LircClient(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
m_socket = new QLocalSocket(this);
|
||||
QObject::connect(m_socket, &QLocalSocket::readyRead, this, &LircClient::readyRead);
|
||||
}
|
||||
|
|
@ -33,17 +32,12 @@ bool LircClient::connect()
|
|||
{
|
||||
m_socket->connectToServer("/var/run/lirc/lircd", QIODevice::ReadWrite);
|
||||
if (!m_socket->isOpen()) {
|
||||
qWarning() << "Error connecting to lircd socket. Is Lircd running?";
|
||||
qWarning() << "--> Lirc daemon NOT available.";
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "connected to lircd!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11111";
|
||||
|
||||
qDebug() << "wrote to lirc:" << m_socket->write("LIST\n");
|
||||
|
||||
m_socket->write("LIST\n");
|
||||
qDebug() << "--> Lirc daemon available.";
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LircClient::readyRead()
|
||||
|
|
@ -53,7 +47,7 @@ void LircClient::readyRead()
|
|||
bool inBlock = false;
|
||||
while (m_socket->canReadLine()) {
|
||||
QByteArray line = m_socket->readLine().trimmed();
|
||||
qDebug() << "got line:" << line;
|
||||
//qDebug() << "got line:" << line;
|
||||
if (line == "BEGIN") {
|
||||
inBlock = true;
|
||||
continue;
|
||||
|
|
@ -87,7 +81,7 @@ void LircClient::readRemotes()
|
|||
{
|
||||
m_socket->readLine(); // IGNORE DATA
|
||||
int remoteCount = m_socket->readLine().trimmed().toInt();
|
||||
qDebug() << "found" << remoteCount << "remotes";
|
||||
qDebug() << "found" << remoteCount << "lirc remotes";
|
||||
for (int i = 0; i < remoteCount; i++) {
|
||||
QByteArray line = m_socket->readLine().trimmed();
|
||||
m_remotes.append(line);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
"name": "Unitec switch (48111)",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "Channel",
|
||||
"type": "QString",
|
||||
|
|
|
|||
|
|
@ -11,6 +11,11 @@
|
|||
"name": "WiFi Device",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "MAC",
|
||||
"type": "QString",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
include(../guh.pri)
|
||||
|
||||
message("Building guh version $${GUH_VERSION_STRING}")
|
||||
|
||||
TARGET = guhd
|
||||
TEMPLATE = app
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue