diff --git a/lib/Hoymiles/src/Hoymiles.cpp b/lib/Hoymiles/src/Hoymiles.cpp index 97922e347..7f1a3c1f3 100644 --- a/lib/Hoymiles/src/Hoymiles.cpp +++ b/lib/Hoymiles/src/Hoymiles.cpp @@ -195,9 +195,9 @@ std::shared_ptr HoymilesClass::getInverterByPos(const uint8_t std::shared_ptr HoymilesClass::getInverterBySerial(const uint64_t serial) { - for (uint8_t i = 0; i < _inverters.size(); i++) { - if (_inverters[i]->serial() == serial) { - return _inverters[i]; + for (auto& inv : _inverters) { + if (inv->serial() == serial) { + return inv; } } return nullptr; @@ -209,9 +209,7 @@ std::shared_ptr HoymilesClass::getInverterByFragment(const fra return nullptr; } - std::shared_ptr inv; - for (uint8_t i = 0; i < _inverters.size(); i++) { - inv = _inverters[i]; + for (auto& inv : _inverters) { serial_u p; p.u64 = inv->serial();