meister anker plugin added
This commit is contained in:
parent
1addaaf638
commit
31b1f9b08e
@ -14,6 +14,7 @@
|
||||
|
||||
Q_IMPORT_PLUGIN(DevicePluginElro)
|
||||
Q_IMPORT_PLUGIN(DevicePluginIntertechno)
|
||||
Q_IMPORT_PLUGIN(DevicePluginMeisterAnker)
|
||||
|
||||
|
||||
DeviceManager::DeviceManager(QObject *parent) :
|
||||
|
||||
@ -68,7 +68,6 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
||||
button2Trigger.setParameters(paramsRemote);
|
||||
buttonTriggers.append(button2Trigger);
|
||||
|
||||
|
||||
TriggerType button3Trigger("77a4780e-2355-4a77-870d-2f675bf986ce");
|
||||
button3Trigger.setName("3");
|
||||
button3Trigger.setParameters(paramsRemote);
|
||||
|
||||
@ -0,0 +1,139 @@
|
||||
#include "devicepluginmeisteranker.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
QUuid thermometer = QUuid("e37e9f34-95b9-4a22-ae4f-e8b874eec871");
|
||||
|
||||
DevicePluginMeisterAnker::DevicePluginMeisterAnker()
|
||||
{
|
||||
}
|
||||
|
||||
void DevicePluginMeisterAnker::init()
|
||||
{
|
||||
connect(deviceManager()->radio433(), &Radio433::dataReceived, this, &DevicePluginMeisterAnker::dataReceived);
|
||||
}
|
||||
|
||||
QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
||||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
// Thermometer
|
||||
DeviceClass deviceClassMeisterAnkerThermometer(pluginId(), thermometer);
|
||||
deviceClassMeisterAnkerThermometer.setName("Meister Anker Thermometer");
|
||||
|
||||
QVariantList thermometerParams;
|
||||
QVariantMap idParam;
|
||||
// id -> first 8 bits of codeword
|
||||
idParam.insert("name", "id");
|
||||
idParam.insert("type", "string");
|
||||
thermometerParams.append(idParam);
|
||||
|
||||
deviceClassMeisterAnkerThermometer.setParams(thermometerParams);
|
||||
|
||||
QList<TriggerType> thermometerTriggers;
|
||||
|
||||
QVariantList paramsThermometer;
|
||||
|
||||
QVariantMap paramThermometer;
|
||||
paramThermometer.insert("name", "temperature");
|
||||
paramThermometer.insert("type", "double");
|
||||
paramsThermometer.append(paramThermometer);
|
||||
|
||||
QVariantMap paramThermometerBat;
|
||||
paramThermometerBat.insert("name", "batterystatus");
|
||||
paramThermometerBat.insert("type", "bool");
|
||||
paramsThermometer.append(paramThermometerBat);
|
||||
|
||||
TriggerType temperatureTrigger(QUuid("174ab4d5-2ef0-491b-a55b-c895cedff80e"));
|
||||
temperatureTrigger.setName("temperature");
|
||||
temperatureTrigger.setParameters(paramsThermometer);
|
||||
thermometerTriggers.append(temperatureTrigger);
|
||||
|
||||
// TODO: lock if we need a sync trigger
|
||||
// TriggerType syncTrigger(QUuid("174ab4d5-2ef0-491b-a55b-c895cedff80e"));
|
||||
// temperatureTrigger.setName("sync");
|
||||
// temperatureTrigger.setParameters(paramsThermometer);
|
||||
// thermometerTriggers.append(temperatureTrigger);
|
||||
|
||||
|
||||
deviceClassMeisterAnkerThermometer.setTriggers(thermometerTriggers);
|
||||
ret.append(deviceClassMeisterAnkerThermometer);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString DevicePluginMeisterAnker::pluginName() const
|
||||
{
|
||||
return "Meister Anker";
|
||||
}
|
||||
|
||||
QUuid DevicePluginMeisterAnker::pluginId() const
|
||||
{
|
||||
return QUuid("993a7c86-e4b9-44aa-b61e-1f7165df1348");
|
||||
}
|
||||
|
||||
void DevicePluginMeisterAnker::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DevicePluginMeisterAnker::dataReceived(QList<int> rawData)
|
||||
{
|
||||
// filter right here a wrong signal length
|
||||
if(rawData.length() != 49){
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Device*> deviceList = deviceManager()->findConfiguredDevices(thermometer);
|
||||
if(deviceList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
|
||||
int delay = rawData.first()/31;
|
||||
QByteArray binCode;
|
||||
|
||||
if(delay > 250 && delay < 260){
|
||||
|
||||
// __
|
||||
// | |________ = 0 1100000000
|
||||
// __
|
||||
// | |________________ = 1 110000000000000000
|
||||
|
||||
for(int i = 1; i <= 48; i+=2 ){
|
||||
if(rawData.at(i) < 1000 && rawData.at(i+1) < 3000 && rawData.at(i+1) > 1000){
|
||||
binCode.append('0');
|
||||
}else if(rawData.at(i) < 1000 && rawData.at(i+1) > 3000){
|
||||
binCode.append('1');
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
// decode the signal
|
||||
QList<QByteArray> byteList;
|
||||
for(int i = 4; i <= 24; i+=4){
|
||||
byteList.append(binCode.left(4));
|
||||
binCode = binCode.right(binCode.length() -4);
|
||||
}
|
||||
|
||||
QByteArray temperatureBin(byteList.at(2) + byteList.at(3));
|
||||
QByteArray batteryBin(byteList.at(4));
|
||||
QByteArray temperatureTenthBin(byteList.at(5));
|
||||
|
||||
QByteArray idCode = binCode.left(8);
|
||||
|
||||
// check if we have a sync signal (id = 11111111)
|
||||
if(idCode.contains("11111111")){
|
||||
qDebug() << "temperatursensor sync signal";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
#ifndef DEVICEPLUGINMEISTERANKER_H
|
||||
#define DEVICEPLUGINMEISTERANKER_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
|
||||
|
||||
class DevicePluginMeisterAnker : public DevicePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginmeisteranker.json")
|
||||
Q_INTERFACES(DevicePlugin)
|
||||
|
||||
public:
|
||||
explicit DevicePluginMeisterAnker();
|
||||
|
||||
void init() override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
|
||||
QString pluginName() const;
|
||||
QUuid pluginId() const;
|
||||
|
||||
public slots:
|
||||
void executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void dataReceived(QList<int> rawData);
|
||||
};
|
||||
|
||||
#endif // DEVICEPLUGINMEISTERANKER_H
|
||||
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -0,0 +1,15 @@
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin static
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginmeisteranker)
|
||||
|
||||
INCLUDEPATH += ../../../libhive
|
||||
LIBS += -L../../../libhive -lhive
|
||||
|
||||
SOURCES += \
|
||||
devicepluginmeisteranker.cpp
|
||||
|
||||
HEADERS += \
|
||||
devicepluginmeisteranker.h
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS += devicepluginelro devicepluginintertechno
|
||||
SUBDIRS += devicepluginelro devicepluginintertechno devicepluginmeisteranker
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ void JsonRPCServer::handleRulesMessage(int clientId, int commandId, const QStrin
|
||||
foreach (const Rule &rule, HiveCore::instance()->ruleEngine()->rules()) {
|
||||
QVariantMap ruleMap;
|
||||
ruleMap.insert("id", rule.id());
|
||||
// ruleMap.insert("triggerId", rule.triggerId());
|
||||
ruleMap.insert("triggerId", rule.triggerTypeId());
|
||||
ruleMap.insert("action", packAction(rule.action()));
|
||||
rulesList.append(ruleMap);
|
||||
}
|
||||
|
||||
@ -36,9 +36,15 @@ QList<Action> RuleEngine::evaluateTrigger(const Trigger &trigger)
|
||||
{
|
||||
QList<Action> actions;
|
||||
for (int i = 0; i < m_rules.count(); ++i) {
|
||||
<<<<<<< HEAD
|
||||
// if (m_rules.at(i).triggerTypeId() == trigger.) {
|
||||
// actions << m_rules.at(i).action();
|
||||
// }
|
||||
=======
|
||||
if (m_rules.at(i).triggerTypeId() == trigger.deviceClassId()) {
|
||||
actions << m_rules.at(i).action();
|
||||
}
|
||||
>>>>>>> meister anker plugin added
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
@ -51,7 +57,11 @@ RuleEngine::RuleError RuleEngine::addRule(const QUuid &triggerTypeId, const Acti
|
||||
|
||||
QSettings settings(rulesFileName);
|
||||
settings.beginGroup(rule.id().toString());
|
||||
<<<<<<< HEAD
|
||||
settings.setValue("triggerTypeId", rule.triggerTypeId());
|
||||
=======
|
||||
settings.setValue("triggerId", rule.triggerTypeId());
|
||||
>>>>>>> meister anker plugin added
|
||||
|
||||
settings.beginGroup("action");
|
||||
settings.setValue("id", rule.action().id());
|
||||
|
||||
@ -26,3 +26,4 @@ HEADERS += hivecore.h \
|
||||
# FIXME: Drop this and link them dynamically
|
||||
LIBS += -L../plugins/deviceplugins/devicepluginelro/ -lhive_devicepluginelro
|
||||
LIBS += -L../plugins/deviceplugins/devicepluginintertechno/ -lhive_devicepluginintertechno
|
||||
LIBS += -L../plugins/deviceplugins/devicepluginmeisteranker/ -lhive_devicepluginmeisteranker
|
||||
|
||||
Reference in New Issue
Block a user