readonly check with device_id

This commit is contained in:
MichaelDvP
2022-12-22 14:25:20 +01:00
parent 9cbb810fe4
commit d300ed38ea
4 changed files with 6 additions and 6 deletions

View File

@@ -307,7 +307,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
// check if read-only. This also checks for valid tags (e.g. heating circuits) // check if read-only. This also checks for valid tags (e.g. heating circuits)
if (cf->cmdfunction_) { if (cf->cmdfunction_) {
if (EMSESP::cmd_is_readonly(device_type, cmd, id)) { if (EMSESP::cmd_is_readonly(device_type, device_id, cmd, id)) {
return_code = CommandRet::INVALID; // readonly or invalid hc return_code = CommandRet::INVALID; // readonly or invalid hc
} else { } else {
return_code = ((cf->cmdfunction_)(value, id)) ? CommandRet::OK : CommandRet::ERROR; return_code = ((cf->cmdfunction_)(value, id)) ? CommandRet::OK : CommandRet::ERROR;

View File

@@ -214,7 +214,7 @@ std::shared_ptr<Thermostat::HeatingCircuit> Thermostat::heating_circuit(const ui
return heating_circuit; return heating_circuit;
} }
} }
LOG_DEBUG("Heating circuit not fond on device 0x%02X", device_id());
return nullptr; // not found return nullptr; // not found
} }
@@ -3244,7 +3244,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid); write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
return true; return true;
} }
LOG_DEBUG("temperature mode %d not found", mode);
return false; return false;
} }

View File

@@ -105,9 +105,9 @@ void EMSESP::fetch_device_values_type(const uint8_t device_type) {
} }
} }
bool EMSESP::cmd_is_readonly(const uint8_t device_type, const char * cmd, const int8_t id) { bool EMSESP::cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id) {
for (const auto & emsdevice : emsdevices) { for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_type)) { if (emsdevice && (emsdevice->device_type() == device_type) && (!device_id || emsdevice->device_id() == device_id)) {
return emsdevice->is_readonly(cmd, id); return emsdevice->is_readonly(cmd, id);
} }
} }

View File

@@ -129,7 +129,7 @@ class EMSESP {
static void send_write_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset, const uint8_t value, const uint16_t validate_typeid); static void send_write_request(const uint16_t type_id, const uint8_t dest, const uint8_t offset, const uint8_t value, const uint16_t validate_typeid);
static bool device_exists(const uint8_t device_id); static bool device_exists(const uint8_t device_id);
static bool cmd_is_readonly(const uint8_t device_type, const char * cmd, const int8_t id); static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id);
static uint8_t count_devices(const uint8_t device_type); static uint8_t count_devices(const uint8_t device_type);
static uint8_t count_devices(); static uint8_t count_devices();