Mqttitem: value type autodetection

This commit is contained in:
Carl Philipp Klemm 2026-04-21 14:09:59 +02:00
parent 7c96b87a11
commit ff07551a59
6 changed files with 560 additions and 12 deletions

View file

@ -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_;