Files
esphome-rgb-status-leds/components/app_status/app_status.cpp

37 lines
925 B
C++

#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "app_status.h"
namespace esphome {
namespace app_status {
static const char *TAG = "app_status.binary_sensor";
void AppStatus::setup() {
}
void AppStatus::update() {
ESP_LOGV(TAG, "update() called", TRUEFALSE(this->inverted_));
bool result = false;
auto app_state = App.get_app_state() & STATUS_LED_MASK;
if (this->include_errors_ && (app_state & STATUS_LED_ERROR)) {
result = true;
}
if (this->include_warnings_ && (app_state & STATUS_LED_WARNING)) {
result = true;
}
this->publish_state(result);
}
void AppStatus::dump_config() {
ESP_LOGCONFIG(TAG, "App status binary sensor");
ESP_LOGCONFIG(TAG, " include warnings = %s", TRUEFALSE(this->include_warnings_));
ESP_LOGCONFIG(TAG, " include errors = %s", TRUEFALSE(this->include_errors_));
}
} // namespace app_status
} // namespace esphome
// vim:set sw=2: