Merge pull request #1736 from MichaelDvP/dev

some more id/tag changes
This commit is contained in:
Proddy
2024-05-03 14:01:20 +02:00
committed by GitHub
5 changed files with 19 additions and 30 deletions

View File

@@ -453,7 +453,7 @@ void Command::erase_command(const uint8_t device_type, const char * cmd, uint8_t
}
// get the tagged command
std::string Command::tagged_cmd(std::string cmd, const uint8_t flag) {
std::string Command::tagged_cmd(const std::string & cmd, const uint8_t flag) {
switch (flag & 0x3F) {
case CommandFlag::CMD_FLAG_HC:
return "[hc<n>.]" + cmd;

View File

@@ -124,7 +124,7 @@ class Command {
static void show_all(uuid::console::Shell & shell);
static Command::CmdFunction * find_command(const uint8_t device_type, const uint8_t device_id, const char * cmd, const uint8_t flag);
static std::string tagged_cmd(std::string cmd, const uint8_t flag);
static std::string tagged_cmd(const std::string & cmd, const uint8_t flag);
static void erase_command(const uint8_t device_type, const char * cmd, uint8_t flag = CommandFlag::CMD_FLAG_DEFAULT);
static void show(uuid::console::Shell & shell, uint8_t device_type, bool verbose);

View File

@@ -936,7 +936,7 @@ void Thermostat::process_RC35wwTimer(std::shared_ptr<const Telegram> telegram) {
}
if (telegram->message_length + telegram->offset >= 92 && telegram->offset <= 87) {
char data[sizeof(dhw->wwVacation_)];
char data[sizeof(dhw->wwVacation_) + 4]; // avoid compiler warning
snprintf(data,
sizeof(data),
"%02d.%02d.%04d-%02d.%02d.%04d",
@@ -950,7 +950,7 @@ void Thermostat::process_RC35wwTimer(std::shared_ptr<const Telegram> telegram) {
}
if (telegram->message_length + telegram->offset >= 98 && telegram->offset <= 93) {
char data[sizeof(dhw->wwHoliday_)];
char data[sizeof(dhw->wwHoliday_) + 4]; // avoid compiler warning
snprintf(data,
sizeof(data),
"%02d.%02d.%04d-%02d.%02d.%04d",
@@ -1487,7 +1487,7 @@ void Thermostat::process_RC35Timer(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, hc->party, 86); // time in hours
if (telegram->message_length + telegram->offset >= 92 && telegram->offset <= 87) {
char data[sizeof(hc->vacation)];
char data[sizeof(hc->vacation) + 4]; // avoid compiler warning
snprintf(data,
sizeof(data),
"%02d.%02d.%04d-%02d.%02d.%04d",
@@ -1501,7 +1501,7 @@ void Thermostat::process_RC35Timer(std::shared_ptr<const Telegram> telegram) {
}
if (telegram->message_length + telegram->offset >= 98 && telegram->offset <= 93) {
char data[sizeof(hc->holiday)];
char data[sizeof(hc->holiday) + 4]; // avoid compiler warning
snprintf(data,
sizeof(data),
"%02d.%02d.%04d-%02d.%02d.%04d",
@@ -1523,7 +1523,7 @@ void Thermostat::process_RC30Vacation(std::shared_ptr<const Telegram> telegram)
static uint8_t vacation_telegram[57] = {0}; // make a copy of the whole telegram to access blocks
memcpy(&vacation_telegram[telegram->offset], telegram->message_data, telegram->message_length);
for (uint8_t index = 0; index < 8; index++) {
char data[sizeof(vacation[0])];
char data[sizeof(vacation[0]) + 4]; // avoid compiler warning
snprintf(data,
sizeof(data),
"%02d.%02d.%04d-%02d.%02d.%04d",
@@ -4473,8 +4473,8 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode2), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));
// register_device_value(tag, &hc->holiday, DeviceValueType::STRING, FL_(tpl_holidays), FL_(holidays), DeviceValueUOM::NONE, MAKE_CF_CB(set_holiday));
// register_device_value(tag, &hc->vacation, DeviceValueType::STRING, FL_(tpl_holidays), FL_(vacations), DeviceValueUOM::NONE, MAKE_CF_CB(set_vacation));
// register_device_value(tag, &hc->pause, DeviceValueType::UINT8, FL_(pause), DeviceValueUOM::HOURS, MAKE_CF_CB(set_pause));
// register_device_value(tag, &hc->party, DeviceValueType::UINT8, FL_(party), DeviceValueUOM::HOURS, MAKE_CF_CB(set_party));
register_device_value(tag, &hc->pause, DeviceValueType::UINT8, FL_(pause), DeviceValueUOM::HOURS, MAKE_CF_CB(set_pause));
register_device_value(tag, &hc->party, DeviceValueType::UINT8, FL_(party), DeviceValueUOM::HOURS, MAKE_CF_CB(set_party));
register_device_value(tag, &vacation[0], DeviceValueType::STRING, FL_(tpl_holidays), FL_(vacations1), DeviceValueUOM::NONE, MAKE_CF_CB(set_RC30Vacation1));
register_device_value(tag, &vacation[1], DeviceValueType::STRING, FL_(tpl_holidays), FL_(vacations2), DeviceValueUOM::NONE, MAKE_CF_CB(set_RC30Vacation2));
register_device_value(tag, &vacation[2], DeviceValueType::STRING, FL_(tpl_holidays), FL_(vacations3), DeviceValueUOM::NONE, MAKE_CF_CB(set_RC30Vacation3));

View File

@@ -79,8 +79,8 @@ class Thermostat : public EMSdevice {
uint8_t vacreducemode;
uint8_t wwprio;
uint8_t fastHeatup;
char holiday[26];
char vacation[26];
char holiday[22];
char vacation[22];
char switchtime1[16];
char switchtime2[16];
uint8_t climate;
@@ -192,8 +192,8 @@ class Thermostat : public EMSdevice {
uint8_t wwDailyHeating_;
uint8_t wwDailyHeatTime_;
uint8_t wwWhenModeOff_;
char wwHoliday_[26];
char wwVacation_[26];
char wwHoliday_[22];
char wwVacation_[22];
uint8_t dhw() const {
return dhw_num_ - 1;

View File

@@ -369,9 +369,8 @@ bool EMSdevice::has_tags(const int8_t tag) const {
// check if the device has a command with this tag.
bool EMSdevice::has_cmd(const char * cmd, const int8_t id) const {
int8_t tag = id;
for (const auto & dv : devicevalues_) {
if ((id < 1 || dv.tag == tag) && dv.has_cmd && strcmp(dv.short_name, cmd) == 0) {
if ((id < 1 || dv.tag == id) && dv.has_cmd && strcmp(dv.short_name, cmd) == 0) {
return true;
}
}
@@ -720,10 +719,9 @@ bool EMSdevice::is_readable(const void * value_p) const {
// check if value/command is readonly
// matches valid tags too
bool EMSdevice::is_readonly(const std::string & cmd, const int8_t id) const {
int8_t tag = id > 0 ? id : DeviceValueTAG::TAG_NONE;
for (const auto & dv : devicevalues_) {
// check command name and tag, id -1 is default hc and only checks name
if (dv.has_cmd && std::string(dv.short_name) == cmd && (dv.tag < DeviceValueTAG::TAG_HC1 || dv.tag == tag || id == -1)) {
if (dv.has_cmd && std::string(dv.short_name) == cmd && (dv.tag < DeviceValueTAG::TAG_HC1 || dv.tag == id || id == -1)) {
return dv.has_state(DeviceValueState::DV_READONLY);
}
}
@@ -846,26 +844,18 @@ std::string EMSdevice::get_value_uom(const std::string & shortname) const {
bool EMSdevice::export_values(uint8_t device_type, JsonObject output, const int8_t id, const uint8_t output_target) {
bool has_value = false;
int8_t tag;
if (id >= 1 && id <= DeviceValueTAG::TAG_HS16) {
tag = id; // this sets also DHW and HS
} else if (id == -1 || id == 0) {
tag = DeviceValueTAG::TAG_NONE;
} else {
return false;
}
if (id > 0 || output_target == EMSdevice::OUTPUT_TARGET::API_VERBOSE) {
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_type)) {
has_value |= emsdevice->generate_values(output, tag, (id < 1), output_target); // use nested for id -1 and 0
has_value |= emsdevice->generate_values(output, id, (id < 1), output_target); // use nested for id -1 and 0
}
}
return has_value;
}
// for nested output add for each tag
for (tag = DeviceValueTAG::TAG_DEVICE_DATA; tag <= DeviceValueTAG::TAG_HS16; tag++) {
for (int8_t tag = DeviceValueTAG::TAG_DEVICE_DATA; tag <= DeviceValueTAG::TAG_HS16; tag++) {
JsonObject output_hc = output;
bool nest_created = false;
for (const auto & emsdevice : EMSESP::emsdevices) {
@@ -1391,9 +1381,8 @@ void EMSdevice::dump_telegram_info(std::vector<TelegramFunctionDump> & telegram_
// builds json for a specific device value / entity
// cmd is the endpoint or name of the device entity
// returns false if failed, otherwise true
bool EMSdevice::get_value_info(JsonObject output, const char * cmd, const int8_t id) {
bool EMSdevice::get_value_info(JsonObject output, const char * cmd, const int8_t tag) {
JsonObject json = output;
int8_t tag = id;
// make a copy of the string command for parsing
char command_s[30];