don't process dallas if gpio is 0

This commit is contained in:
proddy
2021-03-28 16:27:54 +02:00
parent 22b4b66cff
commit 0c17e8deb3

View File

@@ -35,14 +35,14 @@ uuid::log::Logger DallasSensor::logger_{F_(dallassensor), uuid::log::Facility::D
void DallasSensor::start() { void DallasSensor::start() {
reload(); reload();
#ifndef EMSESP_STANDALONE // disabled if dallas gpio is 0
if (dallas_gpio_) { if (dallas_gpio_) {
#ifndef EMSESP_STANDALONE
bus_.begin(dallas_gpio_); bus_.begin(dallas_gpio_);
}
#endif #endif
// API call
// 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); });
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 // load the MQTT settings
@@ -59,6 +59,10 @@ void DallasSensor::reload() {
} }
void DallasSensor::loop() { void DallasSensor::loop() {
if (!dallas_gpio_) {
return; // dallas gpio is 0 (disabled)
}
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
uint32_t time_now = uuid::get_uptime(); uint32_t time_now = uuid::get_uptime();