mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
Fix constants; reduce logging spam
This commit is contained in:
@@ -132,21 +132,21 @@ _COVER_SCHEMA = (
|
|||||||
cv.Optional(CONF_ON_OPEN): automation.validate_automation(
|
cv.Optional(CONF_ON_OPEN): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
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.Optional(CONF_ON_OPENED): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
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.Optional(CONF_ON_CLOSED): automation.validate_automation(
|
||||||
{
|
{
|
||||||
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
|
||||||
CoverPositionTrigger.template(0.0)
|
CoverPositionTrigger.template(COVER_CLOSED)
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ namespace esphome::cover {
|
|||||||
|
|
||||||
static const char *const TAG = "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) {
|
const LogString *cover_command_to_str(float pos) {
|
||||||
if (pos == COVER_OPEN) {
|
if (pos == COVER_OPEN) {
|
||||||
return LOG_STR("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->position = clamp(this->position, 0.0f, 1.0f);
|
||||||
this->tilt = clamp(this->tilt, 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();
|
auto traits = this->get_traits();
|
||||||
if (traits.get_supports_position()) {
|
if (traits.get_supports_position()) {
|
||||||
ESP_LOGD(TAG, " Position: %.0f%%", this->position * 100.0f);
|
ESP_LOGV(TAG, " Position: %.0f%%", this->position * 100.0f);
|
||||||
} else {
|
} else {
|
||||||
if (this->position == COVER_OPEN) {
|
if (this->position == COVER_OPEN) {
|
||||||
ESP_LOGD(TAG, " State: OPEN");
|
ESP_LOGV(TAG, " State: OPEN");
|
||||||
} else if (this->position == COVER_CLOSED) {
|
} else if (this->position == COVER_CLOSED) {
|
||||||
ESP_LOGD(TAG, " State: CLOSED");
|
ESP_LOGV(TAG, " State: CLOSED");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, " State: UNKNOWN");
|
ESP_LOGV(TAG, " State: UNKNOWN");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (traits.get_supports_tilt()) {
|
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();
|
this->state_callback_.call();
|
||||||
#if defined(USE_COVER) && defined(USE_CONTROLLER_REGISTRY)
|
#if defined(USE_COVER) && defined(USE_CONTROLLER_REGISTRY)
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
namespace esphome::cover {
|
namespace esphome::cover {
|
||||||
|
|
||||||
const extern float COVER_OPEN;
|
static constexpr const float COVER_OPEN = 1.0f;
|
||||||
const extern float COVER_CLOSED;
|
static constexpr const float COVER_CLOSED = 0.0f;
|
||||||
|
|
||||||
#define LOG_COVER(prefix, type, obj) \
|
#define LOG_COVER(prefix, type, obj) \
|
||||||
if ((obj) != nullptr) { \
|
if ((obj) != nullptr) { \
|
||||||
|
|||||||
Reference in New Issue
Block a user