forked from konnected-io/konnected-esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make garage door open and close commands state-aware and report infer…
…red opening and closing operations
- Loading branch information
1 parent
6c525e9
commit cd9f33d
Showing
8 changed files
with
187 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
cover: | ||
- platform: template | ||
name: $garage_door_cover_name | ||
id: garage_door | ||
device_class: garage | ||
lambda: |- | ||
if (id(garage_door_range_sensor).state) { | ||
return COVER_OPEN; | ||
} else { | ||
return COVER_CLOSED; | ||
} | ||
open_action: | ||
- button.press: garage_door_opener_button | ||
close_action: | ||
- button.press: pre_close_warning | ||
- delay: $garage_door_close_warning_duration | ||
- button.press: garage_door_opener_button | ||
stop_action: | ||
- button.press: garage_door_opener_button | ||
|
||
<<: !include garage-door-cover.yaml | ||
|
||
binary_sensor: | ||
- id: !extend garage_door_range_sensor | ||
on_state: | ||
- if: | ||
condition: | ||
lambda: return x; | ||
then: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: OPEN | ||
current_operation: IDLE | ||
else: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: CLOSED | ||
current_operation: IDLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
cover: | ||
- platform: template | ||
name: $garage_door_cover_name | ||
id: garage_door | ||
device_class: garage | ||
lambda: |- | ||
if (id(garage_door_input).state || id(garage_door_range_sensor).state) { | ||
return COVER_OPEN; | ||
} else { | ||
return COVER_CLOSED; | ||
} | ||
open_action: | ||
- button.press: garage_door_opener_button | ||
close_action: | ||
- button.press: pre_close_warning | ||
- delay: $garage_door_close_warning_duration | ||
- button.press: garage_door_opener_button | ||
stop_action: | ||
- button.press: garage_door_opener_button | ||
<<: !include garage-door-cover.yaml | ||
|
||
# Consider the garage door open if either the optical or range sensor reports open. | ||
# Consider the garage closed if both wired and range sensor report closed. | ||
binary_sensor: | ||
- id: !extend garage_door_input | ||
on_state: | ||
- if: | ||
condition: | ||
lambda: return (x || id(garage_door_range_sensor).state); | ||
then: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: OPEN | ||
current_operation: IDLE | ||
else: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: CLOSED | ||
current_operation: IDLE | ||
|
||
- id: !extend garage_door_range_sensor | ||
on_state: | ||
- if: | ||
condition: | ||
lambda: return (x || id(garage_door_input).state); | ||
then: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: OPEN | ||
current_operation: IDLE | ||
else: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: CLOSED | ||
current_operation: IDLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
cover: | ||
- platform: template | ||
name: $garage_door_cover_name | ||
id: garage_door | ||
device_class: garage | ||
lambda: |- | ||
if (id(garage_door_input).state) { | ||
return COVER_OPEN; | ||
} else { | ||
return COVER_CLOSED; | ||
} | ||
open_action: | ||
- button.press: garage_door_opener_button | ||
close_action: | ||
- button.press: pre_close_warning | ||
- delay: $garage_door_close_warning_duration | ||
- button.press: garage_door_opener_button | ||
stop_action: | ||
- button.press: garage_door_opener_button | ||
<<: !include garage-door-cover.yaml | ||
|
||
binary_sensor: | ||
- id: !extend garage_door_input | ||
on_state: | ||
- if: | ||
condition: | ||
lambda: return x; | ||
then: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: OPEN | ||
current_operation: IDLE | ||
else: | ||
- cover.template.publish: | ||
id: garage_door | ||
state: CLOSED | ||
current_operation: IDLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
cover: | ||
- platform: template | ||
name: $garage_door_cover_name | ||
id: garage_door | ||
device_class: garage | ||
|
||
# Opens the garage door only if the garage door is currently closed | ||
open_action: | ||
- if: | ||
condition: | ||
lambda: return id(garage_door).position == COVER_CLOSED; | ||
then: | ||
- button.press: garage_door_opener_button | ||
- cover.template.publish: | ||
id: garage_door | ||
current_operation: OPENING | ||
else: | ||
- script.execute: error_tone | ||
- lambda: ESP_LOGW("konnected.gdov2-s","Garage door is already open. Ignoring open action."); | ||
|
||
|
||
# Closes the garage door only if the garage door is currently open. | ||
# Triggers the pre-close warning before closing | ||
close_action: | ||
- if: | ||
condition: | ||
lambda: return id(garage_door).position == COVER_OPEN; | ||
then: | ||
- button.press: pre_close_warning | ||
- delay: $garage_door_close_warning_duration | ||
- button.press: garage_door_opener_button | ||
- cover.template.publish: | ||
id: garage_door | ||
current_operation: CLOSING | ||
else: | ||
- script.execute: error_tone | ||
- lambda: ESP_LOGW("konnected.gdov2-s","Garage door is already closed. Ignoring close action."); | ||
|
||
# Toggles the garage door open or closed | ||
# If the action would cause the door to close, then the pre-close warning is | ||
# triggered prior to closing | ||
toggle_action: | ||
- if: | ||
condition: | ||
lambda: return id(garage_door).position == COVER_OPEN; | ||
then: | ||
- button.press: pre_close_warning | ||
- delay: $garage_door_close_warning_duration | ||
- cover.template.publish: | ||
id: garage_door | ||
current_operation: CLOSING | ||
else: | ||
- cover.template.publish: | ||
id: garage_door | ||
current_operation: OPENING | ||
- button.press: garage_door_opener_button | ||
|
||
# Triggers the garage door button to stop only if the garage door is known to be moving | ||
stop_action: | ||
- if: | ||
condition: | ||
not: | ||
lambda: return id(garage_door).current_operation == CoverOperation::COVER_OPERATION_IDLE; | ||
then: | ||
- button.press: garage_door_opener_button | ||
- cover.template.publish: | ||
id: garage_door | ||
current_operation: IDLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters