Skip to content

Commit

Permalink
fix ignore entity, add weblog level OFF
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Jan 6, 2023
1 parent 7bb3581 commit d0aac18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions interface/src/framework/system/SystemLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
10 changes: 6 additions & 4 deletions src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -537,6 +536,9 @@ void EMSdevice::add_device_value(uint8_t tag,
}
}
});
if (ignore) {
return;
}

// add the device entity
devicevalues_.emplace_back(
Expand Down
10 changes: 8 additions & 2 deletions src/web/WebLogService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit d0aac18

Please sign in to comment.