]> www.infradead.org Git - users/dwmw2/esp32-pool.git/commitdiff
Round cover percentage so it reaches closed
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 11 Feb 2025 21:51:13 +0000 (21:51 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 11 Feb 2025 21:51:13 +0000 (21:51 +0000)
blind.yaml

index ef96e88f3d96d0a1dc24f9980fa4860d83853996..209cb841ef684c89c86d18fc1cfd5b9ea72876af 100644 (file)
@@ -175,8 +175,9 @@ stepper:
     # dir_pin: 6
     on_stall:
       - logger.log:
-         format: "Motor stalled!"
          level: INFO
+         format: "Motor stalled at %f!"
+         args: [ "id(encoder)->get_state()" ]
       - stepper.stop: motor #un-comment this to disable on stall
       - lambda: id(sensored_home_pos) = id(encoder)->get_state();  #un-comment this to not reset home on stall
       - cover.template.publish:
@@ -273,7 +274,7 @@ sensor:
           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");
+             ESP_LOGI("cover", "idle at %d", id(encoder_tracking_)[1]);
           }
           if (delta < 2 && delta > -2)
             return {};
@@ -335,7 +336,7 @@ cover:
     assumed_state: false
     # internal: true
     lambda: |-
-      int percent = 100.0 * (id(encoder)->get_state()-id(sensored_home_pos)) / ${encoder_closed_pos};
+      int percent = (100.0 * (id(encoder)->get_state()-id(sensored_home_pos)) / ${encoder_closed_pos}) + 0.1;
       return (100.0 - percent) / 100.0;
     stop_action:
       - tmc2209.disable: motor