handle telegrams from src only

This commit is contained in:
MichaelDvP
2022-08-10 13:07:02 +02:00
parent 029ef56edd
commit b499d908ab

View File

@@ -826,16 +826,13 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
// match device_id and type_id // match device_id and type_id
// calls the associated process function for that EMS device // calls the associated process function for that EMS device
// returns false if the device_id doesn't recognize it // returns false if the device_id doesn't recognize it
// after the telegram has been processed, call see if there have been values changed and we need to do a MQTT publish // after the telegram has been processed, see if there have been values changed and we need to do a MQTT publish
bool found = false; bool found = false;
bool knowndevice = false; bool knowndevice = false;
for (const auto & emsdevice : emsdevices) { for (const auto & emsdevice : emsdevices) {
if (emsdevice->is_device_id(telegram->src) || emsdevice->is_device_id(telegram->dest)) { if (emsdevice->is_device_id(telegram->src)) {
knowndevice = true; knowndevice = true;
found = emsdevice->handle_telegram(telegram); found = emsdevice->handle_telegram(telegram);
if (found && emsdevice->is_device_id(telegram->dest)) {
LOG_DEBUG(F("Process setting 0x%02X for device 0x%02X"), telegram->type_id, telegram->dest);
}
// if we correctly processed the telegram then follow up with sending it via MQTT (if enabled) // if we correctly processed the telegram then follow up with sending it via MQTT (if enabled)
if (found && Mqtt::connected()) { if (found && Mqtt::connected()) {
if ((mqtt_.get_publish_onchange(emsdevice->device_type()) && emsdevice->has_update()) if ((mqtt_.get_publish_onchange(emsdevice->device_type()) && emsdevice->has_update())
@@ -852,7 +849,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (wait_validate_ == telegram->type_id) { if (wait_validate_ == telegram->type_id) {
wait_validate_ = 0; wait_validate_ = 0;
} }
if (!found && emsdevice->is_device_id(telegram->src) && telegram->message_length > 0) { if (!found && telegram->message_length > 0) {
emsdevice->add_handlers_ignored(telegram->type_id); emsdevice->add_handlers_ignored(telegram->type_id);
} }
break; break;