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

Add "Sleep After Connecting" and "OTA Helper" to better manage sleep #4

Merged
merged 1 commit into from
Sep 22, 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
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
Loading