Skip to content

Commit

Permalink
Merge branch 'emsesp:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy authored Dec 27, 2022
2 parents feca878 + f53fd74 commit 9b66b02
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 27 deletions.
5 changes: 4 additions & 1 deletion src/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,13 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
// id may be used to represent a heating circuit for example
// returns 0 if the command errored, 1 (TRUE) if ok, 2 if not found, 3 if error or 4 if not allowed
uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * value, const bool is_admin, const int8_t id, JsonObject & output) {
if (cmd == nullptr) {
return CommandRet::NOT_FOUND;
}
uint8_t return_code = CommandRet::OK;

auto dname = EMSdevice::device_type_2_device_name(device_type);
uint8_t device_id = EMSESP::device_id_from_cmd(device_type, id, cmd);
uint8_t device_id = EMSESP::device_id_from_cmd(device_type, cmd, id);

// see if there is a command registered
auto cf = find_command(device_type, device_id, cmd);
Expand Down
17 changes: 17 additions & 0 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,13 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
MAKE_CF_CB(set_hpHystPool),
50,
1500);
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&silentMode_,
DeviceValueType::ENUM,
FL_(enum_silentMode),
FL_(silentMode),
DeviceValueUOM::NONE,
MAKE_CF_CB(set_silentMode));
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&minTempSilent_,
DeviceValueType::INT,
Expand Down Expand Up @@ -1571,6 +1578,7 @@ void Boiler::process_amExtraMessage(std::shared_ptr<const Telegram> telegram) {
// Boiler(0x08) -> All(0x00), ?(0x0484), data: 00 00 14 28 0D 50 00 00 00 02 02 07 28 01 00 02 05 19 0A 0A 03 0D 07 00 0A
// Boiler(0x08) -> All(0x00), ?(0x0484), data: 01 90 00 F6 28 14 64 00 00 E1 00 1E 00 1E 01 64 01 64 54 20 00 00 (offset 25)
void Boiler::process_HpSilentMode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, silentMode_, 10); // enum off-auto-on
has_update(telegram, minTempSilent_, 11);
has_update(telegram, hpHystHeat_, 37); // is / 5
has_update(telegram, hpHystCool_, 35); // is / 5, maybe offset swapped with pool
Expand Down Expand Up @@ -2547,6 +2555,15 @@ bool Boiler::set_maxHeat(const char * value, const int8_t id) {
return true;
}

bool Boiler::set_silentMode(const char * value, const int8_t id) {
uint8_t v;
if (!Helpers::value2enum(value, v, FL_(enum_silentMode))) {
return false;
}
write_command(0x484, 10, v, 0x484);
return true;
}

