diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index d827a3b..dc3f169 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -2,6 +2,7 @@ name-template: 'Release v$NEXT_PATCH_VERSION' tag-template: "$RESOLVED_VERSION" change-template: "- #$NUMBER $TITLE @$AUTHOR" sort-direction: ascending +category-template: '**$TITLE**' categories: - title: "🚨 Breaking changes" @@ -26,11 +27,9 @@ include-labels: no-changes-template: '- No changes' +# The shared build workflow appends a Full Changelog compare link to the +# release body (release-drafter cannot render 4-part version tags). template: | - ## What's Changed + **What's Changed** $CHANGES - - **Full Changelog**: https://github.com/ApolloAutomation/PUMP-1/compare/$PREVIOUS_TAG...$RESOLVED_VERSION.1 - - Be sure to 🌟 this repository for updates! \ No newline at end of file diff --git a/.github/workflows/autoassign.yml b/.github/workflows/autoassign.yml index d5a6557..dfdfada 100644 --- a/.github/workflows/autoassign.yml +++ b/.github/workflows/autoassign.yml @@ -1,8 +1,11 @@ name: Auto Assign +# pull_request_target (not pull_request) so assignment works on +# fork-submitted PRs; fork pull_request runs get a read-only token. +# Safe because this workflow never checks out or executes PR code. on: issues: types: [opened] - pull_request: + pull_request_target: types: [opened] jobs: run: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 187fd8b..fb08129 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,17 +4,10 @@ on: pull_request: permissions: - # Allow GITHUB_TOKEN to add labels to pull requests - pull-requests: write - issues: write contents: read id-token: write jobs: - label-check: - name: Label Check - uses: ApolloAutomation/Workflows/.github/workflows/label-check.yml@main - ci: name: Building ${{ matrix.file }} / ESPHome ${{ matrix.esphome-version }} runs-on: ubuntu-latest diff --git a/.github/workflows/label-check.yml b/.github/workflows/label-check.yml new file mode 100644 index 0000000..96a9751 --- /dev/null +++ b/.github/workflows/label-check.yml @@ -0,0 +1,20 @@ +name: Label Check + +# pull_request_target (not pull_request) so the job gets a write token on +# fork-submitted PRs too; plain pull_request runs from forks are read-only +# and cannot add labels. Safe because the called workflow only reads the PR +# body and never checks out or executes PR code. The "edited" type re-runs +# the check when the template checkboxes are changed. +on: + pull_request_target: + types: [opened, edited, reopened, synchronize] + +permissions: + pull-requests: write + issues: write + contents: read + +jobs: + label-check: + name: Label Check + uses: ApolloAutomation/Workflows/.github/workflows/label-check.yml@main diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index 83294d1..a5e0790 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -1,10 +1,9 @@ substitutions: name: apollo-pump-1 - version: "25.12.18.1" + version: "26.3.2.1" device_description: ${name} made by Apollo Automation - version ${version}. esp32: - board: esp32-c6-devkitm-1 variant: esp32c6 flash_size: 8MB framework: @@ -18,9 +17,22 @@ esphome: id(pump_start_time) = 0; id(safety_alert_active) = false; - script.execute: pump_safety_check + - priority: -20 + then: + - if: + condition: + switch.is_on: tank_refill_mode + then: + - switch.turn_on: stop_pump_when_full + - switch.turn_off: stop_pump_when_dry + - switch.turn_on: auto_refill + else: + - switch.turn_off: stop_pump_when_full + - switch.turn_on: stop_pump_when_dry + - switch.turn_off: auto_refill - priority: -100 then: - - delay: 1000ms + - delay: 1000ms - script.execute: statusCheck - priority: -10 then: @@ -69,6 +81,7 @@ captive_portal: web_server: port: 80 + version: 3 # Buzzer output: @@ -127,6 +140,30 @@ switch: restore_mode: RESTORE_DEFAULT_OFF icon: mdi:water-sync entity_category: config + - platform: template + name: "Tank Refill Mode" + id: tank_refill_mode + optimistic: true + restore_mode: RESTORE_DEFAULT_OFF + icon: mdi:water-sync + entity_category: config + on_turn_on: + then: + - switch.turn_on: stop_pump_when_full + - switch.turn_off: stop_pump_when_dry + - switch.turn_on: auto_refill + on_turn_off: + then: + - switch.turn_off: stop_pump_when_full + - switch.turn_on: stop_pump_when_dry + - switch.turn_off: auto_refill + - platform: template + name: "Auto Refill" + id: auto_refill + optimistic: true + restore_mode: RESTORE_DEFAULT_OFF + icon: mdi:autorenew + entity_category: config - platform: template name: "Pump Safety Override" id: pump_safety_override @@ -147,10 +184,21 @@ switch: - if: condition: or: - - binary_sensor.is_on: fluid_input_sensor + # Normal mode: input has water + - and: + - switch.is_off: tank_refill_mode + - binary_sensor.is_on: fluid_input_sensor + # Inverted mode: input is dry (destination is low, needs filling) + - and: + - switch.is_on: tank_refill_mode + - binary_sensor.is_off: fluid_input_sensor + # Bypass: dry protection not enabled - switch.is_off: stop_pump_when_dry then: - logger.log: "Pump turning on - conditions met" + - text_sensor.template.publish: + id: last_pump_action + state: "Pump Started" - lambda: |- id(pump_start_time) = millis(); id(safety_alert_active) = false; @@ -160,10 +208,17 @@ switch: - switch.turn_off: pump_control on_turn_off: then: + - if: + condition: + lambda: 'return id(pump_start_time) != 0;' + then: + - logger.log: "Pump turned off" + - text_sensor.template.publish: + id: last_pump_action + state: "Pump Stopped" - lambda: |- id(pump_start_time) = 0; id(safety_alert_active) = false; - - logger.log: "Pump turned off" binary_sensor: - platform: status @@ -213,6 +268,20 @@ binary_sensor: input: true pullup: true inverted: true + on_release: + then: + - if: + condition: + and: + - switch.is_on: auto_refill + - switch.is_on: tank_refill_mode + - switch.is_off: pump_control + then: + - logger.log: "Auto refill triggered - tank level low" + - text_sensor.template.publish: + id: last_pump_action + state: "Auto Refill Triggered" + - script.execute: pumpUntilFull - platform: gpio name: Fluid Output @@ -295,6 +364,26 @@ light: min_brightness: 50% max_brightness: 100% +text_sensor: + - platform: template + name: "Last Pump Action" + id: last_pump_action + icon: mdi:pump + - platform: wifi_info + ip_address: + name: "IP Address" + id: wifi_ip + entity_category: "diagnostic" + - platform: version + name: "ESPHome Version" + hide_timestamp: true + entity_category: "diagnostic" + - platform: template + name: "Apollo Firmware Version" + id: apollo_firmware_version + update_interval: never + entity_category: "diagnostic" + script: - id: pumpUntilFull then: @@ -366,10 +455,20 @@ script: then: - logger.log: "Pump stopping - safety" - switch.turn_off: pump_control + - if: + condition: + - and: + - switch.is_on: tank_refill_mode + - switch.is_off: stop_pump_when_full + - binary_sensor.is_on: fluid_input_sensor + then: + - logger.log: "Pump stopping - destination full (inverted mode)" + - switch.turn_off: pump_control - if: condition: - and: - switch.is_on: stop_pump_when_dry + - switch.is_off: tank_refill_mode - binary_sensor.is_off: fluid_input_sensor then: - logger.log: "Pump stopping - input dry" diff --git a/Integrations/ESPHome/PUMP-1.yaml b/Integrations/ESPHome/PUMP-1.yaml index 1c619eb..d82dd26 100644 --- a/Integrations/ESPHome/PUMP-1.yaml +++ b/Integrations/ESPHome/PUMP-1.yaml @@ -3,10 +3,12 @@ esphome: friendly_name: Apollo PUMP-1 comment: Apollo PUMP-1 name_add_mac_suffix: true - platformio_options: - board_build.flash_mode: dio - on_boot: + - priority: 500 + then: + - text_sensor.template.publish: + id: apollo_firmware_version + state: "${version}" - priority: -10 then: - if: @@ -49,10 +51,7 @@ update: wifi: on_connect: - - delay: 5s - - ble.disable: - on_disconnect: - - ble.enable: + - component.update: firmware_update ap: ssid: "Apollo PUMP-1 Hotspot" diff --git a/Integrations/ESPHome/PUMP-1_Minimal.yaml b/Integrations/ESPHome/PUMP-1_Minimal.yaml index 5a5a83f..85c674b 100644 --- a/Integrations/ESPHome/PUMP-1_Minimal.yaml +++ b/Integrations/ESPHome/PUMP-1_Minimal.yaml @@ -3,14 +3,17 @@ esphome: friendly_name: Apollo PUMP-1 comment: Apollo PUMP-1 name_add_mac_suffix: true - platformio_options: - board_build.flash_mode: dio - project: name: "ApolloAutomation.PUMP-1" version: "${version}" min_version: 2023.11.1 + on_boot: + priority: 500 + then: + - text_sensor.template.publish: + id: apollo_firmware_version + state: "${version}" dashboard_import: package_import_url: github://ApolloAutomation/PUMP-1/Integrations/ESPHome/PUMP-1_Minimal.yaml