From: David Woodhouse Date: Tue, 11 Feb 2025 19:23:21 +0000 (+0000) Subject: Report opening/closing/idle X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=91782315611a92d2b17ffbc6cb6213548973c52f;p=users%2Fdwmw2%2Fesp32-pool.git Report opening/closing/idle --- diff --git a/blind.yaml b/blind.yaml index 5671c77..6236e37 100644 --- a/blind.yaml +++ b/blind.yaml @@ -246,7 +246,6 @@ sensor: internal: true update_interval: 0ms filters: - - delta: 2 # throttle the high polling rate to only act on value changes # compute absolute position from angle value - lambda: | const uint16_t curr = x; @@ -255,14 +254,30 @@ sensor: delta -= 4096; else if (delta < -2047) delta += 4096; - ESP_LOGD("angle", "Old %d new %d delta %d now %d home %d", id(encoder_tracking_)[0], curr, delta, - id(encoder_tracking_)[1] + delta, id(sensored_home_pos) ); + if (delta == 0 && id(pd_blinds)->current_operation != COVER_OPERATION_IDLE) { + id(pd_blinds)->current_operation = COVER_OPERATION_IDLE; + id(pd_blinds)->publish_state(false); + ESP_LOGI("cover", "idle"); + } + if (delta < 2 && delta > -2) + return {}; id(encoder_tracking_)[0] = curr; id(encoder_tracking_)[1] -= delta; if (id(encoder_tracking_)[1] < id(sensored_home_pos)) { ESP_LOGI("home", "Adjusted to %d", id(encoder_tracking_)[1]); id(sensored_home_pos) = id(encoder_tracking_)[1]; } + ESP_LOGD("angle", "Old %d new %d delta %d now %d home %d", id(encoder_tracking_)[0], curr, delta, + id(encoder_tracking_)[1] + delta, id(sensored_home_pos)); + + if (delta < -100 && id(pd_blinds)->current_operation != COVER_OPERATION_CLOSING) { + id(pd_blinds)->current_operation= COVER_OPERATION_CLOSING; + ESP_LOGI("cover", "closing"); + } else if (delta > 100 && id(pd_blinds)->current_operation != COVER_OPERATION_OPENING) { + id(pd_blinds)->current_operation = COVER_OPERATION_OPENING; + ESP_LOGI("cover", "opening"); + } + return id(encoder_tracking_)[1]; accuracy_decimals: 0 state_class: measurement