some fixes. successfully switching an elro switch using an intertechno remote with this revision

pull/1/head
Michael Zanetti 2014-01-03 23:49:40 +01:00
parent 3d21f85c20
commit e6129d0cea
8 changed files with 47 additions and 16 deletions

View File

@ -89,6 +89,18 @@ QList<Device *> DeviceManager::findConfiguredDevices(const QUuid &deviceClassId)
return ret;
}
DeviceClass DeviceManager::findDeviceClassforTrigger(const QUuid &triggerTypeId)
{
foreach (const DeviceClass &deviceClass, m_supportedDevices) {
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
if (triggerType.id() == triggerTypeId) {
return deviceClass;
}
}
}
return DeviceClass(QUuid(), QUuid());
}
DeviceClass DeviceManager::findDeviceClass(const QUuid &deviceClassId)
{
foreach (const DeviceClass &deviceClass, m_supportedDevices) {

View File

@ -37,6 +37,7 @@ public:
Device* findConfiguredDevice(const QUuid &id) const;
QList<Device*> findConfiguredDevices(const QUuid &deviceClassId);
DeviceClass findDeviceClassforTrigger(const QUuid &triggerTypeId);
DeviceClass findDeviceClass(const QUuid &deviceClassId);
signals:

View File

@ -14,9 +14,9 @@ Radio433::Radio433(QObject *parent) :
// Set up transmitter
m_transmitter = new Gpio(this,22);
m_transmitter->setDirection(OUTPUT);
m_transmitter->setValue(HIGH);
m_transmitter->setValue(LOW);
connect(m_receiver,SIGNAL(pinInterrupt()),this,SLOT(handleInterrupt()));
connect(m_receiver, &Gpio::pinInterrupt, this, &Radio433::handleInterrupt);
m_receiver->start();
}
@ -48,6 +48,7 @@ void Radio433::sendData(QList<int> rawData)
//qDebug() << "signal sent." << rawData;
// re-enable it
m_transmitter->setValue(LOW);
m_receiver->start();
}

View File

@ -195,7 +195,9 @@ void DevicePluginIntertechno::executeAction(Device *device, const Action &action
}
void DevicePluginIntertechno::receiveData(QList<int> rawData)
{
{
// filter right here a wrong signal length
if(rawData.length() != 49){
return;

View File

@ -120,9 +120,10 @@ void JsonRPCServer::handleRulesMessage(int clientId, int commandId, const QStrin
QVariantMap triggerParams = triggerMap.value("params").toMap();
Trigger trigger(triggerTypeId, triggerDeviceId, triggerParams);
Action action(params.value("deviceId").toString());
action.setName(params.value("name").toString());
action.setParams(params.value("params").toMap());
QVariantMap actionMap = params.value("action").toMap();
Action action(actionMap.value("deviceId").toString());
action.setName(actionMap.value("name").toString());
action.setParams(actionMap.value("params").toMap());
switch(HiveCore::instance()->ruleEngine()->addRule(trigger, action)) {
case RuleEngine::RuleErrorNoError:

View File

@ -51,13 +51,14 @@ QList<Action> RuleEngine::evaluateTrigger(const Trigger &trigger)
RuleEngine::RuleError RuleEngine::addRule(const Trigger &trigger, const Action &action)
{
qDebug() << "adding rule: Trigger:" << trigger.triggerTypeId() << "deviceid:" << action.deviceId();
Device *device = HiveCore::instance()->deviceManager()->findConfiguredDevice(trigger.deviceId());
if (!device) {
qWarning() << "Cannot create rule. No configured device for triggerTypeId" << trigger.triggerTypeId();
return RuleErrorDeviceNotFound;
}
DeviceClass deviceClass = HiveCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
qDebug() << "found deviceClass" << deviceClass.name();
bool triggerTypeFound = false;
foreach (const TriggerType &triggerType, deviceClass.triggers()) {

View File

@ -2,13 +2,26 @@
# Creates a Mumbi remote
if [ -z $1 ]; then
echo "usage $0 host"
echo "usage $0 host device"
elif [ $1 == "list" ]; then
echo "elroremote elroswitch intertechnoremote meisteranker"
elif [ -z $2 ]; then
echo "usage $0 host device"
else
# Adds an ELRO remote control on channel 00000
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{d85c1ef4-197c-4053-8e40-707aa671d302}","params":{"channel1":"false", "channel2":"false", "channel3":"false", "channel4": "false", "channel5":"false" }}}'; sleep 1) | nc $1 1234
# Adds a ELRO power switch on channel 00000 and group E
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{308ae6e6-38b3-4b3a-a513-3199da2764f8}","params":{"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
# Adds an intertechno remote control
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","params":{"familycode":"J"}}}'; sleep 1) | nc $1 1234
if [ $2 == "elroremote" ]; then
# Adds an ELRO remote control on channel 00000
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{d85c1ef4-197c-4053-8e40-707aa671d302}","params":{"channel1":"false", "channel2":"false", "channel3":"false", "channel4": "false", "channel5":"false" }}}'; sleep 1) | nc $1 1234
elif [ $2 == "elroswitch" ]; then
# Adds a ELRO power switch on channel 00000 and group E
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{308ae6e6-38b3-4b3a-a513-3199da2764f8}","params":{"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
elif [ $2 == "intertechnoremote" ]; then
# Adds an intertechno remote control
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","params":{"familycode":"J"}}}'; sleep 1) | nc $1 1234
elif [ $2 == "meisteranker" ]; then
# Adds an intertechno remote control
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClass": "{e37e9f34-95b9-4a22-ae4f-e8b874eec871}","params":{"id":"1"}}}'; sleep 1) | nc $1 1234
fi
fi

View File

@ -3,6 +3,6 @@
if test -z $3; then
echo "usage: $1 host triggerId actionId"
else
(echo '{"id":1, "method":"Rules.AddRule", "params":{"triggerTypeId": "'$2'", "action":{ "deviceId":"'$3'", "name":"rule 1", "actionParams":{"power":"true"}}}}'; sleep 1) | nc $1 1234
(echo '{"id":2, "method":"Rules.AddRule", "params":{"triggerTypeId": "'$2'", "action":{ "deviceId":"'$3'", "name":"rule 2", "actionParams":{"power":"false"}}}}'; sleep 1) | nc $1 1234
(echo '{"id":1, "method":"Rules.AddRule", "params":{"trigger": {"triggerTypeId": "'$2'", "deviceId":"'$3'", "params":{"power":"true"}}, "action":{ "deviceId":"'$4'", "name":"rule 1", "params":{"power":"true"}}}}'; sleep 1) | nc $1 1234
(echo '{"id":1, "method":"Rules.AddRule", "params":{"trigger": {"triggerTypeId": "'$2'", "deviceId":"'$3'", "params":{"power":"false"}}, "action":{ "deviceId":"'$4'", "name":"rule 1", "params":{"power":"false"}}}}'; sleep 1) | nc $1 1234
fi