support multi devices of same type

This commit is contained in:
proddy
2025-01-25 13:31:05 +01:00
parent 1d3fec2a95
commit 0953d37303

View File

@@ -766,14 +766,19 @@ void EMSESP::publish_response(std::shared_ptr<const Telegram> telegram) {
bool EMSESP::get_device_value_info(JsonObject root, const char * cmd, const int8_t id, const uint8_t devicetype) {
// check first for EMS devices
bool found_device = false;
for (const auto & emsdevice : emsdevices) {
if (emsdevice->device_type() == devicetype) {
found_device = true;
// we may have multiple devices of the same type, so we need to check the id (e.g. id could be a hc number)
if (emsdevice->get_value_info(root, cmd, id)) {
// if we have no values, keep going traversing the devices, it may be a thermostat with multiple hc's
if (root.size()) {
return true;
}
}
}
}
// if the EMS device was valid, but the cmd not found exit. it will be handled upstream.
if (found_device) {
return false;