From 27d1861886490a6ae2a5e3904373259ed7368e5f Mon Sep 17 00:00:00 2001 From: Boernsman Date: Wed, 28 Oct 2020 19:46:20 +0100 Subject: [PATCH] fixed w1 temperature sensor --- onewire/integrationpluginonewire.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/onewire/integrationpluginonewire.cpp b/onewire/integrationpluginonewire.cpp index dc4757da..c34e34a0 100644 --- a/onewire/integrationpluginonewire.cpp +++ b/onewire/integrationpluginonewire.cpp @@ -292,14 +292,17 @@ void IntegrationPluginOneWire::executeAction(ThingActionInfo *info) void IntegrationPluginOneWire::thingRemoved(Thing *thing) { if (thing->thingClassId() == oneWireInterfaceThingClassId) { - m_owfsInterface->deleteLater(); - m_owfsInterface = nullptr; - return; + if (m_owfsInterface) { + m_owfsInterface->deleteLater(); + m_owfsInterface = nullptr; + } } if (myThings().filterByThingClassId(temperatureSensorThingClassId).isEmpty()) { - m_w1Interface->deleteLater(); - m_w1Interface = nullptr; + if(m_w1Interface) { + m_w1Interface->deleteLater(); + m_w1Interface = nullptr; + } } if (myThings().empty()) { @@ -337,12 +340,12 @@ void IntegrationPluginOneWire::onPluginTimer() double temperature = 0; bool connected = false; - if (myThings().findById(thing->parentId())->thingClassId() == oneWireInterfaceThingClassId) { + if (!thing->parentId().isNull()) { if (m_owfsInterface) { temperature = m_owfsInterface->getTemperature(address); connected = m_owfsInterface->isConnected(address); } else { - qCWarning(dcOneWire()) << "onPlugInTimer: OWFS interface not setup yet for thing" << thing->name(); + qCWarning(dcOneWire()) << "onPlugInTimer: OWFS interface not setup for thing" << thing->name(); } } else {