From 0c17e8deb33857c154a0b3814d03ef23352f791a Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 28 Mar 2021 16:27:54 +0200 Subject: [PATCH] don't process dallas if gpio is 0 --- src/dallassensor.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dallassensor.cpp b/src/dallassensor.cpp index 7cf472cbe..83a577016 100644 --- a/src/dallassensor.cpp +++ b/src/dallassensor.cpp @@ -35,14 +35,14 @@ uuid::log::Logger DallasSensor::logger_{F_(dallassensor), uuid::log::Facility::D void DallasSensor::start() { reload(); -#ifndef EMSESP_STANDALONE + // disabled if dallas gpio is 0 if (dallas_gpio_) { +#ifndef EMSESP_STANDALONE bus_.begin(dallas_gpio_); - } #endif - - // API call - Command::add_with_json(EMSdevice::DeviceType::DALLASSENSOR, F_(info), [&](const char * value, const int8_t id, JsonObject & json) { return command_info(value, id, json); }); + // API call + Command::add_with_json(EMSdevice::DeviceType::DALLASSENSOR, F_(info), [&](const char * value, const int8_t id, JsonObject & json) { return command_info(value, id, json); }); + } } // load the MQTT settings @@ -59,6 +59,10 @@ void DallasSensor::reload() { } void DallasSensor::loop() { + if (!dallas_gpio_) { + return; // dallas gpio is 0 (disabled) + } + #ifndef EMSESP_STANDALONE uint32_t time_now = uuid::get_uptime();