Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/build-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Build and Publish Beta

# Builds PLT-1 firmware from the beta branch and publishes it as assets on a
# rolling "beta-fw" pre-release. The on-device "Firmware Channel" select points
# OTA updates at these assets. Stable firmware is built/published separately
# by build.yml (push to main -> GitHub Pages).

on:
push:
branches: [beta]
paths:
- 'Integrations/ESPHome/**'
workflow_dispatch:

# Least privilege: read-only by default; only publish-beta is elevated to write.
permissions:
contents: read

jobs:
version:
name: Read version
runs-on: ubuntu-latest
outputs:
v: ${{ steps.read.outputs.v }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- id: read
run: |
v=$(awk '/substitutions:/ {f=1} f && /version:/ {print $2; exit}' \
Integrations/ESPHome/Core.yaml | tr -d '"')
echo "v=$v" >> "$GITHUB_OUTPUT"
echo "Beta version: $v"

build:
name: Build ${{ matrix.name }}
needs: version
strategy:
matrix:
include:
# Beta serves OTA updates only, so it builds the end-user Minimal
# images, not the first-flash improv images.
- { yaml: Integrations/ESPHome/beta-channel/PLT-1_Minimal.yaml, name: firmware-beta }
- { yaml: Integrations/ESPHome/beta-channel/PLT-1B_Minimal.yaml, name: firmware-b-beta }
uses: esphome/workflows/.github/workflows/build.yml@025a1e6255610c498ed590403b7e510b69e474df # 2026.4.1
with:
files: ${{ matrix.yaml }}
esphome-version: stable
combined-name: ${{ matrix.name }}
release-version: ${{ needs.version.outputs.v }}

publish-beta:
name: Publish beta release assets
needs: [version, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download firmware artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: fw
pattern: firmware*

- name: Ensure rolling 'beta-fw' pre-release exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view beta-fw -R "${{ github.repository }}" >/dev/null 2>&1 \
|| gh release create beta-fw -R "${{ github.repository }}" \
--prerelease --title "Beta (rolling)" \
--notes "Latest PLT-1 beta firmware. Auto-updated on every push to the beta branch."

- name: Rewrite manifests to absolute URLs and upload assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BASE="https://github.com/${{ github.repository }}/releases/download/beta-fw"
# Manifest names match the on-device variant_slug: "" and "-b".
declare -A DIRS=( [""]=firmware-beta ["-b"]=firmware-b-beta )
for v in "" "-b"; do
src="fw/${DIRS[$v]}"
man=$(find "$src" -name manifest.json | head -1)
if [ -z "$man" ]; then
echo "::error::manifest.json not found for ${DIRS[$v]}"
exit 1
fi
echo "Rewriting $man"
# Make ota.path and parts[].path absolute release-asset URLs so the
# device never has to resolve a relative path against a redirect.
# The two variants have distinct device names, so bin filenames
# don't collide in the flat release-asset namespace.
jq --arg base "$BASE" '
.builds[0].ota.path = ($base + "/" + (.builds[0].ota.path | sub(".*/"; "")))
| .builds[0].parts |= map(.path = ($base + "/" + (.path | sub(".*/"; ""))))
' "$man" > "manifest$v.json"
cat "manifest$v.json"
gh release upload beta-fw "manifest$v.json" -R "${{ github.repository }}" --clobber
find "$src" -name '*.bin' -print -exec \
gh release upload beta-fw {} -R "${{ github.repository }}" --clobber \;
done
echo "Beta assets published."
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ jobs:
pull-requests: write
with:
device-name: plt-1
# The Minimal yamls are the end-user images served at firmware/ and
# firmware-b/ (OTA updates and dashboard adoption). The improv images
# move to *-factory/ and are only used for first flashes via the web
# installer.
yaml-files: |
Integrations/ESPHome/PLT-1_Minimal.yaml
Integrations/ESPHome/PLT-1B_Minimal.yaml
Integrations/ESPHome/PLT-1.yaml
Integrations/ESPHome/PLT-1B.yaml
firmware-names: "1:firmware,1B:firmware-b"
firmware-names: "1_Minimal:firmware,1B_Minimal:firmware-b,1:firmware-factory,1B:firmware-b-factory"
core-yaml-path: Integrations/ESPHome/Core.yaml
esphome-version: stable
# Bypass check if manually triggered with bypass option
Expand Down
1 change: 1 addition & 0 deletions Integrations/ESPHome/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# You can modify this file to suit your needs.
/.esphome/
/secrets.yaml
beta-channel/.esphome/
90 changes: 89 additions & 1 deletion Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
substitutions:
version: "26.3.2.1"
version: "26.7.8.1"
# Firmware variant identity: overridden to "-b" by the PLT-1B images so
# each hardware variant tracks its own manifests.
variant_slug: ""
# Default update channel on first boot (no stored user choice yet, i.e. a
# fresh flash). The beta-channel builds override this to "Beta" (see
# Integrations/ESPHome/beta-channel/) so firmware obtained from the beta
# channel keeps tracking it instead of offering a stable "downgrade".
firmware_channel_default: "Stable"
# Manifest URL bases. Stable = GitHub Pages (main branch builds).
# Beta = rolling "beta" pre-release assets (beta branch builds).
stable_manifest_base: "https://apolloautomation.github.io/PLT-1"
beta_manifest_base: "https://github.com/ApolloAutomation/PLT-1/releases/download/beta-fw"

esp32:
variant: esp32c3
Expand Down Expand Up @@ -339,6 +351,52 @@ button:
icon: mdi:power-cycle
name: "ESP Reboot"

- platform: template
name: "Firmware Update"
id: update_firmware
icon: mdi:cloud-download
entity_category: "config"
on_press:
- logger.log: "Applying firmware based on selected channel"
# OTA download needs the device awake for its whole duration.
- lambda: |-
id(deep_sleep_1).prevent_deep_sleep();
# Free heap for the TLS download when BLE (improv) is active. Guarded
# so images without BLE compile the same YAML.
- lambda: |-
#ifdef USE_ESP32_BLE
if (esp32_ble::global_ble && esp32_ble::global_ble->is_active()) {
ESP_LOGI("firmware", "Disabling BLE for firmware update");
esp32_ble::global_ble->disable();
}
#endif
- delay: 3s
- script.execute: apply_ota_source
- script.wait: apply_ota_source
# The manifest fetch runs in its own task and YAML has no "fetch done"
# condition to wait on (update.is_available stays false for same-version
# switches), so give it a fixed window like R_PRO-1/CAST-1 do.
- delay: 5s
- update.perform:
id: update_http_request
force_update: true
# Only reached if the update did not start (e.g. manifest unreachable).
- lambda: |-
#ifdef USE_ESP32_BLE
if (esp32_ble::global_ble) {
ESP_LOGI("firmware", "Re-enabling BLE (no update performed)");
esp32_ble::global_ble->enable();
}
#endif
- if:
condition:
and:
- switch.is_off: prevent_sleep
- binary_sensor.is_off: ota_mode
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();

- platform: factory_reset
disabled_by_default: True
name: "Factory Reset ESP"
Expand Down Expand Up @@ -385,7 +443,37 @@ text_sensor:
update_interval: never
entity_category: "diagnostic"

select:
- platform: template
name: "Firmware Channel"
id: firmware_channel
icon: mdi:source-branch
entity_category: "config"
optimistic: true
restore_value: true
options:
- "Stable"
- "Beta"
initial_option: "${firmware_channel_default}"
on_value:
then:
- script.execute: apply_ota_source

script:
- id: apply_ota_source
# Sets the OTA manifest URL from the Firmware Channel select for this
# hardware variant (${variant_slug}).
# Stable = GitHub Pages, Beta = rolling "beta" release assets.
then:
- lambda: |-
const bool beta = id(firmware_channel).current_option() == "Beta";
std::string url = beta
? "${beta_manifest_base}/manifest${variant_slug}.json"
: "${stable_manifest_base}/firmware${variant_slug}/manifest.json";
ESP_LOGI("firmware", "OTA manifest set to: %s", url.c_str());
id(update_http_request).set_source_url(url);
- component.update: update_http_request

- id: statusCheck
then:
- if:
Expand Down
4 changes: 2 additions & 2 deletions Integrations/ESPHome/PLT-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ safe_mode:

update:
- platform: http_request
id: firmware_update
id: update_http_request
name: Firmware Update
source: https://apolloautomation.github.io/PLT-1/firmware/manifest.json

wifi:
on_connect:
- component.update: firmware_update
- component.update: update_http_request
ap:
ssid: "Apollo PLT1 Hotspot"

Expand Down
7 changes: 5 additions & 2 deletions Integrations/ESPHome/PLT-1B.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
substitutions:
variant_slug: "-b"

esphome:
name: "apollo-plt-1b"
friendly_name: Apollo PLT-1B
Expand Down Expand Up @@ -66,13 +69,13 @@ web_server:

update:
- platform: http_request
id: firmware_update
id: update_http_request
name: Firmware Update
source: https://apolloautomation.github.io/PLT-1/firmware-b/manifest.json

wifi:
on_connect:
- component.update: firmware_update
- component.update: update_http_request
ap:
ssid: "Apollo PLT1B Hotspot"

Expand Down
16 changes: 16 additions & 0 deletions Integrations/ESPHome/PLT-1B_BLE.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
substitutions:
variant_slug: "-b"

esphome:
name: "apollo-plt-1bble"
friendly_name: Apollo PLT-1BBLE
Expand Down Expand Up @@ -39,6 +42,17 @@ dashboard_import:
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_managed

http_request:
verify_ssl: true

update:
- platform: http_request
id: update_http_request
name: Firmware Update
source: ${stable_manifest_base}/firmware${variant_slug}/manifest.json

safe_mode:

Expand All @@ -50,6 +64,8 @@ esp32_ble_tracker:
active: false

wifi:
on_connect:
- component.update: update_http_request
ap:
ssid: "Apollo PLT1B Hotspot"

Expand Down
26 changes: 22 additions & 4 deletions Integrations/ESPHome/PLT-1B_Minimal.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
substitutions:
variant_slug: "-b"

esphome:
name: "apollo-plt-1b-minimal"
friendly_name: Apollo PLT-1B Minimal
comment: Apollo PLT-1B Minimal
name: "apollo-plt-1b"
friendly_name: Apollo PLT-1B
comment: Apollo PLT-1B
name_add_mac_suffix: true
project:
name: "ApolloAutomation.PLT-1B_Minimal"
name: "ApolloAutomation.PLT-1B"
version: "${version}"

min_version: 2025.6.0
Expand Down Expand Up @@ -49,12 +52,27 @@ improv_serial:
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_managed

http_request:
verify_ssl: true

safe_mode:

update:
- platform: http_request
id: update_http_request
name: Firmware Update
source: https://apolloautomation.github.io/PLT-1/firmware-b/manifest.json

web_server:
port: 80
version: 3

wifi:
on_connect:
- component.update: update_http_request
ap:
ssid: "Apollo PLT1B Hotspot"

Expand Down
13 changes: 13 additions & 0 deletions Integrations/ESPHome/PLT-1_BLE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ dashboard_import:
ota:
- platform: esphome
id: ota_esphome
- platform: http_request
id: ota_managed

http_request:
verify_ssl: true

update:
- platform: http_request
id: update_http_request
name: Firmware Update
source: ${stable_manifest_base}/firmware${variant_slug}/manifest.json

safe_mode:

Expand All @@ -50,6 +61,8 @@ esp32_ble_tracker:


wifi:
on_connect:
- component.update: update_http_request
ap:
ssid: "Apollo PLT1 Hotspot"

Expand Down
Loading
Loading