Fix constants; reduce logging spam

This commit is contained in:
clydebarrow
2026-01-23 16:51:52 +11:00
parent 8abb783b64
commit 081081f69a
3 changed files with 12 additions and 15 deletions
+3 -3
View File
@@ -132,21 +132,21 @@ _COVER_SCHEMA = (
cv.Optional(CONF_ON_OPEN): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
CoverPositionTrigger.template(1.0)
CoverPositionTrigger.template(COVER_OPEN)
),
}
),
cv.Optional(CONF_ON_OPENED): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
CoverPositionTrigger.template(1.0)
CoverPositionTrigger.template(COVER_OPEN)
),
}
),
cv.Optional(CONF_ON_CLOSED): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
CoverPositionTrigger.template(0.0)
CoverPositionTrigger.template(COVER_CLOSED)
),
}
),
+7 -10
View File
@@ -10,9 +10,6 @@ namespace esphome::cover {
static const char *const TAG = "cover";
const float COVER_OPEN = 1.0f;
const float COVER_CLOSED = 0.0f;
const LogString *cover_command_to_str(float pos) {
if (pos == COVER_OPEN) {
return LOG_STR("OPEN");
@@ -153,23 +150,23 @@ void Cover::publish_state(bool save) {
this->position = clamp(this->position, 0.0f, 1.0f);
this->tilt = clamp(this->tilt, 0.0f, 1.0f);
ESP_LOGD(TAG, "'%s' >>", this->name_.c_str());
ESP_LOGV(TAG, "'%s' >>", this->name_.c_str());
auto traits = this->get_traits();
if (traits.get_supports_position()) {
ESP_LOGD(TAG, " Position: %.0f%%", this->position * 100.0f);
ESP_LOGV(TAG, " Position: %.0f%%", this->position * 100.0f);
} else {
if (this->position == COVER_OPEN) {
ESP_LOGD(TAG, " State: OPEN");
ESP_LOGV(TAG, " State: OPEN");
} else if (this->position == COVER_CLOSED) {
ESP_LOGD(TAG, " State: CLOSED");
ESP_LOGV(TAG, " State: CLOSED");
} else {
ESP_LOGD(TAG, " State: UNKNOWN");
ESP_LOGV(TAG, " State: UNKNOWN");
}
}
if (traits.get_supports_tilt()) {
ESP_LOGD(TAG, " Tilt: %.0f%%", this->tilt * 100.0f);
ESP_LOGV(TAG, " Tilt: %.0f%%", this->tilt * 100.0f);
}
ESP_LOGD(TAG, " Current Operation: %s", LOG_STR_ARG(cover_operation_to_str(this->current_operation)));
ESP_LOGV(TAG, " Current Operation: %s", LOG_STR_ARG(cover_operation_to_str(this->current_operation)));
this->state_callback_.call();
#if defined(USE_COVER) && defined(USE_CONTROLLER_REGISTRY)
+2 -2
View File
@@ -10,8 +10,8 @@
namespace esphome::cover {
const extern float COVER_OPEN;
const extern float COVER_CLOSED;
static constexpr const float COVER_OPEN = 1.0f;
static constexpr const float COVER_CLOSED = 0.0f;
#define LOG_COVER(prefix, type, obj) \
if ((obj) != nullptr) { \