fixed w1 temperature sensor

This commit is contained in:
Boernsman 2020-10-28 19:46:20 +01:00
parent 256593f83c
commit 27d1861886

View File

@ -292,15 +292,18 @@ void IntegrationPluginOneWire::executeAction(ThingActionInfo *info)
void IntegrationPluginOneWire::thingRemoved(Thing *thing) void IntegrationPluginOneWire::thingRemoved(Thing *thing)
{ {
if (thing->thingClassId() == oneWireInterfaceThingClassId) { if (thing->thingClassId() == oneWireInterfaceThingClassId) {
if (m_owfsInterface) {
m_owfsInterface->deleteLater(); m_owfsInterface->deleteLater();
m_owfsInterface = nullptr; m_owfsInterface = nullptr;
return; }
} }
if (myThings().filterByThingClassId(temperatureSensorThingClassId).isEmpty()) { if (myThings().filterByThingClassId(temperatureSensorThingClassId).isEmpty()) {
if(m_w1Interface) {
m_w1Interface->deleteLater(); m_w1Interface->deleteLater();
m_w1Interface = nullptr; m_w1Interface = nullptr;
} }
}
if (myThings().empty()) { if (myThings().empty()) {
hardwareManager()->pluginTimerManager()->unregisterTimer(m_pluginTimer); hardwareManager()->pluginTimerManager()->unregisterTimer(m_pluginTimer);
@ -337,12 +340,12 @@ void IntegrationPluginOneWire::onPluginTimer()
double temperature = 0; double temperature = 0;
bool connected = false; bool connected = false;
if (myThings().findById(thing->parentId())->thingClassId() == oneWireInterfaceThingClassId) { if (!thing->parentId().isNull()) {
if (m_owfsInterface) { if (m_owfsInterface) {
temperature = m_owfsInterface->getTemperature(address); temperature = m_owfsInterface->getTemperature(address);
connected = m_owfsInterface->isConnected(address); connected = m_owfsInterface->isConnected(address);
} else { } 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 { } else {