@@ -30,6 +30,8 @@ DeviceList::DeviceList(QSettings *config, QObject *parent) : QObject(parent), m_
30
30
file.close ();
31
31
}
32
32
33
+ m_specialExposes = {" light" , " switch" , " cover" , " lock" , " thermostat" };
34
+
33
35
connect (m_databaseTimer, &QTimer::timeout, this , &DeviceList::writeDatabase);
34
36
connect (m_propertiesTimer, &QTimer::timeout, this , &DeviceList::writeProperties);
35
37
@@ -369,17 +371,16 @@ void DeviceList::setupEndpoint(const Endpoint &endpoint, const QJsonObject &json
369
371
{
370
372
QString exposeName = it->toString (), itemName = it->toString ().split (' _' ).value (0 ), optionName = multiple ? QString (" %1_%2" ).arg (itemName, QString::number (endpoint->id ())) : itemName;
371
373
QMap <QString, QVariant> option = m_exposeOptions.value (itemName).toMap ();
372
- QList <QString> list = {" light" , " switch" , " cover" , " lock" , " thermostat" };
373
374
Expose expose;
374
375
int type;
375
376
376
- if (!list .contains (itemName))
377
+ if (!m_specialExposes .contains (itemName))
377
378
{
378
379
option.insert (device->options ().value (optionName).toMap ());
379
380
device->options ().insert (optionName, option);
380
381
}
381
382
382
- type = QMetaType::type (QString (list .contains (itemName) ? itemName : option.value (" type" ).toString ()).append (" Expose" ).toUtf8 ());
383
+ type = QMetaType::type (QString (m_specialExposes .contains (itemName) ? itemName : option.value (" type" ).toString ()).append (" Expose" ).toUtf8 ());
383
384
384
385
expose = Expose (type ? reinterpret_cast <ExposeObject*> (QMetaType::create (type)) : new ExposeObject (itemName));
385
386
expose->setName (exposeName);
@@ -702,10 +703,12 @@ void DeviceList::recognizeDevice(const Device &device)
702
703
expose->setParent (it.value ().data ());
703
704
recognizeMultipleExpose (device, it.value (), expose);
704
705
706
+ if (!m_specialExposes.contains (expose->name ()))
707
+ device->options ().insert (QString (" %1_%2" ).arg (expose->name (), QString::number (it.key ())), m_exposeOptions.value (expose->name ()).toMap ());
708
+
705
709
if (list.contains (expose->name ()))
706
710
continue ;
707
711
708
- device->options ().insert (QString (" %1_%2" ).arg (expose->name (), QString::number (it.key ())), m_exposeOptions.value (expose->name ()).toMap ());
709
712
list.append (expose->name ());
710
713
}
711
714
0 commit comments