Merge PR #606: MyStrom: Fix discovery for Swiss plugs
This commit is contained in:
commit
fc4024cf14
@ -44,6 +44,12 @@
|
|||||||
// API doc:
|
// API doc:
|
||||||
// https://api.mystrom.ch/
|
// https://api.mystrom.ch/
|
||||||
|
|
||||||
|
QList<int> supportedPlugs {
|
||||||
|
101, // Switch CH v1
|
||||||
|
106, // Switch CH v2
|
||||||
|
107 // Switch EU
|
||||||
|
};
|
||||||
|
|
||||||
IntegrationPluginMyStrom::IntegrationPluginMyStrom()
|
IntegrationPluginMyStrom::IntegrationPluginMyStrom()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -93,7 +99,7 @@ void IntegrationPluginMyStrom::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
qCDebug(dcMyStrom) << "Info response:" << qUtf8Printable(jsonDoc.toJson());
|
qCDebug(dcMyStrom) << "Info response:" << qUtf8Printable(jsonDoc.toJson());
|
||||||
|
|
||||||
QVariantMap deviceInfo = jsonDoc.toVariant().toMap();
|
QVariantMap deviceInfo = jsonDoc.toVariant().toMap();
|
||||||
if (deviceInfo.value("type").toInt() == 107) {
|
if (supportedPlugs.contains(deviceInfo.value("type").toInt())) {
|
||||||
ThingDescriptor descriptor(switchThingClassId, entry.name(), entry.hostAddress().toString());
|
ThingDescriptor descriptor(switchThingClassId, entry.name(), entry.hostAddress().toString());
|
||||||
descriptor.setParams({Param(switchThingIdParamTypeId, entry.txt("id"))});
|
descriptor.setParams({Param(switchThingIdParamTypeId, entry.txt("id"))});
|
||||||
info->addThingDescriptor(descriptor);
|
info->addThingDescriptor(descriptor);
|
||||||
@ -135,7 +141,7 @@ void IntegrationPluginMyStrom::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
qCDebug(dcMyStrom()) << "Device info:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented));
|
qCDebug(dcMyStrom()) << "Device info:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented));
|
||||||
QVariantMap deviceInfo = jsonDoc.toVariant().toMap();
|
QVariantMap deviceInfo = jsonDoc.toVariant().toMap();
|
||||||
if (deviceInfo.value("type").toInt() != 107) {
|
if (!supportedPlugs.contains(deviceInfo.value("type").toInt())) {
|
||||||
qCWarning(dcMyStrom()) << "This device does not seem to be a myStrom WiFi switch";
|
qCWarning(dcMyStrom()) << "This device does not seem to be a myStrom WiFi switch";
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("This device does not seem to be a myStrom WiFi switch."));
|
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("This device does not seem to be a myStrom WiFi switch."));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user