Merge pull request #2027 from proddy/dev

upgrade to ArduinoJson 7.2
This commit is contained in:
Proddy
2024-09-19 12:17:33 +02:00
committed by GitHub
13 changed files with 6962 additions and 6481 deletions

View File

@@ -24,8 +24,8 @@
"@alova/adapter-xhr": "2.0.7", "@alova/adapter-xhr": "2.0.7",
"@emotion/react": "^11.13.3", "@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0", "@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.0", "@mui/icons-material": "^6.1.1",
"@mui/material": "^6.1.0", "@mui/material": "^6.1.1",
"@table-library/react-table-library": "4.1.7", "@table-library/react-table-library": "4.1.7",
"alova": "3.0.16", "alova": "3.0.16",
"async-validator": "^4.2.5", "async-validator": "^4.2.5",

View File

@@ -824,38 +824,38 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/core-downloads-tracker@npm:^6.1.0": "@mui/core-downloads-tracker@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/core-downloads-tracker@npm:6.1.0" resolution: "@mui/core-downloads-tracker@npm:6.1.1"
checksum: 10c0/9cf0470456567b51450fe1e60b53aac7fb95bdb47ba3400153d29ae3c78c737f9fd1019df24ca553a6127154b92c7ab68547981ab3539ecc9a34a6e2135aac56 checksum: 10c0/ca837b75b8d2147a5a67785725b1158eff1240dbca65effbc9c4387fc7c342416bff332b0678378292738aa1b0224b866979c623a5da426904a43df394782286
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/icons-material@npm:^6.1.0": "@mui/icons-material@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/icons-material@npm:6.1.0" resolution: "@mui/icons-material@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
peerDependencies: peerDependencies:
"@mui/material": ^6.1.0 "@mui/material": ^6.1.1
"@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0 "@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0
react: ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^17.0.0 || ^18.0.0 || ^19.0.0
peerDependenciesMeta: peerDependenciesMeta:
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/4ca4cc1e39c9a09ab5d9589bb795f57e28aa99a7bd9a1715b4e86c501788a05e28db24c78eecf621698ebfc4b6fb316ea1f6257380948f8c8d36a1ea267a7703 checksum: 10c0/fc9f468ebf7ee9238606c915b648a4ba461d1ff241926131cd0de173d9092d8be6b2dc84a9d1bd8abcc6a349793e5501bd9d90487af7e946395a9b5ff104d498
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/material@npm:^6.1.0": "@mui/material@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/material@npm:6.1.0" resolution: "@mui/material@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
"@mui/core-downloads-tracker": "npm:^6.1.0" "@mui/core-downloads-tracker": "npm:^6.1.1"
"@mui/system": "npm:^6.1.0" "@mui/system": "npm:^6.1.1"
"@mui/types": "npm:^7.2.16" "@mui/types": "npm:^7.2.17"
"@mui/utils": "npm:^6.1.0" "@mui/utils": "npm:^6.1.1"
"@popperjs/core": "npm:^2.11.8" "@popperjs/core": "npm:^2.11.8"
"@types/react-transition-group": "npm:^4.4.11" "@types/react-transition-group": "npm:^4.4.11"
clsx: "npm:^2.1.1" clsx: "npm:^2.1.1"
@@ -866,7 +866,7 @@ __metadata:
peerDependencies: peerDependencies:
"@emotion/react": ^11.5.0 "@emotion/react": ^11.5.0
"@emotion/styled": ^11.3.0 "@emotion/styled": ^11.3.0
"@mui/material-pigment-css": ^6.1.0 "@mui/material-pigment-css": ^6.1.1
"@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0 "@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0
react: ^17.0.0 || ^18.0.0 || ^19.0.0 react: ^17.0.0 || ^18.0.0 || ^19.0.0
react-dom: ^17.0.0 || ^18.0.0 || ^19.0.0 react-dom: ^17.0.0 || ^18.0.0 || ^19.0.0
@@ -879,16 +879,16 @@ __metadata:
optional: true optional: true
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/fcfd1f0ebbda77e5d1afcf6883becd52965840b61c55e3e73f18b28b67c9211ffd371055697992d886b371ca3cd8860c3e55aa22a84512b36f8bd5f4fabb43a8 checksum: 10c0/ee47e8ac90db10e104fb3176512f5dd762e4cbf534d6377a0b515d738544eb56f3d4c8c54a1ddc029526b56443fc57ed3637164424245a1f3214d8ba4ff4b5eb
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/private-theming@npm:^6.1.0": "@mui/private-theming@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/private-theming@npm:6.1.0" resolution: "@mui/private-theming@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
"@mui/utils": "npm:^6.1.0" "@mui/utils": "npm:^6.1.1"
prop-types: "npm:^15.8.1" prop-types: "npm:^15.8.1"
peerDependencies: peerDependencies:
"@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0 "@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0
@@ -896,13 +896,13 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/b5ca8cd192bb2979dabb5af91faeb3873f652f4129661eee2feb3473b54a08b78140756154f1128d9b4c1a1d048d97bd186f7c353e6551428b64912dae47a549 checksum: 10c0/a4374cb55f6ca1959aa4cb38c28ace2d8e1e73f97cd0eb3c383a0de977df4a5e2966c5f0ab4d04c596ebf9c224aa196301162f3d1e72a43e20ae6cd06dadfc05
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/styled-engine@npm:^6.1.0": "@mui/styled-engine@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/styled-engine@npm:6.1.0" resolution: "@mui/styled-engine@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
"@emotion/cache": "npm:^11.13.1" "@emotion/cache": "npm:^11.13.1"
@@ -918,19 +918,19 @@ __metadata:
optional: true optional: true
"@emotion/styled": "@emotion/styled":
optional: true optional: true
checksum: 10c0/2466bb2d990ae05c29a3643d0d9687dc901e396e12b352ddf8278698c5cc1b6fa565fc38620e04e436f17f0d340cf999cf51b3beb1779f7188e4e9099a4fe5ab checksum: 10c0/5711ca945b9f93845df477da0a82107e8426d7e4a893d464ab968cbdfc6660960056c785c97a3752d1d6829c264bac78754b5585e4ab8a0e3e1738c505fa8770
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/system@npm:^6.1.0": "@mui/system@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/system@npm:6.1.0" resolution: "@mui/system@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
"@mui/private-theming": "npm:^6.1.0" "@mui/private-theming": "npm:^6.1.1"
"@mui/styled-engine": "npm:^6.1.0" "@mui/styled-engine": "npm:^6.1.1"
"@mui/types": "npm:^7.2.16" "@mui/types": "npm:^7.2.17"
"@mui/utils": "npm:^6.1.0" "@mui/utils": "npm:^6.1.1"
clsx: "npm:^2.1.1" clsx: "npm:^2.1.1"
csstype: "npm:^3.1.3" csstype: "npm:^3.1.3"
prop-types: "npm:^15.8.1" prop-types: "npm:^15.8.1"
@@ -946,28 +946,28 @@ __metadata:
optional: true optional: true
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/8c545e828404532f4e2ae7b54d934ff32d3722322997415e2b5de21250b86174a8ca799fc8103e96ddab8875f866f74dfffd360633f8c49d89712ac56663899d checksum: 10c0/9c7d63b369e4885066f23beac927dc5c8aad78bca32e66044744cb04320fdcd4fe2136de92135ae740b3ba8f369bcd3e75ca95fa7617d3021fd0d358b8aade9f
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/types@npm:^7.2.16": "@mui/types@npm:^7.2.17":
version: 7.2.16 version: 7.2.17
resolution: "@mui/types@npm:7.2.16" resolution: "@mui/types@npm:7.2.17"
peerDependencies: peerDependencies:
"@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0 "@types/react": ^17.0.0 || ^18.0.0 || ^19.0.0
peerDependenciesMeta: peerDependenciesMeta:
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/e51189d464e4217616a0d2bf45468b949c5b660b154fa03f1153456e4ef1422157454ed442dc9bde6a247166c8db7de6c405c629829525e3ca500ee9cf48f507 checksum: 10c0/2dd77e88490d364f1f8408a5270583d323919461812768b804cae3874143d79714a862f14c7167f5f65109f7f1e90252ffee14473e3470dd1ae12d7b7308c6c4
languageName: node languageName: node
linkType: hard linkType: hard
"@mui/utils@npm:^6.1.0": "@mui/utils@npm:^6.1.1":
version: 6.1.0 version: 6.1.1
resolution: "@mui/utils@npm:6.1.0" resolution: "@mui/utils@npm:6.1.1"
dependencies: dependencies:
"@babel/runtime": "npm:^7.25.6" "@babel/runtime": "npm:^7.25.6"
"@mui/types": "npm:^7.2.16" "@mui/types": "npm:^7.2.17"
"@types/prop-types": "npm:^15.7.12" "@types/prop-types": "npm:^15.7.12"
clsx: "npm:^2.1.1" clsx: "npm:^2.1.1"
prop-types: "npm:^15.8.1" prop-types: "npm:^15.8.1"
@@ -978,7 +978,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@types/react": "@types/react":
optional: true optional: true
checksum: 10c0/a20120b8ee2ebbc0774ab54bd92d513aefc35f4f1caafe7fe4bb7aec49389e553033cb74f4b8adc8292b84485cce7965f6570dc902b8195306a64a97cff9a8fd checksum: 10c0/4278d1810b6bf9cb366201414885cdcbfcee383030efc90444d5446a9bcc28ec5c5b299ca2a2b0280721f6d51116f29142119cc5c9c4ec86aafd9d5329aa01a6
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1650,8 +1650,8 @@ __metadata:
"@emotion/react": "npm:^11.13.3" "@emotion/react": "npm:^11.13.3"
"@emotion/styled": "npm:^11.13.0" "@emotion/styled": "npm:^11.13.0"
"@eslint/js": "npm:^9.10.0" "@eslint/js": "npm:^9.10.0"
"@mui/icons-material": "npm:^6.1.0" "@mui/icons-material": "npm:^6.1.1"
"@mui/material": "npm:^6.1.0" "@mui/material": "npm:^6.1.1"
"@preact/compat": "npm:^18.3.1" "@preact/compat": "npm:^18.3.1"
"@preact/preset-vite": "npm:^2.9.1" "@preact/preset-vite": "npm:^2.9.1"
"@table-library/react-table-library": "npm:4.1.7" "@table-library/react-table-library": "npm:4.1.7"

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
Version 7.1.0 Version 7.2.0
From https://github.com/bblanchon/ArduinoJson/releases From https://github.com/bblanchon/ArduinoJson/releases

