mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Merge branch 'emsesp:dev' into dev
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
@@ -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
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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_;
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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"]) {
|
||||
|
||||
@@ -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"]) {
|
||||
|
||||
Reference in New Issue
Block a user