Skip to content

Commit

Permalink
Merge pull request #15 from ApolloAutomation/SimplifySleep
Browse files Browse the repository at this point in the history
Simplify sleep
  • Loading branch information
TrevorSchirmer authored Nov 9, 2024
2 parents 774c52f + 076fabc commit c864bb0
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 65 deletions.
21 changes: 2 additions & 19 deletions Integrations/ESPHome/Battery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ external_components:
deep_sleep:
id: deep_sleep_1
sleep_duration: 12h
run_duration: 60s
run_duration: 90s

sensor:
- platform: max17048
Expand All @@ -28,25 +28,8 @@ switch:
id: accessory_power
restore_mode: ALWAYS_ON
setup_priority: 1100
number:
- platform: template
name: "Run Duration"
id: deep_sleep_run_duration
min_value: 20
max_value: 800
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 60
icon: "mdi:arrow-collapse-right"
entity_category: CONFIG
unit_of_measurement: "s"
on_value:
then:
- lambda: |-
id(deep_sleep_1).set_run_duration(x * 1000);
number:

- platform: template
name: "Sleep Duration"
Expand Down
25 changes: 6 additions & 19 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
substitutions:
version: "24.11.6.1"
version: "24.11.9.1"

esp32:
board: esp32-c3-devkitm-1
Expand All @@ -26,15 +26,11 @@ api:
- 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:
- lambda: |-
id(reportAllValues).execute();
- deep_sleep.enter:
id: deep_sleep_1
else:
- lambda: |-
id(reportAllValues).execute();
- deep_sleep.enter:
id: deep_sleep_1

globals:
- id: cycleCounter
Expand Down Expand Up @@ -164,8 +160,6 @@ binary_sensor:
// Remove Wifi
id(testCycleCount) = 0;
id(runTest) = true;
id(deep_sleep_run_duration).publish_state(60);
id(deep_sleep_sleep_duration).publish_state(60);
id(prevent_sleep).turn_on();
id(factory_reset_switch).turn_on();
}
Expand Down Expand Up @@ -337,13 +331,6 @@ switch:
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
entity_category: "config"
script:
- id: statusCheck
Expand Down
21 changes: 1 addition & 20 deletions Integrations/ESPHome/NonBattery.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
deep_sleep:
id: deep_sleep_1
sleep_duration: 5min
run_duration: 1min
run_duration: 90s

number:
- platform: template
name: "Run Duration"
id: deep_sleep_run_duration
min_value: 20
max_value: 800
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 60
icon: "mdi:arrow-collapse-right"
entity_category: CONFIG
unit_of_measurement: "s"
on_value:
then:
- lambda: |-
id(deep_sleep_1).set_run_duration(x * 1000);
- platform: template
name: "Sleep Duration"
id: deep_sleep_sleep_duration
Expand Down
1 change: 0 additions & 1 deletion Integrations/ESPHome/PLT-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ esphome:
- priority: 800.0
then:
- lambda: |-
id(deep_sleep_1).set_run_duration(id(deep_sleep_run_duration).state * 1000);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 60 * 1000);
- if:
condition:
Expand Down
3 changes: 0 additions & 3 deletions Integrations/ESPHome/PLT-1B.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ esphome:
on_boot:
- priority: 999.0
then:
- switch.turn_on: accessory_power

- lambda: |-
id(deep_sleep_1).set_run_duration(id(deep_sleep_run_duration).state * 1000);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 60 * 1000);
- if:
condition:
Expand Down
5 changes: 3 additions & 2 deletions Integrations/ESPHome/PLT-1B_BLE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ esphome:
on_boot:
priority: 500
then:
- switch.turn_on: accessory_power
- lambda: |-
id(deep_sleep_1).set_run_duration(id(deep_sleep_run_duration).state * 1000);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 60 * 1000);
- if:
condition:
Expand Down Expand Up @@ -46,6 +44,9 @@ safe_mode:
bluetooth_proxy:
active: true

esp32_ble_tracker:
scan_parameters:
active: false

wifi:
ap:
Expand Down
5 changes: 4 additions & 1 deletion Integrations/ESPHome/PLT-1_BLE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ esphome:
priority: 500
then:
- lambda: |-
id(deep_sleep_1).set_run_duration(id(deep_sleep_run_duration).state * 1000);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 60 * 1000);
- if:
condition:
Expand Down Expand Up @@ -44,6 +43,10 @@ safe_mode:
bluetooth_proxy:
active: true

esp32_ble_tracker:
scan_parameters:
active: false


wifi:
ap:
Expand Down

0 comments on commit c864bb0

Please sign in to comment.