mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
API updates
This commit is contained in:
Binary file not shown.
@@ -313,7 +313,7 @@ const WiFiSettingsForm: FC = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{restartNeeded && (
|
{restartNeeded && (
|
||||||
<MessageBox my={2} level="warning" message={LL.RESTART_TEXT()}>
|
<MessageBox my={2} level="warning" message={LL.RESTART_TEXT(0)}>
|
||||||
<Button startIcon={<PowerSettingsNewIcon />} variant="contained" color="error" onClick={restart}>
|
<Button startIcon={<PowerSettingsNewIcon />} variant="contained" color="error" onClick={restart}>
|
||||||
{LL.RESTART()}
|
{LL.RESTART()}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -63,16 +63,15 @@ class FSPersistence {
|
|||||||
// serialize it to filesystem
|
// serialize it to filesystem
|
||||||
File settingsFile = _fs->open(_filePath, "w");
|
File settingsFile = _fs->open(_filePath, "w");
|
||||||
|
|
||||||
#ifdef EMSESP_DEBUG
|
|
||||||
Serial.println("Writing settings to " + String(_filePath));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// failed to open file, return false
|
// failed to open file, return false
|
||||||
if (!settingsFile || !jsonObject.size()) {
|
if (!settingsFile || !jsonObject.size()) {
|
||||||
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;
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ build_flags =
|
|||||||
; platform = https://github.com/platformio/platform-espressif32.git
|
; platform = https://github.com/platformio/platform-espressif32.git
|
||||||
; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
|
; platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF5
|
||||||
; platform_packages = https://github.com/espressif/arduino-esp32.git#3.0.0-alpha2
|
; platform_packages = https://github.com/espressif/arduino-esp32.git#3.0.0-alpha2
|
||||||
|
|
||||||
platform = espressif32@6.4.0
|
platform = espressif32@6.4.0
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
|
|||||||
@@ -2,6 +2,12 @@
|
|||||||
# to be used with "REST Client" extension in Visual Studio Code (https://marketplace.visualstudio.com/items?itemName=humao.rest-client)
|
# to be used with "REST Client" extension in Visual Studio Code (https://marketplace.visualstudio.com/items?itemName=humao.rest-client)
|
||||||
# Open this file in VSC, modify the token, go to the API call and click on 'Send Request' (or Ctrl+Alt+R)
|
# Open this file in VSC, modify the token, go to the API call and click on 'Send Request' (or Ctrl+Alt+R)
|
||||||
# The response will be shown in the right panel
|
# The response will be shown in the right panel
|
||||||
|
#
|
||||||
|
# You can also test with the command line
|
||||||
|
# test using CLI with:
|
||||||
|
# curl -X POST http://10.10.10.135/rest/signIn \
|
||||||
|
# -H 'Content-Type: application/json' \
|
||||||
|
# -d '{ "value" : 22 }'
|
||||||
|
|
||||||
@host = http://ems-esp.local
|
@host = http://ems-esp.local
|
||||||
@host_dev = http://10.10.10.135
|
@host_dev = http://10.10.10.135
|
||||||
@@ -9,13 +15,9 @@
|
|||||||
@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
|
@token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiYWRtaW4iOnRydWV9.2bHpWya2C7Q12WjNUBD6_7N3RCD7CMl-EGhyQVzFdDg
|
||||||
|
|
||||||
GET {{host}}/api/system/info
|
GET {{host}}/api/system/info
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host}}/api/thermostat/seltemp
|
GET {{host}}/api/thermostat/seltemp
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST {{host}}/api/thermostat/seltemp
|
POST {{host}}/api/thermostat/seltemp
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
@@ -23,9 +25,7 @@ Authorization: Bearer {{token}}
|
|||||||
{
|
{
|
||||||
"value" : 21.0
|
"value" : 21.0
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST {{host}}/api/thermostat
|
POST {{host}}/api/thermostat
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
@@ -34,9 +34,7 @@ Authorization: Bearer {{token}}
|
|||||||
"entity" : "seltemp",
|
"entity" : "seltemp",
|
||||||
"value" : 21.0
|
"value" : 21.0
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST {{host}}/api
|
POST {{host}}/api
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
@@ -46,95 +44,68 @@ Authorization: Bearer {{token}}
|
|||||||
"entity" : "wwtapactivated",
|
"entity" : "wwtapactivated",
|
||||||
"value" : "on"
|
"value" : "on"
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host}}/api/system/restart
|
GET {{host}}/api/system/restart
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host}}/api/boiler/coldshot
|
GET {{host}}/api/boiler/coldshot
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host}}/api/temperaturesensor/info
|
GET {{host}}/api/temperaturesensor/info
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test on dev
|
# Test on dev
|
||||||
#
|
#
|
||||||
|
|
||||||
GET {{host_dev}}/rest/features
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
GET {{host_dev}}/api/system/info
|
GET {{host_dev}}/api/system/info
|
||||||
|
|
||||||
# Run a test. EMS-ESP must be compiled with -DEMSESP_TEST
|
|
||||||
# Use this to load up a dummy thermostat and boiler with data
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/api?device=system&cmd=test&data=general
|
GET {{host_dev}}/api?device=system&cmd=test&data=general
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/api/boiler/info
|
GET {{host_dev}}/api/boiler/info
|
||||||
|
|
||||||
###
|
###
|
||||||
GET {{host_dev}}/api/boiler/values
|
GET {{host_dev}}/api/boiler/values
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/api/analogsensor/info
|
GET {{host_dev}}/api/analogsensor/info
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/api/boiler/coldshot
|
GET {{host_dev}}/api/boiler/coldshot
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
###
|
||||||
|
GET {{host_dev}}/api/system/commands
|
||||||
|
###
|
||||||
|
POST {{host_dev}}/api
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"device" : "system",
|
||||||
|
"entity" : "info",
|
||||||
|
"id" : 0
|
||||||
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
GET {{host_dev}}/rest/features
|
||||||
GET {{host_dev}}/api/system/commands
|
|
||||||
|
|
||||||
###
|
###
|
||||||
GET {{host_dev}}/rest/getSettings
|
GET {{host_dev}}/rest/getSettings
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
POST {{host_dev}}/rest/signIn
|
POST {{host_dev}}/rest/signIn
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/rest/coreData
|
GET {{host_dev}}/rest/coreData
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/rest/logSettings
|
GET {{host_dev}}/rest/logSettings
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/rest/systemStatus
|
GET {{host_dev}}/rest/systemStatus
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/rest/deviceData?id=1
|
GET {{host_dev}}/rest/deviceData?id=1
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
GET {{host_dev}}/rest/networkSettings
|
GET {{host_dev}}/rest/networkSettings
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
# test using CLI with:
|
|
||||||
curl -X POST http://10.10.10.135/rest/signIn \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{ "value" : 22 }'
|
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ void AnalogSensor::reload() {
|
|||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, sensor.type);
|
sensors_.emplace_back(sensor.gpio, sensor.name, sensor.offset, sensor.factor, sensor.uom, sensor.type);
|
||||||
sensors_.back().ha_registered = false; // this will trigger recrate of the HA config
|
sensors_.back().ha_registered = false; // this will trigger recreate of the HA config
|
||||||
if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) {
|
if (sensor.type == AnalogType::COUNTER || sensor.type >= AnalogType::DIGITAL_OUT) {
|
||||||
sensors_.back().set_value(sensor.offset);
|
sensors_.back().set_value(sensor.offset);
|
||||||
} else {
|
} else {
|
||||||
@@ -616,9 +616,9 @@ void AnalogSensor::publish_values(const bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject dev = config.createNestedObject("dev");
|
JsonObject dev = config.createNestedObject("dev");
|
||||||
dev["name"] = name;
|
dev["name"] = Mqtt::basename() + " Analog";
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add(Mqtt::basename());
|
ids.add(Mqtt::basename() + "-analog");
|
||||||
|
|
||||||
// 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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1159,7 +1159,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();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1398,7 +1398,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
|
||||||
{
|
{
|
||||||
@@ -1488,7 +1488,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();
|
||||||
|
|||||||
@@ -1194,12 +1194,16 @@ bool Mqtt::publish_ha_climate_config(const uint8_t tag, const bool has_roomtemp,
|
|||||||
|
|
||||||
snprintf(mode_str_tpl,
|
snprintf(mode_str_tpl,
|
||||||
sizeof(mode_str_tpl),
|
sizeof(mode_str_tpl),
|
||||||
"{%%if %s%%}off{%%elif %s=='manual'%%}heat{%%elif %s=='day'%%}heat{%%elif %s=='night'%%}off{%%elif %s=='off'%%}off{%%else%%}auto{%%endif%%}",
|
"{%%if %s%%}off{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}heat{%%elif %s=='%s'%%}off{%%elif %s=='%s'%%}off{%%else%%}auto{%%endif%%}",
|
||||||
hc_mode_cond,
|
hc_mode_cond,
|
||||||
hc_mode_s,
|
hc_mode_s,
|
||||||
|
Helpers::translated_word(FL_(manual)),
|
||||||
hc_mode_s,
|
hc_mode_s,
|
||||||
|
Helpers::translated_word(FL_(day)),
|
||||||
hc_mode_s,
|
hc_mode_s,
|
||||||
hc_mode_s);
|
Helpers::translated_word(FL_(night)),
|
||||||
|
hc_mode_s,
|
||||||
|
Helpers::translated_word(FL_(off)));
|
||||||
|
|
||||||
snprintf(name_s, sizeof(name_s), "Hc%d", hc_num);
|
snprintf(name_s, sizeof(name_s), "Hc%d", hc_num);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ void Shower::set_shower_state(bool state, bool force) {
|
|||||||
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
ha_configdone_ = Mqtt::queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
|
||||||
|
|
||||||
//
|
//
|
||||||
// shower duaration
|
// shower duration
|
||||||
//
|
//
|
||||||
doc.clear();
|
doc.clear();
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
@@ -1112,7 +1112,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(),
|
||||||
@@ -1120,26 +1120,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(
|
||||||
@@ -1149,15 +1143,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
|
||||||
@@ -1220,15 +1225,14 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
|
|||||||
node["free app"] = EMSESP::system_.appFree(); // kilobytes
|
node["free app"] = EMSESP::system_.appFree(); // kilobytes
|
||||||
node["partition"] = esp_ota_get_running_partition()->label;
|
node["partition"] = esp_ota_get_running_partition()->label;
|
||||||
|
|
||||||
// TODO test if works
|
// hash: Helpers::data_to_hex(desc->app_elf_sha256, sizeof(desc->app_elf_sha256));
|
||||||
const esp_app_desc_t * desc = esp_ota_get_app_description();
|
const esp_app_desc_t * desc =
|
||||||
|
esp_ota_get_app_description(); // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/misc_system_api.html#_CPPv414esp_app_desc_t
|
||||||
if (desc != nullptr) {
|
if (desc != nullptr) {
|
||||||
node["app_build"] = std::string(desc->date) + " " + desc->time + " hash: " + Helpers::data_to_hex(desc->app_elf_sha256, sizeof(desc->app_elf_sha256));
|
node["app_build"] = std::string(desc->date) + " " + desc->time;
|
||||||
}
|
}
|
||||||
#endif
|
node["build_date"] = std::string(__DATE__) + " " + __TIME__;
|
||||||
node["reset reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
|
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
|
||||||
// Network Status
|
// Network Status
|
||||||
node = output.createNestedObject("Network Info");
|
node = output.createNestedObject("Network Info");
|
||||||
if (EMSESP::system_.ethernet_connected()) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -282,8 +282,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("general");
|
run_test("general");
|
||||||
|
|
||||||
// add sensors
|
// add sensors
|
||||||
emsesp::EMSESP::analogsensor_.test();
|
EMSESP::analogsensor_.test();
|
||||||
emsesp::EMSESP::temperaturesensor_.test();
|
EMSESP::temperaturesensor_.test();
|
||||||
|
|
||||||
// shell.invoke_command("show devices");
|
// shell.invoke_command("show devices");
|
||||||
shell.invoke_command("show values");
|
shell.invoke_command("show values");
|
||||||
@@ -704,7 +704,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
|
|
||||||
if (command == "temperature") {
|
if (command == "temperature") {
|
||||||
shell.printfln("Testing adding Temperature sensor");
|
shell.printfln("Testing adding Temperature sensor");
|
||||||
emsesp::EMSESP::temperaturesensor_.test();
|
EMSESP::temperaturesensor_.test();
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,7 +714,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
Mqtt::nested_format(1);
|
Mqtt::nested_format(1);
|
||||||
// Mqtt::nested_format(0);
|
// Mqtt::nested_format(0);
|
||||||
|
|
||||||
emsesp::EMSESP::temperaturesensor_.test();
|
EMSESP::temperaturesensor_.test();
|
||||||
shell.invoke_command("show values");
|
shell.invoke_command("show values");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
|
||||||
@@ -732,7 +732,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
Mqtt::nested_format(1);
|
Mqtt::nested_format(1);
|
||||||
// Mqtt::nested_format(0);
|
// Mqtt::nested_format(0);
|
||||||
|
|
||||||
emsesp::EMSESP::analogsensor_.test();
|
EMSESP::analogsensor_.test();
|
||||||
shell.invoke_command("show values");
|
shell.invoke_command("show values");
|
||||||
// shell.invoke_command("call system publish");
|
// shell.invoke_command("call system publish");
|
||||||
// shell.invoke_command("show mqtt");
|
// shell.invoke_command("show mqtt");
|
||||||
@@ -956,19 +956,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
/*
|
/*
|
||||||
requestX.url("/api/system"); // check if defaults to info
|
requestX.url("/api/system"); // check if defaults to info
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
emsesp::EMSESP::logger().notice("*");
|
EMSESP::logger().notice("*");
|
||||||
|
|
||||||
requestX.url("/api/system/info");
|
requestX.url("/api/system/info");
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
emsesp::EMSESP::logger().notice("*");
|
EMSESP::logger().notice("*");
|
||||||
|
|
||||||
requestX.url("/api/thermostat"); // check if defaults to values
|
requestX.url("/api/thermostat"); // check if defaults to values
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
emsesp::EMSESP::logger().notice("*");
|
EMSESP::logger().notice("*");
|
||||||
|
|
||||||
requestX.url("/api/thermostat/info");
|
requestX.url("/api/thermostat/info");
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
emsesp::EMSESP::logger().notice("*");
|
EMSESP::logger().notice("*");
|
||||||
|
|
||||||
requestX.url("/api/thermostat/seltemp");
|
requestX.url("/api/thermostat/seltemp");
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
@@ -984,7 +984,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
/*
|
/*
|
||||||
requestX.url("/api/temperaturesensor/xxxx");
|
requestX.url("/api/temperaturesensor/xxxx");
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
emsesp::EMSESP::logger().notice("****");
|
EMSESP::logger().notice("****");
|
||||||
requestX.url("/api/temperaturesensor/info");
|
requestX.url("/api/temperaturesensor/info");
|
||||||
EMSESP::webAPIService.webAPIService_get(&requestX);
|
EMSESP::webAPIService.webAPIService_get(&requestX);
|
||||||
return;
|
return;
|
||||||
@@ -1160,7 +1160,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
request.url("/api");
|
request.url("/api");
|
||||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||||
|
|
||||||
emsesp::EMSESP::logger().warning("* these next ones should fail *");
|
EMSESP::logger().warning("* these next ones should fail *");
|
||||||
|
|
||||||
// write value from web - testing hc9/seltemp - should fail!
|
// write value from web - testing hc9/seltemp - should fail!
|
||||||
char data8[] = "{\"id\":2,\"devicevalue\":{\"v\":\"55\",\"u\":1,\"n\":\"hc2 selected room temperature\",\"c\":\"hc9/seltemp\"}";
|
char data8[] = "{\"id\":2,\"devicevalue\":{\"v\":\"55\",\"u\":1,\"n\":\"hc2 selected room temperature\",\"c\":\"hc9/seltemp\"}";
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ WebAPIService::WebAPIService(PsychicHttpServer * server, SecurityManager * secur
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebAPIService::registerURI() {
|
void WebAPIService::registerURI() {
|
||||||
// POST /{device}[/{hc|id}][/{name}]
|
// POST /api/{device}[/{hc|wwc|id}][/{name}]
|
||||||
// note: must explicity use 'Content-Type: application/json' in header
|
// note: must explicity use 'Content-Type: application/json' in header
|
||||||
_server->on(EMSESP_API_SERVICE_PATH, HTTP_POST, [this](PsychicRequest * request, JsonVariant & json) {
|
_server->on(EMSESP_API_SERVICE_PATH, HTTP_POST, [this](PsychicRequest * request, JsonVariant & json) {
|
||||||
// if no body then treat it as a secure GET
|
// if no json body then treat it as a secure GET
|
||||||
if (!json.is<JsonObject>()) {
|
if (!json.is<JsonObject>()) {
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
||||||
JsonObject input = input_doc.to<JsonObject>();
|
JsonObject input = input_doc.to<JsonObject>();
|
||||||
@@ -49,7 +49,15 @@ void WebAPIService::registerURI() {
|
|||||||
// GET /{device}/{entity}
|
// GET /{device}/{entity}
|
||||||
_server->on(EMSESP_API_SERVICE_PATH, HTTP_GET, [this](PsychicRequest * request) {
|
_server->on(EMSESP_API_SERVICE_PATH, HTTP_GET, [this](PsychicRequest * request) {
|
||||||
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
||||||
JsonObject input = input_doc.to<JsonObject>();
|
JsonObject input = input_doc.to<JsonObject>(); // empty input json
|
||||||
|
return parse(request, input);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// GET - for when using GET query parameters, the old style from v2
|
||||||
|
_server->on("/api", HTTP_GET, [this](PsychicRequest * request) {
|
||||||
|
StaticJsonDocument<EMSESP_JSON_SIZE_SMALL> input_doc;
|
||||||
|
JsonObject input = input_doc.to<JsonObject>(); // empty input json
|
||||||
return parse(request, input);
|
return parse(request, input);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -75,7 +83,13 @@ esp_err_t WebAPIService::parse(PsychicRequest * request, JsonObject & input) {
|
|||||||
// check for query parameters first, the old style from v2
|
// check for query parameters first, the old style from v2
|
||||||
// api?device={device}&cmd={name}&data={value}&id={hc}
|
// api?device={device}&cmd={name}&data={value}&id={hc}
|
||||||
// TODO check if this works, because we're using wildcard now for api/*
|
// TODO check if this works, because we're using wildcard now for api/*
|
||||||
if (request->url() == "/api") {
|
EMSESP::logger().info("API URL: %s", request->url().c_str()); // TODO remove
|
||||||
|
if (request->hasParam(F_(device))) {
|
||||||
|
input["device"] = request->getParam(F_(device))->value().c_str();
|
||||||
|
EMSESP::logger().info("API: have device"); // TODO remove
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (request->url() == "/api") {
|
||||||
// get the device
|
// get the device
|
||||||
if (request->hasParam(F_(device))) {
|
if (request->hasParam(F_(device))) {
|
||||||
input["device"] = request->getParam(F_(device))->value().c_str();
|
input["device"] = request->getParam(F_(device))->value().c_str();
|
||||||
@@ -98,10 +112,11 @@ esp_err_t WebAPIService::parse(PsychicRequest * request, JsonObject & input) {
|
|||||||
if (request->hasParam(F_(wwc))) {
|
if (request->hasParam(F_(wwc))) {
|
||||||
input["wwc"] = Helpers::atoint(request->getParam(F_(wwc))->value().c_str());
|
input["wwc"] = Helpers::atoint(request->getParam(F_(wwc))->value().c_str());
|
||||||
}
|
}
|
||||||
}
|
serializeJson(input, Serial); // TODO remove
|
||||||
|
// }
|
||||||
|
|
||||||
// capture current heap memory before allocating the large return buffer
|
// capture current heap memory before allocating the large return buffer
|
||||||
emsesp::EMSESP::system_.refreshHeapMem();
|
EMSESP::system_.refreshHeapMem();
|
||||||
|
|
||||||
// output json buffer
|
// output json buffer
|
||||||
size_t buffer = EMSESP_JSON_SIZE_XXXLARGE;
|
size_t buffer = EMSESP_JSON_SIZE_XXXLARGE;
|
||||||
@@ -129,7 +144,7 @@ esp_err_t WebAPIService::parse(PsychicRequest * request, JsonObject & input) {
|
|||||||
} else {
|
} else {
|
||||||
snprintf(error, sizeof(error), "API failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
snprintf(error, sizeof(error), "API failed with error code (%s)", Command::return_code_string(return_code).c_str());
|
||||||
}
|
}
|
||||||
emsesp::EMSESP::logger().err(error);
|
EMSESP::logger().err(error);
|
||||||
api_fails_++;
|
api_fails_++;
|
||||||
|
|
||||||
// FAIL, OK, NOT_FOUND, ERROR, NOT_ALLOWED = 400 (bad request), 200 (OK), 400 (not found), 400 (bad request), 401 (unauthorized)
|
// FAIL, OK, NOT_FOUND, ERROR, NOT_ALLOWED = 400 (bad request), 200 (OK), 400 (not found), 400 (bad request), 401 (unauthorized)
|
||||||
|
|||||||
@@ -431,9 +431,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);
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ esp_err_t WebCustomizationService::customization_entities(PsychicRequest * reque
|
|||||||
} else {
|
} else {
|
||||||
emsdevice->setCustomizationEntity(id_s);
|
emsdevice->setCustomizationEntity(id_s);
|
||||||
}
|
}
|
||||||
// emsesp::EMSESP::logger().info(id.as<const char *>());
|
// EMSESP::logger().info(id.as<const char *>());
|
||||||
}
|
}
|
||||||
// add deleted entities from file
|
// add deleted entities from file
|
||||||
read([&](WebCustomization & settings) {
|
read([&](WebCustomization & settings) {
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ esp_err_t WebDataService::device_data(PsychicRequest * request) {
|
|||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
if (emsdevice->unique_id() == id) {
|
if (emsdevice->unique_id() == id) {
|
||||||
// wait max 2.5 sec for updated data (post_send_delay is 2 sec)
|
// wait max 2.5 sec for updated data (post_send_delay is 2 sec)
|
||||||
for (uint16_t i = 0; i < (emsesp::TxService::POST_SEND_DELAY + 500) && EMSESP::wait_validate(); i++) {
|
for (uint16_t i = 0; i < (TxService::POST_SEND_DELAY + 500) && EMSESP::wait_validate(); i++) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
EMSESP::wait_validate(0); // reset in case of timeout
|
EMSESP::wait_validate(0); // reset in case of timeout
|
||||||
|
|||||||
@@ -292,9 +292,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);
|
||||||
@@ -356,7 +356,7 @@ bool WebSchedulerService::command(const char * cmd, const char * data) {
|
|||||||
} else {
|
} else {
|
||||||
snprintf(error, sizeof(error), "Scheduled command %s failed with error code (%s)", cmd, Command::return_code_string(return_code).c_str());
|
snprintf(error, sizeof(error), "Scheduled command %s failed with error code (%s)", cmd, Command::return_code_string(return_code).c_str());
|
||||||
}
|
}
|
||||||
emsesp::EMSESP::logger().err(error);
|
EMSESP::logger().err(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ void WebSettingsService::onUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WebSettings::has_flags(WebSettings::ChangeFlags::MQTT)) {
|
if (WebSettings::has_flags(WebSettings::ChangeFlags::MQTT)) {
|
||||||
emsesp::Mqtt::reset_mqtt(); // reload MQTT, init HA etc
|
Mqtt::reset_mqtt(); // reload MQTT, init HA etc
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSettings::reset_flags();
|
WebSettings::reset_flags();
|
||||||
|
|||||||
Reference in New Issue
Block a user