mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix Arduino 7 (using to<> and not as<>
This commit is contained in:
@@ -854,7 +854,7 @@ bool EMSdevice::export_values(uint8_t device_type, JsonObject & output, const in
|
|||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
||||||
if (!nest_created && emsdevice->has_tags(tag)) {
|
if (!nest_created && emsdevice->has_tags(tag)) {
|
||||||
output_hc = output[EMSdevice::tag_to_mqtt(tag)].add<JsonObject>();
|
output_hc = output[EMSdevice::tag_to_mqtt(tag)].to<JsonObject>();
|
||||||
nest_created = true;
|
nest_created = true;
|
||||||
}
|
}
|
||||||
has_value |= emsdevice->generate_values(output_hc, tag, true, output_target); // use nested for id -1 and 0
|
has_value |= emsdevice->generate_values(output_hc, tag, true, output_target); // use nested for id -1 and 0
|
||||||
@@ -1614,15 +1614,19 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c
|
|||||||
if (dv.tag != old_tag) {
|
if (dv.tag != old_tag) {
|
||||||
old_tag = dv.tag;
|
old_tag = dv.tag;
|
||||||
if (nested && have_tag && dv.tag >= DeviceValueTAG::TAG_HC1) {
|
if (nested && have_tag && dv.tag >= DeviceValueTAG::TAG_HC1) {
|
||||||
json = output[tag_to_mqtt(dv.tag)].add<JsonObject>();
|
json = output[tag_to_mqtt(dv.tag)].to<JsonObject>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not overwrite
|
// do not overwrite
|
||||||
if (json.containsKey(name)) {
|
if (json.containsKey(name)) {
|
||||||
|
#ifdef EMSESP_DEBUG
|
||||||
EMSESP::logger().debug("double json key: %s", name);
|
EMSESP::logger().debug("double json key: %s", name);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle Booleans
|
// handle Booleans
|
||||||
if (dv.type == DeviceValueType::BOOL && Helpers::hasValue(*(uint8_t *)(dv.value_p), EMS_VALUE_BOOL)) {
|
if (dv.type == DeviceValueType::BOOL && Helpers::hasValue(*(uint8_t *)(dv.value_p), EMS_VALUE_BOOL)) {
|
||||||
// see how to render the value depending on the setting
|
// see how to render the value depending on the setting
|
||||||
|
|||||||
@@ -560,15 +560,15 @@ void EMSESP::publish_device_values(uint8_t device_type) {
|
|||||||
|
|
||||||
// group by device type
|
// group by device type
|
||||||
for (uint8_t tag = DeviceValueTAG::TAG_BOILER_DATA_WW; tag <= DeviceValueTAG::TAG_HS16; tag++) {
|
for (uint8_t tag = DeviceValueTAG::TAG_BOILER_DATA_WW; tag <= DeviceValueTAG::TAG_HS16; tag++) {
|
||||||
JsonObject json_hc = json;
|
JsonObject json_tag = json;
|
||||||
bool nest_created = false;
|
bool nest_created = false;
|
||||||
for (const auto & emsdevice : emsdevices) {
|
for (const auto & emsdevice : emsdevices) {
|
||||||
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
if (emsdevice && (emsdevice->device_type() == device_type)) {
|
||||||
if (nested && !nest_created && emsdevice->has_tags(tag)) {
|
if (nested && !nest_created && emsdevice->has_tags(tag)) {
|
||||||
json_hc = doc[EMSdevice::tag_to_mqtt(tag)].add<JsonObject>();
|
json_tag = doc[EMSdevice::tag_to_mqtt(tag)].to<JsonObject>();
|
||||||
nest_created = true;
|
nest_created = true;
|
||||||
}
|
}
|
||||||
need_publish |= emsdevice->generate_values(json_hc, tag, false, EMSdevice::OUTPUT_TARGET::MQTT);
|
need_publish |= emsdevice->generate_values(json_tag, tag, false, EMSdevice::OUTPUT_TARGET::MQTT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (need_publish && ((!nested && tag >= DeviceValueTAG::TAG_DEVICE_DATA_WW) || (tag == DeviceValueTAG::TAG_BOILER_DATA_WW))) {
|
if (need_publish && ((!nested && tag >= DeviceValueTAG::TAG_DEVICE_DATA_WW) || (tag == DeviceValueTAG::TAG_BOILER_DATA_WW))) {
|
||||||
|
|||||||
@@ -115,18 +115,18 @@ bool System::command_allvalues(const char * value, const int8_t id, JsonObject &
|
|||||||
|
|
||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
std::string title = emsdevice->device_type_2_device_name_translated() + std::string(" ") + emsdevice->to_string();
|
std::string title = emsdevice->device_type_2_device_name_translated() + std::string(" ") + emsdevice->to_string();
|
||||||
device_output = output[title].add<JsonObject>();
|
device_output = output[title].to<JsonObject>();
|
||||||
emsdevice->generate_values(device_output, DeviceValueTAG::TAG_NONE, true, EMSdevice::OUTPUT_TARGET::API_VERBOSE); // use nested for id -1 and 0
|
emsdevice->generate_values(device_output, DeviceValueTAG::TAG_NONE, true, EMSdevice::OUTPUT_TARGET::API_VERBOSE); // use nested for id -1 and 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom entities
|
// Custom entities
|
||||||
device_output = output["Custom Entities"].add<JsonObject>();
|
device_output = output["Custom Entities"].to<JsonObject>();
|
||||||
EMSESP::webCustomEntityService.get_value_info(device_output, "");
|
EMSESP::webCustomEntityService.get_value_info(device_output, "");
|
||||||
|
|
||||||
// Sensors
|
// Sensors
|
||||||
device_output = output["Analog Sensors"].add<JsonObject>();
|
device_output = output["Analog Sensors"].to<JsonObject>();
|
||||||
EMSESP::analogsensor_.command_info(nullptr, 0, device_output);
|
EMSESP::analogsensor_.command_info(nullptr, 0, device_output);
|
||||||
device_output = output["Temperature Sensors"].add<JsonObject>();
|
device_output = output["Temperature Sensors"].to<JsonObject>();
|
||||||
EMSESP::temperaturesensor_.command_info(nullptr, 0, device_output);
|
EMSESP::temperaturesensor_.command_info(nullptr, 0, device_output);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1178,7 +1178,7 @@ void System::extractSettings(const char * filename, const char * section, JsonOb
|
|||||||
DeserializationError error = deserializeJson(jsonDocument, settingsFile);
|
DeserializationError error = deserializeJson(jsonDocument, settingsFile);
|
||||||
if (error == DeserializationError::Ok && jsonDocument.is<JsonObject>()) {
|
if (error == DeserializationError::Ok && jsonDocument.is<JsonObject>()) {
|
||||||
JsonObject jsonObject = jsonDocument.as<JsonObject>();
|
JsonObject jsonObject = jsonDocument.as<JsonObject>();
|
||||||
JsonObject node = output[section].add<JsonObject>();
|
JsonObject node = output[section].to<JsonObject>();
|
||||||
for (JsonPair kvp : jsonObject) {
|
for (JsonPair kvp : jsonObject) {
|
||||||
node[kvp.key()] = kvp.value();
|
node[kvp.key()] = kvp.value();
|
||||||
}
|
}
|
||||||
@@ -1211,7 +1211,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
JsonObject node;
|
JsonObject node;
|
||||||
|
|
||||||
// System
|
// System
|
||||||
node = output["System Info"].add<JsonObject>();
|
node = output["System Info"].to<JsonObject>();
|
||||||
node["version"] = EMSESP_APP_VERSION;
|
node["version"] = EMSESP_APP_VERSION;
|
||||||
node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
|
node["uptime"] = uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3);
|
||||||
node["uptime (seconds)"] = uuid::get_uptime_sec();
|
node["uptime (seconds)"] = uuid::get_uptime_sec();
|
||||||
@@ -1228,7 +1228,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
// Network Status
|
// Network Status
|
||||||
node = output["Network Info"].add<JsonObject>();
|
node = output["Network Info"].to<JsonObject>();
|
||||||
if (EMSESP::system_.ethernet_connected()) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
node["network"] = "Ethernet";
|
node["network"] = "Ethernet";
|
||||||
node["hostname"] = ETH.getHostname();
|
node["hostname"] = ETH.getHostname();
|
||||||
@@ -1276,7 +1276,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// NTP status
|
// NTP status
|
||||||
node = output["NTP Info"].add<JsonObject>();
|
node = output["NTP Info"].to<JsonObject>();
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
node["NTP status"] = EMSESP::system_.ntp_connected() ? "connected" : "disconnected";
|
node["NTP status"] = EMSESP::system_.ntp_connected() ? "connected" : "disconnected";
|
||||||
EMSESP::esp8266React.getNTPSettingsService()->read([&](NTPSettings & settings) {
|
EMSESP::esp8266React.getNTPSettingsService()->read([&](NTPSettings & settings) {
|
||||||
@@ -1287,7 +1287,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
});
|
});
|
||||||
|
|
||||||
// OTA status
|
// OTA status
|
||||||
node = output["OTA Info"].add<JsonObject>();
|
node = output["OTA Info"].to<JsonObject>();
|
||||||
EMSESP::esp8266React.getOTASettingsService()->read([&](OTASettings & settings) {
|
EMSESP::esp8266React.getOTASettingsService()->read([&](OTASettings & settings) {
|
||||||
node["enabled"] = settings.enabled;
|
node["enabled"] = settings.enabled;
|
||||||
node["port"] = settings.port;
|
node["port"] = settings.port;
|
||||||
@@ -1295,7 +1295,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MQTT Status
|
// MQTT Status
|
||||||
node = output["MQTT Info"].add<JsonObject>();
|
node = output["MQTT Info"].to<JsonObject>();
|
||||||
node["MQTT status"] = Mqtt::connected() ? F_(connected) : F_(disconnected);
|
node["MQTT status"] = Mqtt::connected() ? F_(connected) : F_(disconnected);
|
||||||
if (Mqtt::enabled()) {
|
if (Mqtt::enabled()) {
|
||||||
node["MQTT publishes"] = Mqtt::publish_count();
|
node["MQTT publishes"] = Mqtt::publish_count();
|
||||||
@@ -1329,7 +1329,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Syslog Status
|
// Syslog Status
|
||||||
node = output["Syslog Info"].add<JsonObject>();
|
node = output["Syslog Info"].to<JsonObject>();
|
||||||
node["enabled"] = EMSESP::system_.syslog_enabled_;
|
node["enabled"] = EMSESP::system_.syslog_enabled_;
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (EMSESP::system_.syslog_enabled_) {
|
if (EMSESP::system_.syslog_enabled_) {
|
||||||
@@ -1341,7 +1341,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sensor Status
|
// Sensor Status
|
||||||
node = output["Sensor Info"].add<JsonObject>();
|
node = output["Sensor Info"].to<JsonObject>();
|
||||||
if (EMSESP::sensor_enabled()) {
|
if (EMSESP::sensor_enabled()) {
|
||||||
node["temperature sensors"] = EMSESP::temperaturesensor_.no_sensors();
|
node["temperature sensors"] = EMSESP::temperaturesensor_.no_sensors();
|
||||||
node["temperature sensor reads"] = EMSESP::temperaturesensor_.reads();
|
node["temperature sensor reads"] = EMSESP::temperaturesensor_.reads();
|
||||||
@@ -1354,12 +1354,12 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// API Status
|
// API Status
|
||||||
node = output["API Info"].add<JsonObject>();
|
node = output["API Info"].to<JsonObject>();
|
||||||
node["API calls"] = WebAPIService::api_count();
|
node["API calls"] = WebAPIService::api_count();
|
||||||
node["API fails"] = WebAPIService::api_fails();
|
node["API fails"] = WebAPIService::api_fails();
|
||||||
|
|
||||||
// EMS Bus Status
|
// EMS Bus Status
|
||||||
node = output["Bus Info"].add<JsonObject>();
|
node = output["Bus Info"].to<JsonObject>();
|
||||||
switch (EMSESP::bus_status()) {
|
switch (EMSESP::bus_status()) {
|
||||||
case EMSESP::BUS_STATUS_OFFLINE:
|
case EMSESP::BUS_STATUS_OFFLINE:
|
||||||
node["bus status"] = "disconnected";
|
node["bus status"] = "disconnected";
|
||||||
@@ -1387,7 +1387,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
node = output["Settings"].add<JsonObject>();
|
node = output["Settings"].to<JsonObject>();
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
||||||
node["board profile"] = settings.board_profile;
|
node["board profile"] = settings.board_profile;
|
||||||
node["locale"] = settings.locale;
|
node["locale"] = settings.locale;
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ void WebAPIService::getSettings(AsyncWebServerRequest * request) {
|
|||||||
|
|
||||||
root["type"] = "settings";
|
root["type"] = "settings";
|
||||||
|
|
||||||
JsonObject node = root["System"].add<JsonObject>();
|
JsonObject node = root["System"].to<JsonObject>();
|
||||||
node["version"] = EMSESP_APP_VERSION;
|
node["version"] = EMSESP_APP_VERSION;
|
||||||
|
|
||||||
System::extractSettings(NETWORK_SETTINGS_FILE, "Network", root);
|
System::extractSettings(NETWORK_SETTINGS_FILE, "Network", root);
|
||||||
|
|||||||
Reference in New Issue
Block a user