Closed luzik closed 5 months ago
The time based cover doesn't allow endstop sensors. The implementation here combines endstop cover and time based cover. You should be able to use this for Eachen GD-DC5 as long as you can figure out the right platform to use and the right relay and endstop configuration. If you were able to figure out it would be good to update this for others.
I ended up using cover feedback. It support both endstop and time based position, the only thing is to support one-click button with scenarios like user using HA press up-stop-up. I can put my yaml here when finish
Interesting. I wasn't aware of the feedback cover. I'll take a look. From a quick look I don't think it will properly work if the cover is stopped halfway. For my gdo if the door is stopped partially open and I want to fully open it, the relay needs to be activated twice.
Maybe you can help me with my setup. Feedback cover have this issue - when doors are fully closed with close_endstop=1 position is (0% - closed), and when I trigger close_endstop=0 (without using cover_open action) - just close_endstop goes to OFF then in HA nothing changes - it is still (0% - closed). Other firmware I was using in this situation change position to (1% - open) I am looking for something like
binary_sensor:
- platform: gpio
id: close_endstop
pin:
number: GPIO13
on_release:
then:
- cover.overwrite_actual_position: gate 1%
Here is my working version, with lots of debugs to clean out. I am open for any suggestions.
globals:
- id: global_last_direction
type: int
restore_value: yes
initial_value: '99'
# 1=opened, 2=closed, 99=initial value
- id: global_last_operation
type: esphome::cover::CoverOperation
restore_value: yes
initial_value: CoverOperation::COVER_OPERATION_IDLE
# 1= previous operation was opening, 2=closing, 0=idle
switch:
- platform: gpio
id: relay
name: Relay
disabled_by_default: true
pin: GPIO12
restore_mode: ALWAYS_OFF
on_turn_on:
- logger.log: "*********** RELAY **************"
- delay: 200ms
- switch.turn_off: relay
binary_sensor:
- platform: gpio
id: close_endstop
name: Close endstop
disabled_by_default: true
pin:
number: GPIO13
mode:
input: true
pullup: true
inverted: true
filters:
- delayed_on: 20ms
on_press:
then:
- logger.log: "*********** CLOSED **************"
on_release:
then:
- logger.log: "*********** NOT CLOSED **************"
- platform: gpio
id: click
name: Button Click
disabled_by_default: true
pin:
number: GPIO0
mode:
input: true
inverted: true
filters:
- delayed_on: 20ms
on_press:
then:
- logger.log: "*********** BUTTON **************"
- cover.toggle: gate
cover:
- platform: feedback
name: "Brama"
device_class: garage
id: gate
assumed_state: false
has_built_in_endstop: true
max_duration: 30s
open_duration: 22s
close_duration: 19s
direction_change_wait_time: 500ms
acceleration_wait_time: 300ms
open_action:
- if:
condition:
lambda: |-
return id(global_last_operation) != CoverOperation::COVER_OPERATION_IDLE;
then:
- cover.stop: gate
- if:
condition:
lambda: |-
return id(global_last_direction) == CoverOperation::COVER_OPERATION_OPENING;
then:
- switch.turn_on: relay
- delay: 400ms
- switch.turn_on: relay
- delay: 400ms
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_CLOSING;
- if:
condition:
and:
- lambda: |-
return id(global_last_direction) != CoverOperation::COVER_OPERATION_OPENING;
- lambda: |-
return id(global_last_operation) == CoverOperation::COVER_OPERATION_IDLE;
then:
- switch.turn_on: relay
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_OPENING;
id(global_last_operation) = CoverOperation::COVER_OPERATION_OPENING;
- logger.log: "*********** OPENING **************"
else:
- logger.log: "*********** OPENING ABORTED **************"
- lambda: |-
ESP_LOGD("custom", "global_last_direction=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_direction), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
ESP_LOGD("custom", "global_last_operation=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_operation), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
on_open:
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_OPENING;
id(global_last_operation) = CoverOperation::COVER_OPERATION_IDLE;
- logger.log: "*********** OPENED **************"
close_action:
- if:
condition:
lambda: |-
return id(global_last_operation) != CoverOperation::COVER_OPERATION_IDLE;
then:
- cover.stop: gate
- if:
condition:
lambda: |-
return id(global_last_direction) == CoverOperation::COVER_OPERATION_CLOSING;
then:
- switch.turn_on: relay
- delay: 400ms
- switch.turn_on: relay
- delay: 400ms
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_OPENING;
- if:
condition:
and:
- lambda: |-
return id(global_last_direction) != CoverOperation::COVER_OPERATION_CLOSING;
- lambda: |
return id(global_last_operation) == CoverOperation::COVER_OPERATION_IDLE;
then:
- switch.turn_on: relay
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_CLOSING;
id(global_last_operation) = CoverOperation::COVER_OPERATION_CLOSING;
- logger.log: "*********** CLOSING **************"
else:
- logger.log: "*********** CLOSING ABORTED **************"
- lambda: |-
ESP_LOGD("custom", "global_last_direction=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_direction), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
ESP_LOGD("custom", "global_last_operation=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_operation), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
close_endstop: close_endstop
on_closed:
- lambda: |-
id(global_last_direction) = CoverOperation::COVER_OPERATION_CLOSING;
id(global_last_operation) = CoverOperation::COVER_OPERATION_IDLE;
- logger.log: "*********** CLOSED **************"
stop_action:
- if:
condition:
lambda: |-
return id(global_last_operation) != CoverOperation::COVER_OPERATION_IDLE;
then:
- switch.turn_on: relay
- lambda: |-
id(global_last_operation) = CoverOperation::COVER_OPERATION_IDLE;
- logger.log: "*********** STOPPED **************"
else:
- logger.log: "*********** STOPPED ABORTED **************"
- lambda: |-
ESP_LOGD("custom", "global_last_direction=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_direction), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
ESP_LOGD("custom", "global_last_operation=%d, Idle=%d, Opening=%d, Closing=%d", id(global_last_operation), CoverOperation::COVER_OPERATION_IDLE, CoverOperation::COVER_OPERATION_OPENING, CoverOperation::COVER_OPERATION_CLOSING);
esp8266:
board: esp8285
For the feedback cover you might have better luck getting help from the ESPHome community forum or discord. Why don't you try my component? Replace cover in your config with:
cover:
- platform: gdo
id: gate
name: "Brama"
device_class: garage
open_duration: 22s
close_duration: 19s
single_press_action:
- logger.log: "relay single press"
- switch.turn_on: relay
double_press_action:
- logger.log: "relay double press"
- switch.turn_on: relay
- delay: 400ms
- switch.turn_on: relay
close_endstop: close_endstop
I am totally new to ESPHome, found this project and have few question about that. My hardware is drive with one button - connected in parallel with ESP relay GPIO12, and one input as "close" sensor GPIO13. I do not make use of obstruct sensor.
Why do I need esphome-gdo ? There is already time based cover in ESPHome. Is this about mixing "close" sensor with time based position ? Or native time-based configuration do not provide position, or maybe I can't set garage doors to 50% ?