diff --git a/garage-door-GDOv1-S.yaml b/garage-door-GDOv1-S.yaml index 1719e77..abfb95a 100644 --- a/garage-door-GDOv1-S.yaml +++ b/garage-door-GDOv1-S.yaml @@ -53,7 +53,7 @@ substitutions: name: garage-door friendly_name: Garage Door Opener project_name: konnected.garage-door-gdov1-s - project_version: "1.0.0" + project_version: "1.1.0" garage_door_cover_name: Garage Door switch_name: Switch @@ -107,6 +107,18 @@ packages: # This package is required - packages/core-esp8266.yaml + #### + # GARAGE DOOR WIRED SENSOR + # Enables a wired contact sensor for reporting the open or closed state of the garage door + # via the physical INPUT terminals. + - packages/garage-door-wired-sensor.yaml + + #### + # GARAGE DOOR RANGE SENSOR + # Enables the optical laser range sensor included with some Konnected Garage Door opener models to detect + # the open/closed state of an overhead garage door. + - packages/vl53l0x-range-sensor.yaml + #### # GARAGE DOOR COVER # The Garage Door Cover is the main user interface entity representing a garage door in Home Assistant. @@ -122,18 +134,6 @@ packages: # 3. WIRED & RANGE SENSORS - Include this line. # - packages/garage-door-cover-wired-and-range.yaml - #### - # GARAGE DOOR WIRED SENSOR - # Enables a wired contact sensor for reporting the open or closed state of the garage door - # via the physical INPUT terminals. - - packages/garage-door-wired-sensor.yaml - - #### - # GARAGE DOOR RANGE SENSOR - # Enables the optical laser range sensor included with some Konnected Garage Door opener models to detect - # the open/closed state of an overhead garage door. - - packages/vl53l0x-range-sensor.yaml - #### # GARAGE DOOR OPENER BUTTON # Enables the garage door opener relay labeled DOOR on the Konnected Garage Door Opener as a button entity. When diff --git a/garage-door-GDOv2-S.yaml b/garage-door-GDOv2-S.yaml index 9b7e058..8fe61f5 100644 --- a/garage-door-GDOv2-S.yaml +++ b/garage-door-GDOv2-S.yaml @@ -57,7 +57,7 @@ substitutions: name: garage-door friendly_name: Garage Door Opener project_name: konnected.garage-door-gdov2-s - project_version: "1.0.0" + project_version: "1.1.0" garage_door_cover_name: Garage Door switch_name: STR output @@ -116,6 +116,18 @@ packages: # This package is required and sets up core ESPHome features. - packages/core-esp32-s3.yaml + #### + # GARAGE DOOR WIRED SENSOR + # Enables a wired contact sensor for reporting the open or closed state of the garage door + # via the physical INPUT terminals. + - packages/garage-door-wired-sensor.yaml + + #### + # GARAGE DOOR RANGE SENSOR + # Enables the optical laser range sensor included with some Konnected Garage Door opener models to detect + # the open/closed state of an overhead garage door. + - packages/vl53l0x-range-sensor.yaml + #### # GARAGE DOOR COVER # The Garage Door Cover is the main user interface entity representing a garage door in Home Assistant. @@ -131,18 +143,6 @@ packages: # 3. WIRED & RANGE SENSORS - Include this line. # - packages/garage-door-cover-wired-and-range.yaml - #### - # GARAGE DOOR WIRED SENSOR - # Enables a wired contact sensor for reporting the open or closed state of the garage door - # via the physical INPUT terminals. - - packages/garage-door-wired-sensor.yaml - - #### - # GARAGE DOOR RANGE SENSOR - # Enables the optical laser range sensor included with some Konnected Garage Door opener models to detect - # the open/closed state of an overhead garage door. - - packages/vl53l0x-range-sensor.yaml - #### # GARAGE DOOR OPENER BUTTON # Enables the garage door opener relay labeled DOOR on the Konnected Garage Door Opener as a button entity. When diff --git a/packages/buzzer-rtttl.yaml b/packages/buzzer-rtttl.yaml index 2ac3ace..696a967 100644 --- a/packages/buzzer-rtttl.yaml +++ b/packages/buzzer-rtttl.yaml @@ -15,6 +15,11 @@ button: then: - rtttl.play: $ominous_warning +script: + - id: error_tone + then: + - rtttl.play: err:d=16,o=4,b=100:d#,d#,d# + api: services: # Call the play_rtttl service to play any RTTTL song in the garage diff --git a/packages/garage-door-cover-range.yaml b/packages/garage-door-cover-range.yaml index 008392a..fb244e2 100644 --- a/packages/garage-door-cover-range.yaml +++ b/packages/garage-door-cover-range.yaml @@ -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 \ No newline at end of file + +<<: !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 diff --git a/packages/garage-door-cover-wired-and-range.yaml b/packages/garage-door-cover-wired-and-range.yaml index 90b8b48..a4cf42f 100644 --- a/packages/garage-door-cover-wired-and-range.yaml +++ b/packages/garage-door-cover-wired-and-range.yaml @@ -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 diff --git a/packages/garage-door-cover-wired.yaml b/packages/garage-door-cover-wired.yaml index 9089e28..811aa68 100644 --- a/packages/garage-door-cover-wired.yaml +++ b/packages/garage-door-cover-wired.yaml @@ -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 diff --git a/packages/garage-door-cover.yaml b/packages/garage-door-cover.yaml new file mode 100644 index 0000000..81ad7f9 --- /dev/null +++ b/packages/garage-door-cover.yaml @@ -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 \ No newline at end of file diff --git a/packages/warning-beep.yaml b/packages/warning-beep.yaml index 7540b5f..6e0bfa1 100644 --- a/packages/warning-beep.yaml +++ b/packages/warning-beep.yaml @@ -5,6 +5,20 @@ output: number: $warning_beep_pin allow_other_uses: $warning_beep_shared +script: + - id: error_tone + then: + - output.turn_on: buzzer_output + - delay: 60ms + - output.turn_off: buzzer_output + - delay: 50ms + - output.turn_on: buzzer_output + - delay: 60ms + - output.turn_off: buzzer_output + - delay: 50ms + - output.turn_on: buzzer_output + - delay: 60ms + - output.turn_off: buzzer_output light: - id: warning_beep