Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Minimal Firmware On ESPHome Addon Import #12

Merged
merged 3 commits into from
Dec 20, 2024
Merged
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
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
file: # TODO: Rename
file:
- Integrations/ESPHome/H-1.yaml
- Integrations/ESPHome/H-1D.yaml
- Integrations/ESPHome/H-1_Minimal.yaml
esphome-version:
- stable
- beta
- dev
steps:
- name: Checkout source code
uses: actions/[email protected]
Expand Down
22 changes: 20 additions & 2 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
substitutions:
version: "24.11.25.1"
version: "24.12.19.1"

esp32:
board: esp32-c3-devkitm-1
Expand Down Expand Up @@ -72,6 +72,24 @@ button:
name: "Factory Reset"
entity_category: diagnostic
internal: true
- platform: template
id: btn_play_song_1
name: "Play Song 1"
on_press:
then:
- script.execute: play_song_1
- platform: template
id: btn_play_song_2
name: "Play Song 2"
on_press:
then:
- script.execute: play_song_2
- platform: template
id: btn_play_song_3
name: "Play Song 3"
on_press:
then:
- script.execute: play_song_3

number:
- platform: template
Expand Down Expand Up @@ -291,7 +309,7 @@ light:
lambda: |-
for (int i = 0; i < it.size(); i++) {
// Generate a random brightness factor between 50% and 100%
float brightness_factor = 0.5 + (esp_random() % 30) / 75.0;
float brightness_factor = 0.5 + (rand() % 30) / 75.0;

// Apply brightness to white color (255, 255, 255) for a twinkle effect
int white_r = 255 * brightness_factor;
Expand Down
2 changes: 1 addition & 1 deletion Integrations/ESPHome/H-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ esphome:
- light.turn_off: rgb_light

dashboard_import:
package_import_url: github://ApolloAutomation/H-1/Integrations/ESPHome/H-1.yaml
package_import_url: github://ApolloAutomation/H-1/Integrations/ESPHome/H-1_Minimal.yaml
import_full_config: false

improv_serial:
Expand Down
177 changes: 177 additions & 0 deletions Integrations/ESPHome/H-1_Minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
esphome:
name: "apollo-h-1"
friendly_name: Apollo H-1 Minimal
comment: Apollo H-1 Minimal
name_add_mac_suffix: true
platformio_options:
board_build.flash_mode: dio

project:
name: "ApolloAutomation.H-1_Minimal"
version: "${version}"

min_version: 2023.11.1
on_boot:
- priority: 500
then:
- lambda: |-
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 60 * 1000);
- if:
condition:
or:
- binary_sensor.is_on: ota_mode
- switch.is_on: prevent_sleep
then:
- lambda: |-
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA On Boot");
id(deep_sleep_1).prevent_deep_sleep();
- priority: -10
then:
- if:
condition:
- lambda: "return id(runTest);"
then:
- lambda: "id(testScript).execute();"
on_shutdown:
- light.turn_off: rgb_light

dashboard_import:
package_import_url: github://ApolloAutomation/H-1/Integrations/ESPHome/H-1_Minimal.yaml
import_full_config: false

improv_serial:

ota:
- platform: esphome
id: ota_esphome

wifi:
ap:
ssid: "Apollo H1 Hotspot"

logger:

captive_portal:

web_server:
port: 80

api:
services:
- service: play_buzzer
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
- service: play_song_1
then:
- script.execute: play_song_1
- service: play_song_2
then:
- script.execute: play_song_2
- service: play_song_3
then:
- script.execute: play_song_3
reboot_timeout: 0s
on_client_connected:
then:
- delay: 5s
- if:
condition:
or:
- binary_sensor.is_on: ota_mode
- switch.is_on: prevent_sleep
then:
- lambda: |-
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA Or Switch");
id(deep_sleep_1).prevent_deep_sleep();
switch:
- platform: template
name: "Prevent Sleep"
id: prevent_sleep
icon: mdi:sleep
restore_mode: RESTORE_DEFAULT_ON
optimistic: true
entity_category: "config"
on_turn_on:
then:
- lambda: |-
id(deep_sleep_1).prevent_deep_sleep();
on_turn_off:
then:
- if:
condition:
binary_sensor.is_off: ota_mode
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();

binary_sensor:
- platform: status
name: Online
id: ink_ha_connected
- platform: homeassistant
name: "OTA Mode"
id: ota_mode
entity_id: input_boolean.apollo_ota_mode
on_press:
then:
- lambda: |-
id(deep_sleep_1).prevent_deep_sleep();
on_release:
then:
- if:
condition:
switch.is_off: prevent_sleep
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();

sensor:
- platform: wifi_signal
name: RSSI
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"

script:
- id: statusCheck
then:
- if:
condition:
- lambda: 'return id(ink_ha_connected).state;'
then:
- logger.log: "Apollo Automation: Connected To HA"
- light.turn_on:
id: rgb_light
brightness: 40%
red: 0%
green: 0%
blue: 100%
else:
- if:
condition:
- wifi.connected
then:
- logger.log: "Apollo Automation: Connected To Wifi"
- light.turn_on:
id: rgb_light
brightness: 40%
red: 0%
green: 100%
blue: 0%
else:
- logger.log: "Apollo Automation: Not Connected To Wifi"
- light.turn_on:
id: rgb_light
brightness: 40%
red: 100%
green: 100%
blue: 0%
- delay: 5s
- light.turn_off: rgb_light


packages:
core: !include Core.yaml
Loading