Skip to content

Commit

Permalink
Merge pull request #4 from ApolloAutomation/SleepImprovements
Browse files Browse the repository at this point in the history
Add "Sleep After Connecting" and "OTA Helper" to better manage sleep
  • Loading branch information
TrevorSchirmer authored Sep 22, 2024
2 parents 3f98b86 + cbc442e commit 76daa7d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
47 changes: 41 additions & 6 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-temp-1
version: "24.9.5.1"
version: "24.9.21.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
Expand All @@ -17,6 +17,27 @@ api:
- rtttl.play:
rtttl: !lambda 'return song_str;'
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();
else:
- if:
condition:
switch.is_on: sleep_after_connecting
then:
- switch.turn_off: accessory_power
- deep_sleep.enter:
id: deep_sleep_1


globals:
- id: cycleCounter
Expand Down Expand Up @@ -216,10 +237,14 @@ binary_sensor:
then:
- lambda: |-
id(deep_sleep_1).prevent_deep_sleep();
on_release:
on_release:
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();
- if:
condition:
switch.is_off: prevent_sleep
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();
sensor:
- platform: internal_temperature
Expand Down Expand Up @@ -334,8 +359,18 @@ switch:
id(deep_sleep_1).prevent_deep_sleep();
on_turn_off:
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();
- if:
condition:
binary_sensor.is_off: ota_mode
then:
- lambda: |-
id(deep_sleep_1).allow_deep_sleep();
- platform: template
name: "Sleep After Connecting"
id: sleep_after_connecting
icon: mdi:sleep
restore_mode: RESTORE_DEFAULT_ON
optimistic: true

- platform: template
name: Notify Only Outside Temp Difference
Expand Down
1 change: 0 additions & 1 deletion Integrations/ESPHome/TEMP-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ esphome:
- deep_sleep.enter:
id: deep_sleep_1


on_shutdown:
- light.turn_off: rgb_light
- switch.turn_off: accessory_power
Expand Down
2 changes: 1 addition & 1 deletion Integrations/ESPHome/TEMP-1_BLE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ esphome:


dashboard_import:
package_import_url: github://ApolloAutomation/TEMP-1/Integrations/ESPHome/TEMP-1.yaml
package_import_url: github://ApolloAutomation/TEMP-1/Integrations/ESPHome/TEMP-1_BLE.yaml
import_full_config: false

ota:
Expand Down
2 changes: 1 addition & 1 deletion Integrations/ESPHome/TEMP-1_Minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ esphome:


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

ota:
Expand Down

0 comments on commit 76daa7d

Please sign in to comment.