From 3514aa54f5443351340b1d2d9bdbf07e71d42dc9 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 12 Feb 2025 14:46:22 +0000 Subject: [PATCH] Add reed switch, log all stop calls, device-specific wifi --- blind.yaml | 54 +++++++++++++++++++++++++++++++++++--------- landing-blind-3.yaml | 9 ++++++++ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/blind.yaml b/blind.yaml index 5a1de7e..a2edcba 100644 --- a/blind.yaml +++ b/blind.yaml @@ -57,14 +57,6 @@ esphome: packages: base: !include base.yaml -wifi: - power_save_mode: none - networks: - - ssid: !secret wifi_ssid - password: !secret wifi_pw - bssid: !secret lantiq_bssid - priority: 1 - logger: level: INFO @@ -176,8 +168,9 @@ stepper: on_stall: - logger.log: level: INFO - format: "Motor stalled at %f!" - args: [ "id(encoder)->get_state()" ] + format: "Motor stalled at %f in direction %d, travel %s!" + args: [ "id(encoder)->get_state()", "id(motor)->current_direction", + "cover_operation_to_str(id(pd_blinds)->current_operation)" ] - 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: @@ -206,6 +199,9 @@ button: - platform: template name: Stop on_press: + - logger.log: + level: INFO + format: "Stop template button" - stepper.stop: motor binary_sensor: @@ -243,6 +239,9 @@ binary_sensor: on_click: - max_length: 1s then: + - logger.log: + level: INFO + format: "Stop button" - stepper.stop: motor - min_length: 2s @@ -267,6 +266,36 @@ binary_sensor: on_press: - cover.open: pd_blinds + - platform: gpio + name: Reed Switch + id: reedsw + pin: + number: 14 + mode: + input: true + pullup: true + inverted: true + filters: + - delayed_on_off: 10ms + on_press: + - logger.log: + level: INFO + format: "Reed switch on at %f in direction %d, travel %s!" + args: [ "id(encoder)->get_state()", "id(motor)->current_direction", + "cover_operation_to_str(id(pd_blinds)->current_operation)" ] + - lambda: | + // If we hit the reed switch while travelling upwards, stop the motor and reset the home position. + if (id(motor).current_direction < 0) { + id(motor).stop(); + id(sensored_home_pos) = id(encoder)->get_state(); + } + on_release: + - logger.log: + level: INFO + format: "Reed switch off at %f in direction %d, travel %s!" + args: [ "id(encoder)->get_state()", "id(motor)->current_direction", + "cover_operation_to_str(id(pd_blinds)->current_operation)" ] + as5600: slow_filter: 16x @@ -359,7 +388,10 @@ cover: 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 + - logger.log: + level: INFO + format: "Cover stop" + - stepper.stop: motor open_action: - lambda: |- int32_t wantpos = id(sensored_home_pos); diff --git a/landing-blind-3.yaml b/landing-blind-3.yaml index ce7ebfc..dafcd0c 100644 --- a/landing-blind-3.yaml +++ b/landing-blind-3.yaml @@ -5,3 +5,12 @@ substitutions: packages: blind: !include blind.yaml + +wifi: + power_save_mode: none + networks: + - ssid: !secret wifi_ssid + password: !secret wifi_pw + bssid: !secret lantiq_bssid + priority: 1 + -- 2.50.1