mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
replace lambda [&] with [this]
This commit is contained in:
@@ -65,7 +65,7 @@ ESP8266React::ESP8266React(AsyncWebServer * server, FS * fs)
|
|||||||
|
|
||||||
void ESP8266React::begin() {
|
void ESP8266React::begin() {
|
||||||
_networkSettingsService.begin();
|
_networkSettingsService.begin();
|
||||||
_networkSettingsService.read([&](NetworkSettings & networkSettings) {
|
_networkSettingsService.read([this](NetworkSettings & networkSettings) {
|
||||||
DefaultHeaders & defaultHeaders = DefaultHeaders::Instance();
|
DefaultHeaders & defaultHeaders = DefaultHeaders::Instance();
|
||||||
if (networkSettings.enableCORS) {
|
if (networkSettings.enableCORS) {
|
||||||
defaultHeaders.addHeader("Access-Control-Allow-Origin", networkSettings.CORSOrigin);
|
defaultHeaders.addHeader("Access-Control-Allow-Origin", networkSettings.CORSOrigin);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class FSPersistence {
|
|||||||
|
|
||||||
void enableUpdateHandler() {
|
void enableUpdateHandler() {
|
||||||
if (!_updateHandlerId) {
|
if (!_updateHandlerId) {
|
||||||
_updateHandlerId = _statefulService->addUpdateHandler([&]() { writeToFS(); });
|
_updateHandlerId = _statefulService->addUpdateHandler([this] { writeToFS(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void AnalogSensor::start() {
|
|||||||
Command::add(
|
Command::add(
|
||||||
EMSdevice::DeviceType::ANALOGSENSOR,
|
EMSdevice::DeviceType::ANALOGSENSOR,
|
||||||
F_(setvalue),
|
F_(setvalue),
|
||||||
[&](const char * value, const int8_t id) { return command_setvalue(value, id); },
|
[this](const char * value, const int8_t id) { return command_setvalue(value, id); },
|
||||||
FL_(setiovalue_cmd),
|
FL_(setiovalue_cmd),
|
||||||
CommandFlag::ADMIN_ONLY);
|
CommandFlag::ADMIN_ONLY);
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ void AnalogSensor::start() {
|
|||||||
|
|
||||||
// load settings from the customization file, sorts them and initializes the GPIOs
|
// load settings from the customization file, sorts them and initializes the GPIOs
|
||||||
void AnalogSensor::reload() {
|
void AnalogSensor::reload() {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) { analog_enabled_ = settings.analog_enabled; });
|
EMSESP::webSettingsService.read([this](WebSettings & settings) { analog_enabled_ = settings.analog_enabled; });
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE)
|
#if defined(EMSESP_STANDALONE)
|
||||||
analog_enabled_ = true; // for local offline testing
|
analog_enabled_ = true; // for local offline testing
|
||||||
@@ -63,7 +63,7 @@ void AnalogSensor::reload() {
|
|||||||
}
|
}
|
||||||
// load the list of analog sensors from the customization service
|
// load the list of analog sensors from the customization service
|
||||||
// and store them locally and then activate them
|
// and store them locally and then activate them
|
||||||
EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
|
EMSESP::webCustomizationService.read([this](WebCustomization & settings) {
|
||||||
auto it = sensors_.begin();
|
auto it = sensors_.begin();
|
||||||
for (auto & sensor_ : sensors_) {
|
for (auto & sensor_ : sensors_) {
|
||||||
// update existing sensors
|
// update existing sensors
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ void EMSESPShell::display_banner() {
|
|||||||
println();
|
println();
|
||||||
|
|
||||||
// set console name
|
// set console name
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { console_hostname_ = networkSettings.hostname.c_str(); });
|
EMSESP::esp8266React.getNetworkSettingsService()->read([this](NetworkSettings & networkSettings) { console_hostname_ = networkSettings.hostname.c_str(); });
|
||||||
if (console_hostname_.empty()) {
|
if (console_hostname_.empty()) {
|
||||||
console_hostname_ = "ems-esp";
|
console_hostname_ = "ems-esp";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1118,7 +1118,7 @@ void Boiler::check_active() {
|
|||||||
|
|
||||||
// check forceheatingoff option
|
// check forceheatingoff option
|
||||||
if (!Helpers::hasValue(forceHeatingOff_, EMS_VALUE_BOOL)) {
|
if (!Helpers::hasValue(forceHeatingOff_, EMS_VALUE_BOOL)) {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) { forceHeatingOff_ = settings.boiler_heatingoff ? EMS_VALUE_BOOL_ON : 0; });
|
EMSESP::webSettingsService.read([this](WebSettings & settings) { forceHeatingOff_ = settings.boiler_heatingoff ? EMS_VALUE_BOOL_ON : 0; });
|
||||||
has_update(&forceHeatingOff_);
|
has_update(&forceHeatingOff_);
|
||||||
}
|
}
|
||||||
static uint32_t lastSendHeatingOff = 0;
|
static uint32_t lastSendHeatingOff = 0;
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ void Solar::process_SM10Monitor(std::shared_ptr<const Telegram> telegram) {
|
|||||||
has_update(solarPumpMod_, solarpumpmod);
|
has_update(solarPumpMod_, solarpumpmod);
|
||||||
|
|
||||||
if (!Helpers::hasValue(maxFlow_)) {
|
if (!Helpers::hasValue(maxFlow_)) {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) { maxFlow_ = settings.solar_maxflow; });
|
EMSESP::webSettingsService.read([this](WebSettings & settings) { maxFlow_ = settings.solar_maxflow; });
|
||||||
has_update(&maxFlow_);
|
has_update(&maxFlow_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1047,7 +1047,7 @@ bool Solar::set_SM10MaxFlow(const char * value, const int8_t id) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
maxFlow_ = (flow * 10);
|
maxFlow_ = (flow * 10);
|
||||||
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
EMSESP::webSettingsService.update([this](WebSettings & settings) {
|
||||||
settings.solar_maxflow = maxFlow_;
|
settings.solar_maxflow = maxFlow_;
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -195,9 +195,9 @@ void Mqtt::show_mqtt(uuid::console::Shell & shell) {
|
|||||||
for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
|
for (const auto & mqtt_subfunction : mqtt_subfunctions_) {
|
||||||
shell.printfln(" %s/%s", Mqtt::base().c_str(), mqtt_subfunction.topic_.c_str());
|
shell.printfln(" %s/%s", Mqtt::base().c_str(), mqtt_subfunction.topic_.c_str());
|
||||||
}
|
}
|
||||||
shell.println();
|
|
||||||
|
|
||||||
shell.println();
|
shell.println();
|
||||||
|
shell.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EMSESP_TEST)
|
#if defined(EMSESP_TEST)
|
||||||
@@ -451,6 +451,7 @@ void Mqtt::on_disconnect(espMqttClientTypes::DisconnectReason reason) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connecting_ = false;
|
connecting_ = false;
|
||||||
|
|
||||||
if (reason == espMqttClientTypes::DisconnectReason::TCP_DISCONNECTED) {
|
if (reason == espMqttClientTypes::DisconnectReason::TCP_DISCONNECTED) {
|
||||||
LOG_WARNING("MQTT disconnected: TCP");
|
LOG_WARNING("MQTT disconnected: TCP");
|
||||||
} else if (reason == espMqttClientTypes::DisconnectReason::MQTT_UNACCEPTABLE_PROTOCOL_VERSION) {
|
} else if (reason == espMqttClientTypes::DisconnectReason::MQTT_UNACCEPTABLE_PROTOCOL_VERSION) {
|
||||||
@@ -468,6 +469,7 @@ void Mqtt::on_disconnect(espMqttClientTypes::DisconnectReason reason) {
|
|||||||
} else {
|
} else {
|
||||||
LOG_WARNING("MQTT disconnected: code %d", reason);
|
LOG_WARNING("MQTT disconnected: code %d", reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
mqttClient_->clearQueue(true);
|
mqttClient_->clearQueue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ uuid::log::Logger Shower::logger_{F_(shower), uuid::log::Facility::CONSOLE};
|
|||||||
static bool force_coldshot = false;
|
static bool force_coldshot = false;
|
||||||
|
|
||||||
void Shower::start() {
|
void Shower::start() {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([this](WebSettings & settings) {
|
||||||
shower_timer_ = settings.shower_timer;
|
shower_timer_ = settings.shower_timer;
|
||||||
shower_alert_ = settings.shower_alert;
|
shower_alert_ = settings.shower_alert;
|
||||||
shower_alert_trigger_ = settings.shower_alert_trigger * 60000; // convert from minutes
|
shower_alert_trigger_ = settings.shower_alert_trigger * 60000; // convert from minutes
|
||||||
@@ -35,7 +35,7 @@ void Shower::start() {
|
|||||||
Command::add(
|
Command::add(
|
||||||
EMSdevice::DeviceType::BOILER,
|
EMSdevice::DeviceType::BOILER,
|
||||||
F_(coldshot),
|
F_(coldshot),
|
||||||
[&](const char * value, const int8_t id, JsonObject output) {
|
[this](const char * value, const int8_t id, JsonObject output) {
|
||||||
LOG_INFO("Forcing coldshot...");
|
LOG_INFO("Forcing coldshot...");
|
||||||
if (shower_state_) {
|
if (shower_state_) {
|
||||||
output["message"] = "OK";
|
output["message"] = "OK";
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ bool System::command_syslog_level(const char * value, const int8_t id) {
|
|||||||
if (Helpers::value2enum(value, s, FL_(list_syslog_level))) {
|
if (Helpers::value2enum(value, s, FL_(list_syslog_level))) {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
EMSESP::webSettingsService.update(
|
EMSESP::webSettingsService.update(
|
||||||
[&](WebSettings & settings) {
|
[this](WebSettings & settings) {
|
||||||
if (settings.syslog_level != (int8_t)s - 1) {
|
if (settings.syslog_level != (int8_t)s - 1) {
|
||||||
settings.syslog_level = (int8_t)s - 1;
|
settings.syslog_level = (int8_t)s - 1;
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -295,7 +295,7 @@ void System::format(uuid::console::Shell & shell) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void System::syslog_init() {
|
void System::syslog_init() {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([this](WebSettings & settings) {
|
||||||
syslog_enabled_ = settings.syslog_enabled;
|
syslog_enabled_ = settings.syslog_enabled;
|
||||||
syslog_level_ = settings.syslog_level;
|
syslog_level_ = settings.syslog_level;
|
||||||
syslog_mark_interval_ = settings.syslog_mark_interval;
|
syslog_mark_interval_ = settings.syslog_mark_interval;
|
||||||
@@ -349,7 +349,7 @@ void System::syslog_init() {
|
|||||||
|
|
||||||
// read some specific system settings to store locally for faster access
|
// read some specific system settings to store locally for faster access
|
||||||
void System::reload_settings() {
|
void System::reload_settings() {
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([this](WebSettings & settings) {
|
||||||
version_ = settings.version;
|
version_ = settings.version;
|
||||||
|
|
||||||
pbutton_gpio_ = settings.pbutton_gpio;
|
pbutton_gpio_ = settings.pbutton_gpio;
|
||||||
@@ -427,7 +427,7 @@ void System::start() {
|
|||||||
refreshHeapMem(); // refresh free heap and max alloc heap
|
refreshHeapMem(); // refresh free heap and max alloc heap
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
EMSESP::esp8266React.getNetworkSettingsService()->read([this](NetworkSettings & networkSettings) {
|
||||||
hostname(networkSettings.hostname.c_str()); // sets the hostname
|
hostname(networkSettings.hostname.c_str()); // sets the hostname
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1080,15 +1080,13 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
|
|
||||||
version::Semver200_version settings_version(settingsVersion);
|
version::Semver200_version settings_version(settingsVersion);
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
|
||||||
if (!missing_version) {
|
if (!missing_version) {
|
||||||
LOG_INFO("Checking version (settings file is v%d.%d.%d-%s)...",
|
LOG_DEBUG("Checking version upgrade (settings file is v%d.%d.%d-%s)",
|
||||||
settings_version.major(),
|
settings_version.major(),
|
||||||
settings_version.minor(),
|
settings_version.minor(),
|
||||||
settings_version.patch(),
|
settings_version.patch(),
|
||||||
settings_version.prerelease().c_str());
|
settings_version.prerelease().c_str());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (factory_settings) {
|
if (factory_settings) {
|
||||||
return false; // fresh install, do nothing
|
return false; // fresh install, do nothing
|
||||||
@@ -1106,14 +1104,14 @@ bool System::check_upgrade(bool factory_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 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_INFO("Setting MQTT Entity ID format to v3.4 format");
|
LOG_INFO("Setting MQTT Entity ID format to v3.4 format");
|
||||||
EMSESP::esp8266React.getMqttSettingsService()->update([&](MqttSettings & mqttSettings) {
|
EMSESP::esp8266React.getMqttSettingsService()->update([this](MqttSettings & mqttSettings) {
|
||||||
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
|
mqttSettings.entity_format = 0; // use old Entity ID format from v3.4
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network Settings Wifi tx_power is now using the value * 4.
|
// Network Settings Wifi tx_power is now using the value * 4.
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->update([&](NetworkSettings & networkSettings) {
|
EMSESP::esp8266React.getNetworkSettingsService()->update([this](NetworkSettings & networkSettings) {
|
||||||
if (networkSettings.tx_power == 20) {
|
if (networkSettings.tx_power == 20) {
|
||||||
networkSettings.tx_power = WIFI_POWER_19_5dBm; // use 19.5 as we don't have 20 anymore
|
networkSettings.tx_power = WIFI_POWER_19_5dBm; // use 19.5 as we don't have 20 anymore
|
||||||
LOG_INFO("Setting WiFi TX Power to Auto");
|
LOG_INFO("Setting WiFi TX Power to Auto");
|
||||||
@@ -1132,7 +1130,7 @@ bool System::check_upgrade(bool factory_settings) {
|
|||||||
|
|
||||||
// if we did a change, set the new version and reboot
|
// if we did a change, set the new version and reboot
|
||||||
if (save_version) {
|
if (save_version) {
|
||||||
EMSESP::webSettingsService.update([&](WebSettings & settings) {
|
EMSESP::webSettingsService.update([this](WebSettings & settings) {
|
||||||
settings.version = EMSESP_APP_VERSION;
|
settings.version = EMSESP_APP_VERSION;
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ void RxService::add_empty(const uint8_t src, const uint8_t dest, const uint16_t
|
|||||||
// send out request to EMS bus for all devices
|
// send out request to EMS bus for all devices
|
||||||
void TxService::start() {
|
void TxService::start() {
|
||||||
// grab the bus ID and tx_mode
|
// grab the bus ID and tx_mode
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([this](WebSettings & settings) {
|
||||||
ems_bus_id(settings.ems_bus_id);
|
ems_bus_id(settings.ems_bus_id);
|
||||||
tx_mode(settings.tx_mode);
|
tx_mode(settings.tx_mode);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void TemperatureSensor::start() {
|
|||||||
// load settings
|
// load settings
|
||||||
void TemperatureSensor::reload() {
|
void TemperatureSensor::reload() {
|
||||||
// load the service settings
|
// load the service settings
|
||||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
EMSESP::webSettingsService.read([this](WebSettings & settings) {
|
||||||
dallas_gpio_ = settings.dallas_gpio;
|
dallas_gpio_ = settings.dallas_gpio;
|
||||||
parasite_ = settings.dallas_parasite;
|
parasite_ = settings.dallas_parasite;
|
||||||
});
|
});
|
||||||
@@ -604,7 +604,7 @@ std::string TemperatureSensor::Sensor::name() const {
|
|||||||
// look up in customization service for a specific sensor
|
// look up in customization service for a specific sensor
|
||||||
// and set the name and offset from that entry if it exists
|
// and set the name and offset from that entry if it exists
|
||||||
bool TemperatureSensor::Sensor::apply_customization() {
|
bool TemperatureSensor::Sensor::apply_customization() {
|
||||||
EMSESP::webCustomizationService.read([&](WebCustomization & settings) {
|
EMSESP::webCustomizationService.read([this](WebCustomization & settings) {
|
||||||
auto sensors = settings.sensorCustomizations;
|
auto sensors = settings.sensorCustomizations;
|
||||||
if (!sensors.empty()) {
|
if (!sensors.empty()) {
|
||||||
for (const auto & sensor : sensors) {
|
for (const auto & sensor : sensors) {
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ StateUpdateResult WebCustomEntity::update(JsonObject root, WebCustomEntity & web
|
|||||||
|
|
||||||
// set value by api command
|
// set value by api command
|
||||||
bool WebCustomEntityService::command_setvalue(const char * value, const std::string name) {
|
bool WebCustomEntityService::command_setvalue(const char * value, const std::string name) {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
for (CustomEntityItem & entityItem : *customEntityItems) {
|
for (CustomEntityItem & entityItem : *customEntityItems) {
|
||||||
if (Helpers::toLower(entityItem.name) == Helpers::toLower(name)) {
|
if (Helpers::toLower(entityItem.name) == Helpers::toLower(name)) {
|
||||||
if (entityItem.ram == 1) {
|
if (entityItem.ram == 1) {
|
||||||
@@ -251,7 +251,7 @@ void WebCustomEntityService::show_values(JsonObject output) {
|
|||||||
|
|
||||||
// process json output for info/commands and value_info
|
// process json output for info/commands and value_info
|
||||||
bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd) {
|
bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd) {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
|
|
||||||
// if it's commands...
|
// if it's commands...
|
||||||
if (Helpers::toLower(cmd) == F_(commands)) {
|
if (Helpers::toLower(cmd) == F_(commands)) {
|
||||||
@@ -365,7 +365,7 @@ void WebCustomEntityService::publish(const bool force) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
if (customEntityItems->size() == 0) {
|
if (customEntityItems->size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -456,7 +456,7 @@ void WebCustomEntityService::publish(const bool force) {
|
|||||||
|
|
||||||
// count only entities with valid value or command to show in dashboard
|
// count only entities with valid value or command to show in dashboard
|
||||||
uint8_t WebCustomEntityService::count_entities() {
|
uint8_t WebCustomEntityService::count_entities() {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
if (customEntityItems->size() == 0) {
|
if (customEntityItems->size() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -473,7 +473,7 @@ uint8_t WebCustomEntityService::count_entities() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t WebCustomEntityService::has_commands() {
|
uint8_t WebCustomEntityService::has_commands() {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
uint8_t count = 0;
|
uint8_t count = 0;
|
||||||
for (const CustomEntityItem & entity : *customEntityItems) {
|
for (const CustomEntityItem & entity : *customEntityItems) {
|
||||||
count += entity.writeable ? 1 : 0;
|
count += entity.writeable ? 1 : 0;
|
||||||
@@ -484,7 +484,7 @@ 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) {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
|
|
||||||
output["label"] = (std::string) "Custom Entities";
|
output["label"] = (std::string) "Custom Entities";
|
||||||
JsonArray data = output["data"].to<JsonArray>();
|
JsonArray data = output["data"].to<JsonArray>();
|
||||||
@@ -556,7 +556,7 @@ void WebCustomEntityService::generate_value_web(JsonObject output) {
|
|||||||
|
|
||||||
// fetch telegram, called from emsesp::fetch
|
// fetch telegram, called from emsesp::fetch
|
||||||
void WebCustomEntityService::fetch() {
|
void WebCustomEntityService::fetch() {
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
const uint8_t len[] = {1, 1, 1, 2, 2, 3, 3};
|
const uint8_t len[] = {1, 1, 1, 2, 2, 3, 3};
|
||||||
|
|
||||||
for (auto & entity : *customEntityItems) {
|
for (auto & entity : *customEntityItems) {
|
||||||
@@ -582,7 +582,7 @@ void WebCustomEntityService::fetch() {
|
|||||||
// called on process telegram, read from telegram
|
// called on process telegram, read from telegram
|
||||||
bool WebCustomEntityService::get_value(std::shared_ptr<const Telegram> telegram) {
|
bool WebCustomEntityService::get_value(std::shared_ptr<const Telegram> telegram) {
|
||||||
bool has_change = false;
|
bool has_change = false;
|
||||||
EMSESP::webCustomEntityService.read([&](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
EMSESP::webCustomEntityService.read([this](WebCustomEntity & webEntity) { customEntityItems = &webEntity.customEntityItems; });
|
||||||
// read-length of BOOL, INT, UINT, SHORT, USHORT, ULONG, TIME
|
// read-length of BOOL, INT, UINT, SHORT, USHORT, ULONG, TIME
|
||||||
const uint8_t len[] = {1, 1, 1, 2, 2, 3, 3};
|
const uint8_t len[] = {1, 1, 1, 2, 2, 3, 3};
|
||||||
for (auto & entity : *customEntityItems) {
|
for (auto & entity : *customEntityItems) {
|
||||||
@@ -626,7 +626,7 @@ bool WebCustomEntityService::get_value(std::shared_ptr<const Telegram> telegram)
|
|||||||
// hard coded tests
|
// hard coded tests
|
||||||
#ifdef EMSESP_TEST
|
#ifdef EMSESP_TEST
|
||||||
void WebCustomEntityService::test() {
|
void WebCustomEntityService::test() {
|
||||||
update([&](WebCustomEntity & webCustomEntity) {
|
update([this](WebCustomEntity & webCustomEntity) {
|
||||||
webCustomEntity.customEntityItems.clear();
|
webCustomEntity.customEntityItems.clear();
|
||||||
// test 1
|
// test 1
|
||||||
auto entityItem = CustomEntityItem();
|
auto entityItem = CustomEntityItem();
|
||||||
|
|||||||
Reference in New Issue
Block a user