improved device detection
This commit is contained in:
parent
c8c730fe00
commit
f96b2ab3c8
@ -498,11 +498,13 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
|
||||
if (obj["dev"] == "relay") {
|
||||
qCDebug(dcUniPi()) << "Relay:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt() << "Relay Type:" << obj["relay_type"].toInt() ;
|
||||
qCDebug(dcUniPi()) << "Relay:" << obj["dev"].toString() << "Circuit:" << obj["circuit"].toString() << "Value:" << obj["value"].toInt() << "Relay Type:" << obj["relay_type"].toString() ;
|
||||
|
||||
QString circuit = obj["circuit"].toString();
|
||||
bool value = QVariant(obj["value"].toInt()).toBool();
|
||||
|
||||
if (obj["relay_type"].toString() == "physical") {
|
||||
|
||||
if (!m_relais.contains(circuit)) {
|
||||
//New Device detected
|
||||
m_relais.append(circuit);
|
||||
@ -545,6 +547,22 @@ void DevicePluginUniPi::onWebSocketTextMessageReceived(QString message)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (obj["relay_type"].toString() == "digtial") {
|
||||
if (!m_digitalOutputs.contains(obj["circuit"].toString())){
|
||||
//New Device detected
|
||||
m_digitalOutputs.append(obj["circuit"].toString());
|
||||
} else {
|
||||
|
||||
foreach (Device *device, myDevices()) {
|
||||
if (device->deviceClassId() == digitalOutputDeviceClassId) {
|
||||
if (obj["circuit"] == device->paramValue(digitalOutputDigitalOutputNumberParamTypeId).toString()) {
|
||||
device->setStateValue(digitalOutputDigitalOutputStatusStateTypeId, QVariant(obj["value"].toInt()).toBool());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj["dev"] == "input") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user