Mqttitem: value type autodetection
This commit is contained in:
parent
7c96b87a11
commit
ff07551a59
6 changed files with 560 additions and 12 deletions
|
|
@ -101,6 +101,7 @@ void MqttItem::onDevicesMessageReceived(const QMqttMessage& message)
|
|||
{
|
||||
loadExposeFromDevice(device);
|
||||
exposeLoaded_ = true;
|
||||
Q_EMIT exposeLoaded();
|
||||
|
||||
// Unsubscribe from devices topic since we found our device
|
||||
std::shared_ptr<MqttClient> workClient = client.lock();
|
||||
|
|
@ -293,6 +294,30 @@ void MqttItem::setFromExpose(const QJsonObject& expose)
|
|||
hashId();
|
||||
}
|
||||
|
||||
void MqttItem::triggerExposeLookup()
|
||||
{
|
||||
if(exposeLoaded_)
|
||||
return;
|
||||
|
||||
std::shared_ptr<MqttClient> workClient = client.lock();
|
||||
if(!workClient)
|
||||
return;
|
||||
|
||||
// Reset expose loaded flag to allow re-detection
|
||||
exposeLoaded_ = false;
|
||||
|
||||
// Subscribe to bridge/devices
|
||||
if(devicesSubscription)
|
||||
{
|
||||
disconnect(devicesSubscription->subscription, &QMqttSubscription::messageReceived, this, &MqttItem::onDevicesMessageReceived);
|
||||
workClient->unsubscribe(devicesSubscription);
|
||||
devicesSubscription = nullptr;
|
||||
}
|
||||
|
||||
devicesSubscription = workClient->subscribe(workClient->getBaseTopic() + "/bridge/devices");
|
||||
connect(devicesSubscription->subscription, &QMqttSubscription::messageReceived, this, &MqttItem::onDevicesMessageReceived);
|
||||
}
|
||||
|
||||
QString MqttItem::getTopic() const
|
||||
{
|
||||
return topic_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue