mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
@@ -420,6 +420,7 @@ const DashboardDevices: FC = () => {
|
|||||||
<MessageBox my={2} level="warning" message={LL.EMS_BUS_SCANNING()} />
|
<MessageBox my={2} level="warning" message={LL.EMS_BUS_SCANNING()} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{coreData.connected && (
|
||||||
<Table data={{ nodes: coreData.devices }} select={device_select} theme={device_theme} layout={{ custom: true }}>
|
<Table data={{ nodes: coreData.devices }} select={device_select} theme={device_theme} layout={{ custom: true }}>
|
||||||
{(tableList: any) => (
|
{(tableList: any) => (
|
||||||
<>
|
<>
|
||||||
@@ -447,6 +448,7 @@ const DashboardDevices: FC = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Table>
|
</Table>
|
||||||
|
)}
|
||||||
</IconContext.Provider>
|
</IconContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ const Help: FC = () => {
|
|||||||
{'github.com/emsesp/EMS-ESP32'}
|
{'github.com/emsesp/EMS-ESP32'}
|
||||||
</Link>
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography color="white" align="center">
|
<Typography color="white" variant="subtitle2" align="center">
|
||||||
@proddy @MichaelDvP
|
@proddy @MichaelDvP
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -68,7 +68,10 @@ class FSPersistence {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// serialize the data to the file
|
// serialize the data to the file
|
||||||
|
#ifdef EMSESP_DEBUG
|
||||||
|
Serial.println("Writing settings to " + String(_filePath));
|
||||||
|
#endif
|
||||||
serializeJson(jsonDocument, settingsFile);
|
serializeJson(jsonDocument, settingsFile);
|
||||||
settingsFile.close();
|
settingsFile.close();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -4226,7 +4226,7 @@ void Thermostat::register_device_values() {
|
|||||||
|
|
||||||
#if defined(EMSESP_STANDALONE_DUMP)
|
#if defined(EMSESP_STANDALONE_DUMP)
|
||||||
// if we're just dumping out values, create a single dummy hc
|
// if we're just dumping out values, create a single dummy hc
|
||||||
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, this->model())); // hc=1
|
register_device_values_hc(std::make_shared<Thermostat::HeatingCircuit>(1, this->model())); // hc=1
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1755,7 +1755,7 @@ void EMSdevice::mqtt_ha_entity_config_create() {
|
|||||||
}
|
}
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
// always create minimum one config
|
// always create minimum one config
|
||||||
if (ESP.getMaxAllocHeap() < (6 * 1024) || (!emsesp::EMSESP::system_.PSram() && ESP.getFreeHeap() < (65 * 1024))) {
|
if (ESP.getMaxAllocHeap() < (6 * 1024) || (!EMSESP::system_.PSram() && ESP.getFreeHeap() < (65 * 1024))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1153,7 +1153,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
|
|||||||
emsdevices.back()->unique_id(++unique_id_count_);
|
emsdevices.back()->unique_id(++unique_id_count_);
|
||||||
|
|
||||||
// sort devices based on type
|
// sort devices based on type
|
||||||
std::sort(emsdevices.begin(), emsdevices.end(), [](const std::unique_ptr<emsesp::EMSdevice> & a, const std::unique_ptr<emsesp::EMSdevice> & b) {
|
std::sort(emsdevices.begin(), emsdevices.end(), [](const std::unique_ptr<EMSdevice> & a, const std::unique_ptr<EMSdevice> & b) {
|
||||||
return a->device_type() < b->device_type();
|
return a->device_type() < b->device_type();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1394,7 +1394,7 @@ void EMSESP::scheduled_fetch_values() {
|
|||||||
EMSESP::EMSESP()
|
EMSESP::EMSESP()
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
: telnet_([this](Stream & stream, const IPAddress & addr, uint16_t port) -> std::shared_ptr<uuid::console::Shell> {
|
: telnet_([this](Stream & stream, const IPAddress & addr, uint16_t port) -> std::shared_ptr<uuid::console::Shell> {
|
||||||
return std::make_shared<emsesp::EMSESPConsole>(*this, stream, addr, port);
|
return std::make_shared<EMSESPConsole>(*this, stream, addr, port);
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -1421,7 +1421,7 @@ void EMSESP::start() {
|
|||||||
// start the file system
|
// start the file system
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
if (!LittleFS.begin(true)) {
|
if (!LittleFS.begin(true)) {
|
||||||
Serial.println("LittleFS Mount Failed. EMS-ESP stopped.");
|
Serial.println("LittleFS Mount Failed. Using default settings.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
src/emsesp.h
10
src/emsesp.h
@@ -83,11 +83,11 @@
|
|||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
using DeviceValueUOM = emsesp::DeviceValue::DeviceValueUOM;
|
using DeviceValueUOM = DeviceValue::DeviceValueUOM;
|
||||||
using DeviceValueType = emsesp::DeviceValue::DeviceValueType;
|
using DeviceValueType = DeviceValue::DeviceValueType;
|
||||||
using DeviceValueState = emsesp::DeviceValue::DeviceValueState;
|
using DeviceValueState = DeviceValue::DeviceValueState;
|
||||||
using DeviceValueTAG = emsesp::DeviceValue::DeviceValueTAG;
|
using DeviceValueTAG = DeviceValue::DeviceValueTAG;
|
||||||
using DeviceValueNumOp = emsesp::DeviceValue::DeviceValueNumOp;
|
using DeviceValueNumOp = DeviceValue::DeviceValueNumOp;
|
||||||
|
|
||||||
// forward declarations for compiler
|
// forward declarations for compiler
|
||||||
class EMSESPShell;
|
class EMSESPShell;
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
|
|
||||||
#include "emsesp.h"
|
#include "emsesp.h"
|
||||||
|
|
||||||
static emsesp::EMSESP application;
|
using namespace emsesp;
|
||||||
|
|
||||||
|
static EMSESP application; // the main application
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
application.start();
|
application.start();
|
||||||
|
|||||||
@@ -211,9 +211,9 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject dev = doc.createNestedObject("dev");
|
JsonObject dev = doc.createNestedObject("dev");
|
||||||
dev["name"] = "EMS-ESP";
|
dev["name"] = "EMS-ESP Shower";
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename() + "-shower");
|
||||||
|
|
||||||
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>()); // add "availability" section
|
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>()); // add "availability" section
|
||||||
|
|
||||||
@@ -241,9 +241,9 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
// doc["ent_cat"] = "diagnostic";
|
// doc["ent_cat"] = "diagnostic";
|
||||||
|
|
||||||
JsonObject dev2 = doc.createNestedObject("dev");
|
JsonObject dev2 = doc.createNestedObject("dev");
|
||||||
dev2["name"] = "EMS-ESP";
|
dev2["name"] = "EMS-ESP Shower";
|
||||||
JsonArray ids2 = dev2.createNestedArray("ids");
|
JsonArray ids2 = dev2.createNestedArray("ids");
|
||||||
ids2.add(Mqtt::basename());
|
ids2.add(Mqtt::basename() + "-shower");
|
||||||
|
|
||||||
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.duration is defined"); // add "availability" section
|
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.duration is defined"); // add "availability" section
|
||||||
|
|
||||||
@@ -268,9 +268,9 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
// doc["ent_cat"] = "diagnostic";
|
// doc["ent_cat"] = "diagnostic";
|
||||||
|
|
||||||
JsonObject dev3 = doc.createNestedObject("dev");
|
JsonObject dev3 = doc.createNestedObject("dev");
|
||||||
dev3["name"] = "EMS-ESP";
|
dev3["name"] = "EMS-ESP Shower";
|
||||||
JsonArray ids3 = dev3.createNestedArray("ids");
|
JsonArray ids3 = dev3.createNestedArray("ids");
|
||||||
ids3.add(Mqtt::basename());
|
ids3.add(Mqtt::basename() + "-shower");
|
||||||
|
|
||||||
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.timestamp is defined"); // add "availability" section
|
Mqtt::add_avty_to_doc(stat_t, doc.as<JsonObject>(), "value_json.timestamp is defined"); // add "availability" section
|
||||||
|
|
||||||
|
|||||||
@@ -1111,7 +1111,7 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
if (!missing_version) {
|
if (!missing_version) {
|
||||||
LOG_INFO("Current version from settings is %d.%d.%d-%s",
|
LOG_INFO("Checking version (settings has %d.%d.%d-%s)...",
|
||||||
settings_version.major(),
|
settings_version.major(),
|
||||||
settings_version.minor(),
|
settings_version.minor(),
|
||||||
settings_version.patch(),
|
settings_version.patch(),
|
||||||
@@ -1119,26 +1119,20 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// always save the new version to the settings
|
|
||||||
EMSESP::webSettingsService.update(
|
|
||||||
[&](WebSettings & settings) {
|
|
||||||
settings.version = EMSESP_APP_VERSION;
|
|
||||||
return StateUpdateResult::CHANGED;
|
|
||||||
},
|
|
||||||
"local");
|
|
||||||
|
|
||||||
if (factory_settings) {
|
if (factory_settings) {
|
||||||
return false; // fresh install, do nothing
|
return false; // fresh install, do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
version::Semver200_version this_version(EMSESP_APP_VERSION);
|
version::Semver200_version this_version(EMSESP_APP_VERSION);
|
||||||
|
|
||||||
|
bool save_version = true;
|
||||||
|
|
||||||
// compare versions
|
// compare versions
|
||||||
bool reboot_required = false;
|
|
||||||
if (this_version > settings_version) {
|
if (this_version > settings_version) {
|
||||||
|
// need upgrade
|
||||||
LOG_NOTICE("Upgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str());
|
LOG_NOTICE("Upgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str());
|
||||||
|
|
||||||
// if we're coming from 3.4.4 or 3.5.0b14 then we need to apply new settings
|
// if we're coming from 3.4.4 or 3.5.0b14 which had no version stored then we need to apply new settings
|
||||||
if (missing_version) {
|
if (missing_version) {
|
||||||
LOG_DEBUG("Setting MQTT Entity ID format to v3.4 format");
|
LOG_DEBUG("Setting MQTT Entity ID format to v3.4 format");
|
||||||
EMSESP::esp8266React.getMqttSettingsService()->update(
|
EMSESP::esp8266React.getMqttSettingsService()->update(
|
||||||
@@ -1148,15 +1142,26 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
},
|
},
|
||||||
"local");
|
"local");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (this_version < settings_version) {
|
} else if (this_version < settings_version) {
|
||||||
|
// need downgrade
|
||||||
LOG_NOTICE("Downgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str());
|
LOG_NOTICE("Downgrading to version %d.%d.%d-%s", this_version.major(), this_version.minor(), this_version.patch(), this_version.prerelease().c_str());
|
||||||
} else {
|
} else {
|
||||||
// same version, do nothing
|
// same version, do nothing
|
||||||
return false;
|
save_version = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return reboot_required;
|
// if we did a change, set the new version and reboot
|
||||||
|
if (save_version) {
|
||||||
|
EMSESP::webSettingsService.update(
|
||||||
|
[&](WebSettings & settings) {
|
||||||
|
settings.version = EMSESP_APP_VERSION;
|
||||||
|
return StateUpdateResult::CHANGED;
|
||||||
|
},
|
||||||
|
"local");
|
||||||
|
return true; // need reboot
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// list commands
|
// list commands
|
||||||
|
|||||||
@@ -544,9 +544,9 @@ void TemperatureSensor::publish_values(const bool force) {
|
|||||||
config["name"] = name;
|
config["name"] = name;
|
||||||
|
|
||||||
JsonObject dev = config.createNestedObject("dev");
|
JsonObject dev = config.createNestedObject("dev");
|
||||||
dev["name"] = Mqtt::basename();
|
dev["name"] = Mqtt::basename() + " Temperature";
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename() + "-temperature");
|
||||||
|
|
||||||
// add "availability" section
|
// add "availability" section
|
||||||
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
||||||
|
|||||||
@@ -427,9 +427,9 @@ void WebCustomEntityService::publish(const bool force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
JsonObject dev = config.createNestedObject("dev");
|
JsonObject dev = config.createNestedObject("dev");
|
||||||
dev["name"] = Mqtt::basename();
|
dev["name"] = Mqtt::basename() + " Custom";
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename() + "-custom");
|
||||||
|
|
||||||
// add "availability" section
|
// add "availability" section
|
||||||
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
||||||
|
|||||||
@@ -288,9 +288,9 @@ void WebSchedulerService::publish(const bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject dev = config.createNestedObject("dev");
|
JsonObject dev = config.createNestedObject("dev");
|
||||||
dev["name"] = Mqtt::basename();
|
dev["name"] = Mqtt::basename() + " Scheduler";
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename() + "-scheduler");
|
||||||
|
|
||||||
// add "availability" section
|
// add "availability" section
|
||||||
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
Mqtt::add_avty_to_doc(stat_t, config.as<JsonObject>(), val_cond);
|
||||||
|
|||||||
Reference in New Issue
Block a user