bool Boiler::set_minTempSilent(const char * value, const int8_t id) {
int v;
if (Helpers::value2temperature(value, v)) {
Expand Down
2 changes: 2 additions & 0 deletions src/devices/boiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class Boiler : public EMSdevice {
uint8_t auxHeaterOff_;
uint8_t auxHeaterStatus_;
uint16_t auxHeaterDelay_;
uint8_t silentMode_;
int8_t minTempSilent_;
int8_t tempParMode_;
int8_t auxHeatMixValve_;
Expand Down Expand Up @@ -401,6 +402,7 @@ class Boiler : public EMSdevice {
inline bool set_maxHeatDhw(const char * value, const int8_t id) {
return set_maxHeat(value, 4);
}
bool set_silentMode(const char * value, const int8_t id);
bool set_minTempSilent(const char * value, const int8_t id);
bool set_additionalHeaterOnly(const char * value, const int8_t id);
bool set_additionalHeater(const char * value, const int8_t id);
Expand Down
2 changes: 1 addition & 1 deletion src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ bool EMSdevice::has_tag(const uint8_t tag) const {
}

// check if the device has a command on the with this tag.
bool EMSdevice::has_cmd(const int8_t id, const char * cmd) const {
bool EMSdevice::has_cmd(const char * cmd, const int8_t id) const {
uint8_t tag = DeviceValueTAG::TAG_HC1 + id - 1;
for (const auto & dv : devicevalues_) {
if ((id < 1 || dv.tag == tag) && dv.has_cmd && strcmp(dv.short_name, cmd) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/emsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class EMSdevice {
static std::string tag_to_mqtt(uint8_t tag);

bool has_tag(const uint8_t tag) const;
bool has_cmd(const int8_t id, const char * cmd) const;
bool has_cmd(const char * cmd, const int8_t id) const;

inline uint8_t device_id() const {
return device_id_;
Expand Down
4 changes: 2 additions & 2 deletions src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ bool EMSESP::cmd_is_readonly(const uint8_t device_type, const uint8_t device_id,
return false;
}

uint8_t EMSESP::device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd) {
uint8_t EMSESP::device_id_from_cmd(const uint8_t device_type, const char * cmd, const int8_t id) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && emsdevice->device_type() == device_type && emsdevice->has_cmd(id, cmd)) {
if (emsdevice && emsdevice->device_type() == device_type && emsdevice->has_cmd(cmd, id)) {
return emsdevice->device_id();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/emsesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class EMSESP {
static bool device_exists(const uint8_t device_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 device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd);
static uint8_t device_id_from_cmd(const uint8_t device_type, const char * cmd, const int8_t id);
static uint8_t count_devices(const uint8_t device_type);
static uint8_t count_devices();
static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id);
Expand Down
1 change: 1 addition & 0 deletions src/locale_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ MAKE_PSTR_ENUM(enum_lowNoiseMode, FL_(off), FL_(reduced_output), FL_(switchoff),

// heat pump
MAKE_PSTR_ENUM(enum_hpactivity, FL_(none), FL_(heating), FL_(cooling), FL_(hot_water), FL_(pool), FL_(unknown), FL_(defrost))
MAKE_PSTR_ENUM(enum_silentMode, FL_(off), FL_(auto), FL_(on))

// solar
MAKE_PSTR_ENUM(enum_solarmode, FL_(constant), FL_(pwm), FL_(analog))
Expand Down
1 change: 1 addition & 0 deletions src/locale_translations.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ MAKE_PSTR_LIST(auxHeaterOff, "auxheateroff", "disable auxilliary heater", "Verbi
MAKE_PSTR_LIST(auxHeaterStatus, "auxheaterstatus", "auxilliary heater status", "Status Zusatzheizer", "Bijverwarming", "", "status dogrzewacza", "", "Chauffage auxiliaire")
MAKE_PSTR_LIST(auxHeaterOnly, "auxheateronly", "auxilliary heater only", "nur Zusatzheizer","Alleen bijverwarming", "", "tylko dogrzewacz", "", "Que chauffage auxiliaire")
MAKE_PSTR_LIST(auxHeaterDelay, "auxheaterdelay", "auxilliary heater on delay", "Zusatzheizer verzögert ein", "Bijverw. vertraagd aan", "Tillskottfördröjning på", "opóźnienie włączania dogrzewacza", "Tilleggsvarmer forsinket på", "Chauff app tempo marche")
MAKE_PSTR_LIST(silentMode, "silentmode", "silent mode", "Silentmodus", " Stiller gebruik", "", "trybu cichego", "", "Fct silencieux")
MAKE_PSTR_LIST(minTempSilent, "mintempsilent", "min. outside temp. for silent mode", "Minimale Aussentemperatur Silentmodus", " Stiller gebruik min. buitentemp", "", "minimalna temperatura zewnętrzna dla trybu cichego", "", "Fct silencieux: Temp. extérieure min.")
MAKE_PSTR_LIST(tempParMode, "tempparmode", "outside temp. parallel mode", "Aussentemperatur Parallelmodus", "Buitentemp. parallelbedr", "", "maksymalna temperatura zewnętrzna dla dogrzewacza", "", "Temp. ext. fct parallèle")
MAKE_PSTR_LIST(auxHeatMixValve, "auxheatmix", "aux. heater mixing valve", "Mischer Zusatzheizer", "Bijverwarming menger", "", "mieszacz dogrzewacza", "", "Chauffage auxiliaire mélangeur")
Expand Down
12 changes: 5 additions & 7 deletions src/web/WebAPIService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
}

// output json buffer
auto * response = new PrettyAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE_DYN);
if (!response->getSize()) {
size_t buffer = EMSESP_JSON_SIZE_XXLARGE_DYN;
auto * response = new PrettyAsyncJsonResponse(false, buffer);
while (!response->getSize()) {
delete response;
response = new PrettyAsyncJsonResponse(false, 256);
response->setCode(507); // Insufficient Storage
response->setLength();
request->send(response);
return;
buffer -= 1024;
response = new PrettyAsyncJsonResponse(false, buffer);
}
JsonObject output = response->getRoot();

Expand Down
12 changes: 5 additions & 7 deletions src/web/WebCustomizationService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,12 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) {
// send back list of device entities
void WebCustomizationService::device_entities(AsyncWebServerRequest * request, JsonVariant & json) {
if (json.is<JsonObject>()) {
auto * response = new MsgpackAsyncJsonResponse(true, EMSESP_JSON_SIZE_XXXLARGE_DYN);
if (!response->getSize()) {
size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN;
auto * response = new MsgpackAsyncJsonResponse(true, buffer);
while (!response->getSize()) {
delete response;
response = new MsgpackAsyncJsonResponse(true, 256);
response->setCode(507); // Insufficient Storage
response->setLength();
request->send(response);
return;
buffer -= 1024;
response = new MsgpackAsyncJsonResponse(true, buffer);
}
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->unique_id() == json["id"]) {
Expand Down
12 changes: 5 additions & 7 deletions src/web/WebDataService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,12 @@ void WebDataService::sensor_data(AsyncWebServerRequest * request) {
// Compresses the JSON using MsgPack https://msgpack.org/index.html
void WebDataService::device_data(AsyncWebServerRequest * request, JsonVariant & json) {
if (json.is<JsonObject>()) {
auto * response = new MsgpackAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXXLARGE_DYN);
if (!response->getSize()) {
size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN;
auto * response = new MsgpackAsyncJsonResponse(false, buffer);
while (!response->getSize()) {
delete response;
response = new MsgpackAsyncJsonResponse(false, 256);
response->setCode(507); // Insufficient Storage
response->setLength();
request->send(response);
return;
buffer -= 1024;
response = new MsgpackAsyncJsonResponse(false, buffer);
}
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->unique_id() == json["id"]) {
Expand Down

0 comments on commit 9b66b02

Please sign in to comment.