mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add sending devices that are not in 0x07, add id to info command
This commit is contained in:
@@ -6,6 +6,8 @@ See https://github.com/proddy/EMS-ESP/issues/632
|
||||
- Power settings for ESP32
|
||||
- Rx and Tx counts to Heartbeat MQTT payload
|
||||
- Ethernet support (ESP32)
|
||||
- id to info command to show only a heatingcircuit
|
||||
- add sending devices that are not listed to 0x07
|
||||
|
||||
### Fixed
|
||||
- telegrams matched to masterthermostat 0x18
|
||||
|
||||
@@ -396,8 +396,13 @@ void EMSESPShell::add_console_commands() {
|
||||
// no value specified, just the cmd
|
||||
ok = Command::call(device_type, cmd, nullptr, -1, json);
|
||||
} else if (arguments.size() == 3) {
|
||||
if (strncmp(cmd, "info", 4) == 0) {
|
||||
// info has a id but no value
|
||||
ok = Command::call(device_type, cmd, nullptr, atoi(arguments.back().c_str()), json);
|
||||
} else {
|
||||
// has a value but no id
|
||||
ok = Command::call(device_type, cmd, arguments.back().c_str(), -1, json);
|
||||
}
|
||||
} else {
|
||||
// use value, which could be an id or hc
|
||||
ok = Command::call(device_type, cmd, arguments[2].c_str(), atoi(arguments[3].c_str()), json);
|
||||
|
||||
@@ -699,12 +699,17 @@ 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;
|
||||
}
|
||||
|
||||
@@ -713,9 +718,11 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
|
||||
// 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
|
||||
bool found = false;
|
||||
bool knowndevice = false;
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice) {
|
||||
if (emsdevice->is_device_id(telegram->src)) {
|
||||
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()) {
|
||||
@@ -737,6 +744,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;
|
||||
@@ -873,9 +883,15 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
|
||||
// value and id are ignored
|
||||
bool EMSESP::command_info(uint8_t device_type, JsonObject & json, const int8_t id) {
|
||||
bool has_value = false;
|
||||
uint8_t tag = DeviceValueTAG::TAG_NONE;
|
||||
if (id >= 1 && id <= 4) {
|
||||
tag = DeviceValueTAG::TAG_HC1 + id - 1;
|
||||
} else if (id >= 9 && id <= 10) {
|
||||
tag = DeviceValueTAG::TAG_WWC1 + id - 9;
|
||||
}
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() == device_type) && ((device_type != DeviceType::THERMOSTAT) || (emsdevice->device_id() == EMSESP::actual_master_thermostat()))) {
|
||||
has_value |= emsdevice->generate_values_json(json, DeviceValueTAG::TAG_NONE, (id != 0)); // verbose mode
|
||||
has_value |= emsdevice->generate_values_json(json, tag, (id == -1)); // verbose mode only for default
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user