View File

@@ -55,7 +55,7 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
const char * device_s = nullptr; const char * device_s = nullptr;
if (!num_paths) { if (!num_paths) {
// we must look for the device in the JSON body // we must look for the device in the JSON body
if (input.containsKey("device")) { if (input["device"].is<const char *>()) {
device_s = input["device"]; device_s = input["device"];
} }
} else { } else {
@@ -89,9 +89,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
command_p = command; command_p = command;
} else { } else {
// take it from the JSON // take it from the JSON
if (input.containsKey("entity")) { if (input["entity"].is<const char *>()) {
command_p = input["entity"]; command_p = input["entity"];
} else if (input.containsKey("cmd")) { } else if (input["cmd"].is<const char *>()) {
command_p = input["cmd"]; command_p = input["cmd"];
} }
} }
@@ -111,20 +111,20 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
} }
} }
// if we don't have an id/hc/dhw try and get it from the JSON input // if we don't have an id/hc/dhw try and get it from the JSON input. It must be a number.
// it's allowed to have no id, and then keep the default to -1 // it's allowed to have no id, and then keep the default to -1
if (id_n == -1) { if (id_n == -1) {
if (input.containsKey("hc")) { if (input["hc"].is<int>()) {
id_n = input["hc"]; id_n = input["hc"];
} else if (input.containsKey("dhw")) { } else if (input["dhw"].is<int>()) {
id_n = input["dhw"]; id_n = input["dhw"];
id_n += DeviceValueTAG::TAG_DHW1 - DeviceValueTAG::TAG_HC1; // dhw1 has id 9 id_n += DeviceValueTAG::TAG_DHW1 - DeviceValueTAG::TAG_HC1; // dhw1 has id 9
} else if (input.containsKey("id")) { } else if (input["id"].is<int>()) {
id_n = input["id"]; id_n = input["id"];
} else if (input.containsKey("ahs")) { } else if (input["ahs"].is<int>()) {
id_n = input["ahs"]; id_n = input["ahs"];
id_n += DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1; // ahs1 has id 19 id_n += DeviceValueTAG::TAG_AHS1 - DeviceValueTAG::TAG_HC1; // ahs1 has id 19
} else if (input.containsKey("hs")) { } else if (input["hs"].is<int>()) {
id_n = input["hs"]; id_n = input["hs"];
id_n += DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1; // hs1 has id 20 id_n += DeviceValueTAG::TAG_HS1 - DeviceValueTAG::TAG_HC1; // hs1 has id 20
} }
@@ -132,9 +132,9 @@ uint8_t Command::process(const char * path, const bool is_admin, const JsonObjec
// the value must always come from the input JSON. It's allowed to be empty. // the value must always come from the input JSON. It's allowed to be empty.
JsonVariant data; JsonVariant data;
if (input.containsKey("data")) { if (input["data"].is<JsonVariantConst>()) {
data = input["data"]; data = input["data"];
} else if (input.containsKey("value")) { } else if (input["value"].is<JsonVariantConst>()) {
data = input["value"]; data = input["value"];
} }
@@ -298,8 +298,8 @@ bool Command::set_attribute(JsonObject output, const char * cmd, const char * at
if (attribute == nullptr) { if (attribute == nullptr) {
return true; return true;
} }
if (output.containsKey(attribute)) { if (output[attribute].is<std::string>()) {
std::string data = output[attribute].as<std::string>(); std::string data = output[attribute];
output.clear(); output.clear();
output["api_data"] = data; // always as a string output["api_data"] = data; // always as a string
return true; return true;

View File

@@ -552,8 +552,8 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
if (return_code == CommandRet::OK) { if (return_code == CommandRet::OK) {
if (json.size()) { if (json.size()) {
if (json.containsKey("api_data")) { if (json["api_data"].is<String>()) {
String data = json["api_data"].as<String>(); String data = json["api_data"];
shell.println(data.c_str()); shell.println(data.c_str());
return; return;
} }

View File

@@ -3250,11 +3250,11 @@ bool Thermostat::set_switchtime(const char * value, const uint16_t type_id, char
if (error) { if (error) {
return false; return false;
} }
if (!doc.containsKey("no")) { if (!doc["no"].is<int>()) {
return false; return false;
} }
no = doc["no"].as<int>(); no = doc["no"];
if (!doc.containsKey("day") || !doc.containsKey("mode") || !doc.containsKey("time")) { if (!doc["day"].is<const char *>() || !doc["mode"].is<const char *>() || !doc["time"].is<const char *>()) {
EMSESP::wait_validate(type_id); EMSESP::wait_validate(type_id);
read_command(type_id, 2 * no, 2); read_command(type_id, 2 * no, 2);
return true; return true;

View File

@@ -1681,7 +1681,7 @@ bool EMSdevice::generate_values(JsonObject output, const int8_t tag_filter, cons
} }
// do not overwrite // do not overwrite
if (json.containsKey(name)) { if (json[name].is<const char *>()) {
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
EMSESP::logger().debug("warning: double json key: %s", name); EMSESP::logger().debug("warning: double json key: %s", name);
#endif #endif

View File

@@ -271,7 +271,7 @@ void Mqtt::on_message(const char * topic, const uint8_t * payload, size_t len) {
// if the payload doesn't not contain the key 'value' or 'data', treat the whole payload as the 'value' // if the payload doesn't not contain the key 'value' or 'data', treat the whole payload as the 'value'
if (len != 0) { if (len != 0) {
DeserializationError error = deserializeJson(input_doc, (const char *)message); DeserializationError error = deserializeJson(input_doc, (const char *)message);
if ((!input_doc.containsKey("value") && !input_doc.containsKey("data")) || error) { if (((!input_doc["value"].is<JsonVariantConst>()) && (!input_doc["data"].is<JsonVariantConst>())) || error) {
input_doc.clear(); input_doc.clear();
input_doc["value"] = (const char *)message; // always a string input_doc["value"] = (const char *)message; // always a string
} }

View File

@@ -360,8 +360,8 @@ std::string commands(std::string & expr, bool quotes = true) {
JsonObject input = doc_in.to<JsonObject>(); JsonObject input = doc_in.to<JsonObject>();
std::string cmd_s = "api/" + std::string(cmd); std::string cmd_s = "api/" + std::string(cmd);
emsesp::Command::process(cmd_s.c_str(), true, input, output); emsesp::Command::process(cmd_s.c_str(), true, input, output);
if (output.containsKey("api_data")) { if (output["api_data"].is<std::string>()) {
std::string data = output["api_data"].as<std::string>(); std::string data = output["api_data"];
if (!isnum(data) && quotes) { if (!isnum(data) && quotes) {
data.insert(data.begin(), '"'); data.insert(data.begin(), '"');
data.insert(data.end(), '"'); data.insert(data.end(), '"');

View File

@@ -789,7 +789,6 @@ void System::network_init(bool refresh) {
auto clock_mode = (eth_clock_mode_t)eth_clock_mode_; auto clock_mode = (eth_clock_mode_t)eth_clock_mode_;
// reset power and add a delay as ETH doesn't not always start up correctly after a warm boot // reset power and add a delay as ETH doesn't not always start up correctly after a warm boot
// TODO still experimental
if (eth_power_ != -1) { if (eth_power_ != -1) {
pinMode(eth_power_, OUTPUT); pinMode(eth_power_, OUTPUT);
digitalWrite(eth_power_, LOW); digitalWrite(eth_power_, LOW);

View File

@@ -126,20 +126,20 @@ StateUpdateResult WebCustomEntity::update(JsonObject root, WebCustomEntity & web
webCustomEntity.customEntityItems.push_back(entityItem); // add to list webCustomEntity.customEntityItems.push_back(entityItem); // add to list
if (webCustomEntity.customEntityItems.back().writeable && !webCustomEntity.customEntityItems.back().name.empty()) { if (entityItem.writeable && !entityItem.name.empty()) {
Command::add( Command::add(
EMSdevice::DeviceType::CUSTOM, EMSdevice::DeviceType::CUSTOM,
webCustomEntity.customEntityItems.back().name.c_str(), entityItem.name.c_str(),
[webCustomEntity](const char * value, const int8_t id) { [entityItem](const char * value, const int8_t id) {
return EMSESP::webCustomEntityService.command_setvalue(value, id, webCustomEntity.customEntityItems.back().name.c_str()); return EMSESP::webCustomEntityService.command_setvalue(value, id, entityItem.name.c_str());
}, },
FL_(entity_cmd), FL_(entity_cmd),
CommandFlag::ADMIN_ONLY); CommandFlag::ADMIN_ONLY);
} }
if (webCustomEntity.customEntityItems.back().ram && doc.containsKey(webCustomEntity.customEntityItems.back().name)
&& doc[webCustomEntity.customEntityItems.back().name] != webCustomEntity.customEntityItems.back().value) { if (entityItem.ram && doc[entityItem.name].is<JsonVariantConst>() && doc[entityItem.name] != entityItem.value) {
char cmd[COMMAND_MAX_LENGTH]; char cmd[COMMAND_MAX_LENGTH];
snprintf(cmd, sizeof(cmd), "%s/%s", F_(custom), webCustomEntity.customEntityItems.back().name.c_str()); snprintf(cmd, sizeof(cmd), "%s/%s", F_(custom), entityItem.name.c_str());
EMSESP::webSchedulerService.onChange(cmd); EMSESP::webSchedulerService.onChange(cmd);
} }
} }
@@ -462,7 +462,10 @@ uint8_t WebCustomEntityService::count_entities() {
uint8_t count = 0; uint8_t count = 0;
for (const CustomEntityItem & entity : *customEntityItems_) { for (const CustomEntityItem & entity : *customEntityItems_) {
render_value(output, entity); render_value(output, entity);
count += (output.containsKey(entity.name) || entity.writeable) ? 1 : 0; // TODO check JsonVariant
if (output[entity.name].is<JsonVariantConst>() || entity.writeable) {
count++;
}
} }
return count; return count;
@@ -479,15 +482,18 @@ uint8_t WebCustomEntityService::has_commands() {
// send to dashboard, msgpack don't like serialized, use number // send to dashboard, msgpack don't like serialized, use number
void WebCustomEntityService::generate_value_web(JsonObject output) { void WebCustomEntityService::generate_value_web(JsonObject output) {
// output["label"] = (std::string) "Custom Entities";
JsonArray data = output["data"].to<JsonArray>(); JsonArray data = output["data"].to<JsonArray>();
uint8_t index = 0; uint8_t index = 0;
for (const CustomEntityItem & entity : *customEntityItems_) { for (const CustomEntityItem & entity : *customEntityItems_) {
bool include = false;
JsonObject obj = data.add<JsonObject>(); // create the object, we know there is a value JsonObject obj = data.add<JsonObject>(); // create the object, we know there is a value
obj["id"] = "00" + entity.name; obj["id"] = "00" + entity.name;
obj["u"] = entity.uom; obj["u"] = entity.uom;
if (entity.writeable) { if (entity.writeable) {
obj["c"] = entity.name; obj["c"] = entity.name;
include = true;
if (entity.value_type != DeviceValueType::BOOL && entity.value_type != DeviceValueType::STRING) { if (entity.value_type != DeviceValueType::BOOL && entity.value_type != DeviceValueType::STRING) {
char s[10]; char s[10];
obj["s"] = Helpers::render_value(s, entity.factor, 1); obj["s"] = Helpers::render_value(s, entity.factor, 1);
@@ -498,6 +504,8 @@ void WebCustomEntityService::generate_value_web(JsonObject output) {
case DeviceValueType::BOOL: { case DeviceValueType::BOOL: {
char s[12]; char s[12];
obj["v"] = Helpers::render_boolean(s, (uint8_t)entity.value, true); obj["v"] = Helpers::render_boolean(s, (uint8_t)entity.value, true);
include = true;
JsonArray l = obj["l"].to<JsonArray>(); JsonArray l = obj["l"].to<JsonArray>();
l.add(Helpers::render_boolean(s, false, true)); l.add(Helpers::render_boolean(s, false, true));
l.add(Helpers::render_boolean(s, true, true)); l.add(Helpers::render_boolean(s, true, true));
@@ -506,21 +514,25 @@ void WebCustomEntityService::generate_value_web(JsonObject output) {
case DeviceValueType::INT8: case DeviceValueType::INT8:
if ((int8_t)entity.value != EMS_VALUE_INT8_NOTSET) { if ((int8_t)entity.value != EMS_VALUE_INT8_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (int8_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (int8_t)entity.value, 0);
include = true;
} }
break; break;
case DeviceValueType::UINT8: case DeviceValueType::UINT8:
if ((uint8_t)entity.value != EMS_VALUE_UINT8_NOTSET) { if ((uint8_t)entity.value != EMS_VALUE_UINT8_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (uint8_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (uint8_t)entity.value, 0);
include = true;
} }
break; break;
case DeviceValueType::INT16: case DeviceValueType::INT16:
if ((int16_t)entity.value != EMS_VALUE_INT16_NOTSET) { if ((int16_t)entity.value != EMS_VALUE_INT16_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (int16_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (int16_t)entity.value, 0);
include = true;
} }
break; break;
case DeviceValueType::UINT16: case DeviceValueType::UINT16:
if ((uint16_t)entity.value != EMS_VALUE_UINT16_NOTSET) { if ((uint16_t)entity.value != EMS_VALUE_UINT16_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * (uint16_t)entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * (uint16_t)entity.value, 0);
include = true;
} }
break; break;
case DeviceValueType::UINT24: case DeviceValueType::UINT24:
@@ -528,11 +540,13 @@ void WebCustomEntityService::generate_value_web(JsonObject output) {
case DeviceValueType::UINT32: case DeviceValueType::UINT32:
if (entity.value != EMS_VALUE_UINT24_NOTSET) { if (entity.value != EMS_VALUE_UINT24_NOTSET) {
obj["v"] = Helpers::transformNumFloat(entity.factor * entity.value, 0); obj["v"] = Helpers::transformNumFloat(entity.factor * entity.value, 0);
include = true;
} }
break; break;
case DeviceValueType::STRING: case DeviceValueType::STRING:
if (entity.data.length() > 0) { if (entity.data.length() > 0) {
obj["v"] = entity.data; obj["v"] = entity.data;
include = true;
} }
break; break;
default: default:
@@ -540,10 +554,10 @@ void WebCustomEntityService::generate_value_web(JsonObject output) {
} }
// show only entities with value or command // show only entities with value or command
if (!obj.containsKey("v") && !obj.containsKey("c")) { if (include) {
data.remove(index);
} else {
index++; index++;
} else {
data.remove(index);
} }
} }
} }

View File

@@ -245,7 +245,7 @@ void WebSchedulerService::publish(const bool force) {
JsonDocument doc; JsonDocument doc;
bool ha_created = ha_registered_; bool ha_created = ha_registered_;
for (const ScheduleItem & scheduleItem : *scheduleItems_) { for (const ScheduleItem & scheduleItem : *scheduleItems_) {
if (!scheduleItem.name.empty() && !doc.containsKey(scheduleItem.name)) { if (!scheduleItem.name.empty() && !doc[scheduleItem.name].is<const char *>()) {
if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) { if (EMSESP::system_.bool_format() == BOOL_FORMAT_TRUEFALSE) {
doc[scheduleItem.name] = scheduleItem.active; doc[scheduleItem.name] = scheduleItem.active;
} else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) { } else if (EMSESP::system_.bool_format() == BOOL_FORMAT_10) {