Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
recognize sending devices
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Feb 1, 2021
1 parent 2fa275b commit 36f0555
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- multiple roomcontrollers
- readback after write with delay (give ems-devices time to set the value)
- Thermostat ES72/RC20, device 66 to RC20_2 command-set
- recognize sending devices which are not in telegram 0x07

### Changed
- split `show values` in smaller packages and separate heating circuits
Expand Down
14 changes: 12 additions & 2 deletions src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,24 +651,31 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
return false;
}

// remember if we first get scan results from UBADevices
static bool first_scan_done_ = false;
// check for common types, like the Version(0x02)
if (telegram->type_id == EMSdevice::EMS_TYPE_VERSION) {
process_version(telegram);
return true;
} else if (telegram->type_id == EMSdevice::EMS_TYPE_UBADevices) {
process_UBADevices(telegram);
if (telegram->dest == EMSbus::ems_bus_id()) {
first_scan_done_ = true;
}
return true;
}

// match device_id and type_id
// calls the associated process function for that EMS device
// returns false if the device_id doesn't recognize it
// after the telegram has been processed, call the updated_values() function to see if we need to force an MQTT publish
bool found = false;
bool found = false;
bool knowndevice = false;
for (const auto & emsdevice : emsdevices) {
if (emsdevice) {
if (emsdevice->is_device_id(telegram->src)) {
found = emsdevice->handle_telegram(telegram);
knowndevice = true;
found = emsdevice->handle_telegram(telegram);
// if we correctly processes the telegram follow up with sending it via MQTT if needed
if (found && Mqtt::connected()) {
if ((mqtt_.get_publish_onchange(emsdevice->device_type()) && emsdevice->updated_values()) || telegram->type_id == publish_id_) {
Expand All @@ -688,6 +695,9 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
if (watch() == WATCH_UNKNOWN) {
LOG_NOTICE(pretty_telegram(telegram).c_str());
}
if (first_scan_done_ && !knowndevice && (telegram->src != EMSbus::ems_bus_id()) && (telegram->src != 0x0B) && (telegram->src != 0x0C) && (telegram->src != 0x0D)) {
send_read_request(EMSdevice::EMS_TYPE_VERSION, telegram->src);
}
}

return found;
Expand Down

0 comments on commit 36f0555

Please sign in to comment.