diff --git a/components/app_status/README.md b/components/app_status/README.md index de0e7bf..79935e3 100644 --- a/components/app_status/README.md +++ b/components/app_status/README.md @@ -23,5 +23,6 @@ binary_sensor: detect_status: - warning - error - inverted: true + filters: + - invert: ``` diff --git a/components/app_status/app_status.cpp b/components/app_status/app_status.cpp index be9db1c..eb2222c 100644 --- a/components/app_status/app_status.cpp +++ b/components/app_status/app_status.cpp @@ -12,7 +12,7 @@ void AppStatus::setup() { } void AppStatus::update() { - ESP_LOGV(TAG, "update() called; inverted = %s", TRUEFALSE(this->inverted_)); + 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)) { @@ -21,15 +21,11 @@ void AppStatus::update() { if (this->include_warnings_ && (app_state & STATUS_LED_WARNING)) { result = true; } - if (this->inverted_) { - result = !result; - } this->publish_state(result); } void AppStatus::dump_config() { ESP_LOGCONFIG(TAG, "App status binary sensor"); - ESP_LOGCONFIG(TAG, " inverted = %s", TRUEFALSE(this->inverted_)); ESP_LOGCONFIG(TAG, " include warnings = %s", TRUEFALSE(this->include_warnings_)); ESP_LOGCONFIG(TAG, " include errors = %s", TRUEFALSE(this->include_errors_)); } diff --git a/components/app_status/app_status.h b/components/app_status/app_status.h index 098bc87..86f0c98 100644 --- a/components/app_status/app_status.h +++ b/components/app_status/app_status.h @@ -15,13 +15,11 @@ class AppStatus : public binary_sensor::BinarySensor, public PollingComponent { //float get_loop_priority() const override { return 50.0f; } - void set_inverted(bool value) { this->inverted_ = value; } void set_include_errors(bool allow) { this->include_errors_ = allow; } void set_include_warnings(bool allow) { this->include_warnings_ = allow; } protected: //uint8_t last_app_state_(0xFF); - bool inverted_{false}; bool include_warnings_{true}; bool include_errors_{true}; }; diff --git a/components/app_status/binary_sensor.py b/components/app_status/binary_sensor.py index 543075f..44f4fc0 100644 --- a/components/app_status/binary_sensor.py +++ b/components/app_status/binary_sensor.py @@ -3,7 +3,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import CONF_ID, CONF_INVERTED +from esphome.const import CONF_ID CONF_DETECT_STATUS = "detect_status" CONF_WARNING = "warning" @@ -21,12 +21,10 @@ AppStatus = app_status_ns.class_("AppStatus", binary_sensor.BinarySensor, cg.Pol CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(AppStatus).extend({ cv.GenerateID(): cv.declare_id(AppStatus), cv.Optional(CONF_DETECT_STATUS, default=[CONF_WARNING, CONF_ERROR]): cv.ensure_list(cv.enum(DETECT_STATUS_ENUM)), - cv.Optional(CONF_INVERTED, default=False): cv.boolean, }).extend(cv.polling_component_schema(default_update_interval="1s")) async def to_code(config): var = await binary_sensor.new_binary_sensor(config) await cg.register_component(var, config) - cg.add(var.set_inverted(config[CONF_INVERTED])) cg.add(var.set_include_warnings(CONF_WARNING in config[CONF_DETECT_STATUS])) cg.add(var.set_include_errors(CONF_ERROR in config[CONF_DETECT_STATUS]))