mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
Merge branch 'dev' into dev
This commit is contained in:
@@ -68,7 +68,7 @@
|
||||
{224, DeviceType::CONTROLLER, F("9000i"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||
{229, DeviceType::CONTROLLER, F("8700i"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||
{230, DeviceType::CONTROLLER, F("BC Base"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||
{240, DeviceType::CONTROLLER, F("Rego 3000"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||
{240, DeviceType::CONTROLLER, F("Rego 3000"), DeviceFlags::EMS_DEVICE_FLAG_IVT}, // 0x09
|
||||
{241, DeviceType::CONTROLLER, F("Condens 5000i"), DeviceFlags::EMS_DEVICE_FLAG_NONE}, // 0x09
|
||||
|
||||
// Thermostat - not currently supporting write operations, like the Easy/100 types - 0x18
|
||||
|
||||
@@ -25,8 +25,10 @@ REGISTER_FACTORY(Controller, EMSdevice::DeviceType::CONTROLLER);
|
||||
Controller::Controller(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const std::string & name, uint8_t flags, uint8_t brand)
|
||||
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
|
||||
// IVT broadcasts Thermostat time from controller (0x09) if display is off.
|
||||
register_telegram_type(0x06, F("RCTime"), false, MAKE_PF_CB(process_dateTime));
|
||||
register_device_value(DeviceValueTAG::TAG_NONE, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE);
|
||||
if ((flags & 0x0F) == EMS_DEVICE_FLAG_IVT) {
|
||||
register_telegram_type(0x06, F("RCTime"), false, MAKE_PF_CB(process_dateTime));
|
||||
register_device_value(DeviceValueTAG::TAG_NONE, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
// process_dateTime - type 0x06 - date and time from a thermostat - 14 bytes long, IVT only
|
||||
@@ -35,7 +37,7 @@ void Controller::process_dateTime(std::shared_ptr<const Telegram> telegram) {
|
||||
return;
|
||||
}
|
||||
char newdatetime[sizeof(dateTime_)];
|
||||
// publich as dd.mm.yyyy hh:mmF
|
||||
// publish as dd.mm.yyyy hh:mmF
|
||||
snprintf(newdatetime,
|
||||
sizeof(dateTime_),
|
||||
"%02d.%02d.%04d %02d:%02d",
|
||||
@@ -47,5 +49,4 @@ void Controller::process_dateTime(std::shared_ptr<const Telegram> telegram) {
|
||||
has_update(dateTime_, newdatetime, sizeof(dateTime_));
|
||||
}
|
||||
|
||||
|
||||
} // namespace emsesp
|
||||
@@ -716,11 +716,9 @@ void EMSdevice::generate_values_web(JsonObject & output) {
|
||||
|
||||
auto mask = Helpers::hextoa((uint8_t)(dv.state >> 4), false); // create mask to a 2-char string
|
||||
|
||||
// add name, prefixing the tag if it exists. This is the id used for the table sorting
|
||||
// add name, prefixing the tag if it exists. This is the id used in the WebUI table and must be unique
|
||||
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
|
||||
obj["id"] = mask + read_flash_string(dv.full_name);
|
||||
} else if (dv.tag < DeviceValueTAG::TAG_HC1) {
|
||||
obj["id"] = mask + tag_to_string(dv.tag) + " " + read_flash_string(dv.full_name);
|
||||
} else {
|
||||
obj["id"] = mask + tag_to_string(dv.tag) + " " + read_flash_string(dv.full_name);
|
||||
}
|
||||
@@ -775,7 +773,7 @@ void EMSdevice::generate_values_web(JsonObject & output) {
|
||||
|
||||
// as generate_values_web() but stripped down to only show all entities and their state
|
||||
// this is used only for WebCustomizationService::device_entities()
|
||||
void EMSdevice::generate_values_web_all(JsonArray & output) {
|
||||
void EMSdevice::generate_values_web_customization(JsonArray & output) {
|
||||
for (const auto & dv : devicevalues_) {
|
||||
// also show commands and entities that have an empty full name
|
||||
JsonObject obj = output.createNestedObject();
|
||||
@@ -831,29 +829,29 @@ void EMSdevice::generate_values_web_all(JsonArray & output) {
|
||||
obj["v"] = (divider > 0) ? time_value / divider : time_value * factor; // sometimes we need to divide by 60
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// must always have v for sorting to work in web
|
||||
obj["v"] = "";
|
||||
}
|
||||
|
||||
// add name, prefixing the tag if it exists as the id (key for table sorting)
|
||||
if (dv.full_name) {
|
||||
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
|
||||
obj["id"] = dv.full_name;
|
||||
} else {
|
||||
char name[50];
|
||||
snprintf(name, sizeof(name), "%s %s", tag_to_string(dv.tag).c_str(), read_flash_string(dv.full_name).c_str());
|
||||
obj["id"] = name;
|
||||
// id holds the shortname and must always have a value for the WebUI table to work
|
||||
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
|
||||
obj["id"] = tag_to_string(dv.tag) + "/" + read_flash_string(dv.short_name);
|
||||
} else {
|
||||
obj["id"] = read_flash_string(dv.short_name);
|
||||
}
|
||||
|
||||
// n is the fullname, and can be optional
|
||||
// don't add the fullname if its a command
|
||||
if (dv.type != DeviceValueType::CMD) {
|
||||
if (dv.full_name) {
|
||||
if ((dv.tag == DeviceValueTAG::TAG_NONE) || tag_to_string(dv.tag).empty()) {
|
||||
obj["n"] = dv.full_name;
|
||||
} else {
|
||||
char name[50];
|
||||
snprintf(name, sizeof(name), "%s %s", tag_to_string(dv.tag).c_str(), read_flash_string(dv.full_name).c_str());
|
||||
obj["n"] = name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
obj["id"] = "";
|
||||
}
|
||||
|
||||
// shortname
|
||||
if (dv.tag >= DeviceValueTAG::TAG_HC1) {
|
||||
obj["s"] = tag_to_string(dv.tag) + "/" + read_flash_string(dv.short_name);
|
||||
} else {
|
||||
obj["s"] = dv.short_name;
|
||||
obj["n"] = "";
|
||||
}
|
||||
|
||||
obj["m"] = dv.state >> 4; // send back the mask state. We're only interested in the high nibble
|
||||
|
||||
@@ -200,7 +200,7 @@ class EMSdevice {
|
||||
enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API_SHORTNAMES, MQTT, CONSOLE };
|
||||
bool generate_values(JsonObject & output, const uint8_t tag_filter, const bool nested, const uint8_t output_target);
|
||||
void generate_values_web(JsonObject & output);
|
||||
void generate_values_web_all(JsonArray & output);
|
||||
void generate_values_web_customization(JsonArray & output);
|
||||
|
||||
void register_device_value(uint8_t tag,
|
||||
void * value_p,
|
||||
@@ -315,6 +315,9 @@ class EMSdevice {
|
||||
// device flags: The lower 4 bits hold the unique identifier, the upper 4 bits are used for specific flags
|
||||
static constexpr uint8_t EMS_DEVICE_FLAG_NONE = 0;
|
||||
|
||||
// Controller
|
||||
static constexpr uint8_t EMS_DEVICE_FLAG_IVT = 1;
|
||||
|
||||
// Boiler
|
||||
static constexpr uint8_t EMS_DEVICE_FLAG_EMS = 1;
|
||||
static constexpr uint8_t EMS_DEVICE_FLAG_EMSPLUS = 2;
|
||||
|
||||
@@ -620,7 +620,7 @@ MAKE_PSTR_LIST(wwDailyHeating, F("wwdailyheating"), F("daily heating"))
|
||||
MAKE_PSTR_LIST(wwDailyHeatTime, F("wwdailyheattime"), F("daily heating time"))
|
||||
MAKE_PSTR_LIST(wwWhenModeOff, F("wwwhenmodeoff"), F("when thermostat mode off"))
|
||||
// thermostat hc
|
||||
MAKE_PSTR_LIST(climate, F("climate"))
|
||||
MAKE_PSTR_LIST(climate, F("HA climate config creation")) // no full-name, hidden, only for creation
|
||||
MAKE_PSTR_LIST(selRoomTemp, F("seltemp"), F("selected room temperature"))
|
||||
MAKE_PSTR_LIST(roomTemp, F("currtemp"), F("current room temperature"))
|
||||
MAKE_PSTR_LIST(mode, F("mode"), F("mode"))
|
||||
|
||||
@@ -418,7 +418,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
// emsdevice->generate_values_web(root);
|
||||
|
||||
JsonArray output = doc.to<JsonArray>();
|
||||
emsdevice->generate_values_web_all(output);
|
||||
emsdevice->generate_values_web_customization(output);
|
||||
|
||||
Serial.print(COLOR_BRIGHT_MAGENTA);
|
||||
serializeJson(doc, Serial);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define EMSESP_APP_VERSION "3.4.1b0"
|
||||
#define EMSESP_APP_VERSION "3.4.2b1"
|
||||
|
||||
@@ -132,6 +132,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
||||
JsonVariant data = output["api_data"];
|
||||
request->send(200, "text/plain; charset=utf-8", data.as<String>());
|
||||
api_count_++;
|
||||
delete response;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ void WebCustomizationService::device_entities(AsyncWebServerRequest * request, J
|
||||
if (emsdevice->unique_id() == json["id"]) {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
JsonArray output = response->getRoot();
|
||||
emsdevice->generate_values_web_all(output);
|
||||
emsdevice->generate_values_web_customization(output);
|
||||
#endif
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
|
||||
Reference in New Issue
Block a user