mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
fix ignore entity, add weblog level OFF
This commit is contained in:
@@ -210,6 +210,7 @@ const SystemLog: FC = () => {
|
||||
margin="normal"
|
||||
select
|
||||
>
|
||||
<MenuItem value={-1}>OFF</MenuItem>
|
||||
<MenuItem value={3}>ERROR</MenuItem>
|
||||
<MenuItem value={4}>WARNING</MenuItem>
|
||||
<MenuItem value={5}>NOTICE</MenuItem>
|
||||
|
||||
@@ -493,6 +493,7 @@ void EMSdevice::add_device_value(uint8_t tag,
|
||||
std::string custom_fullname = std::string(""); // custom fullname
|
||||
auto short_name = name[0]; // entity name
|
||||
bool has_cmd = (f != nullptr); // is it a command?
|
||||
bool ignore = false; // ignore this entity?
|
||||
|
||||
// get fullname, getting translation if it exists
|
||||
const char * const * fullname;
|
||||
@@ -523,10 +524,8 @@ void EMSdevice::add_device_value(uint8_t tag,
|
||||
if (shortname == entity) {
|
||||
// get Mask
|
||||
uint8_t mask = Helpers::hextoint(entity_id.substr(0, 2).c_str());
|
||||
state = mask << 4; // set state high bits to flag, turn off active and ha flags
|
||||
if (mask & 0x80) {
|
||||
return;
|
||||
}
|
||||
state = mask << 4; // set state high bits to flag, turn off active and ha flags
|
||||
ignore = (mask & 0x80) == 0x80; // do not register
|
||||
// see if there is a custom name in the entity string
|
||||
if (has_custom_name) {
|
||||
custom_fullname = entity_id.substr(custom_name_pos + 1);
|
||||
@@ -537,6 +536,9 @@ void EMSdevice::add_device_value(uint8_t tag,
|
||||
}
|
||||
}
|
||||
});
|
||||
if (ignore) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add the device entity
|
||||
devicevalues_.emplace_back(
|
||||
|
||||
@@ -57,6 +57,9 @@ void WebLogService::start() {
|
||||
limit_log_messages_ = maximum_log_messages_;
|
||||
compact_ = settings.weblog_compact;
|
||||
uuid::log::Logger::register_handler(this, (uuid::log::Level)settings.weblog_level);
|
||||
if ((uuid::log::Level)settings.weblog_level == uuid::log::Level::OFF) {
|
||||
log_messages_.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -72,6 +75,9 @@ void WebLogService::log_level(uuid::log::Level level) {
|
||||
},
|
||||
"local");
|
||||
uuid::log::Logger::register_handler(this, level);
|
||||
if (level == uuid::log::Level::OFF) {
|
||||
log_messages_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
size_t WebLogService::num_log_messages() const {
|
||||
@@ -214,8 +220,8 @@ void WebLogService::fetchLog(AsyncWebServerRequest * request) {
|
||||
buffer -= 1024;
|
||||
response = new MsgpackAsyncJsonResponse(false, buffer);
|
||||
}
|
||||
JsonObject root = response->getRoot();
|
||||
JsonArray log = root.createNestedArray("events");
|
||||
JsonObject root = response->getRoot();
|
||||
JsonArray log = root.createNestedArray("events");
|
||||
|
||||
log_message_id_tail_ = log_messages_.back().id_;
|
||||
last_transmit_ = uuid::get_uptime_ms();
|
||||
|
||||
Reference in New Issue
Block a user