Skip to content

Commit

Permalink
Merge pull request #44 from ApolloAutomation/FixSleep
Browse files Browse the repository at this point in the history
Remove Sleep After Connecting, Fix Sleep Numbers
  • Loading branch information
TrevorSchirmer authored Nov 9, 2024
2 parents c762784 + f363324 commit 91f137c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 43 deletions.
3 changes: 1 addition & 2 deletions Integrations/ESPHome/AIR-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ 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);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 1000);
- if:
condition:
or:
Expand Down
4 changes: 3 additions & 1 deletion Integrations/ESPHome/AIR-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 All @@ -40,6 +39,9 @@ ota:

bluetooth_proxy:
active: true
esp32_ble_tracker:
scan_parameters:
active: false

wifi:
ap:
Expand Down
3 changes: 1 addition & 2 deletions Integrations/ESPHome/AIR-1_Factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ 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);
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 60 * 1000);
- if:
condition:
or:
Expand Down
64 changes: 26 additions & 38 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-air-1
version: "24.10.29.1"
version: "24.11.9.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
Expand All @@ -20,13 +20,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:
- deep_sleep.enter:
id: deep_sleep_1
else:
- lambda: |-
id(reportAllValues).execute();
- deep_sleep.enter:
id: deep_sleep_1
services:
#Co2 Calibration Service
- service: calibrate_co2_value
Expand Down Expand Up @@ -77,7 +75,7 @@ i2c:
deep_sleep:
id: deep_sleep_1
sleep_duration: 5min
run_duration: 1min
run_duration: 2min

number:
- platform: template
Expand Down Expand Up @@ -106,25 +104,6 @@ number:
update_interval: never
step: 0.1
mode: box

- platform: template
name: "Run Duration"
id: deep_sleep_run_duration
min_value: 1
max_value: 800
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 1
icon: "mdi:arrow-collapse-right"
entity_category: CONFIG
unit_of_measurement: "min"
on_value:
then:
- lambda: |-
id(deep_sleep_1).set_run_duration(x * 1000);

- platform: template
name: "Sleep Duration"
Expand All @@ -143,7 +122,7 @@ number:
on_value:
then:
- lambda: |-
id(deep_sleep_1).set_sleep_duration(x * 60 * 60 * 1000);
id(deep_sleep_1).set_sleep_duration(x * 60 * 1000);

binary_sensor:
Expand Down Expand Up @@ -405,8 +384,10 @@ text_sensor:
return std::string("Abnormal");}
else if (id(sen55_voc).state < 400) {
return std::string("Very abnormal");}
else {
else if (id(sen55_voc).state >= 400) {
return std::string("Extremely abnormal");}
else {
return std::string("Unknown");}
switch:
- platform: factory_reset
Expand All @@ -432,13 +413,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: testScript
Expand Down Expand Up @@ -542,4 +516,18 @@ script:
green: 100%
blue: 0%
- delay: 5s
- light.turn_off: rgb_light
- light.turn_off: rgb_light
- id: reportAllValues
then:
- component.update: sen55
- component.update: mics4514
- component.update: dps_310
- component.update: scd40
- component.update: wifi_signal_db
- component.update: sys_esp_temperature
- component.update: sys_uptime
- component.update: pm0_3_to_1
- component.update: pm1_to_2_5
- component.update: pm2_5_to_4
- component.update: pm4_to_10
- component.update: voc_quality

0 comments on commit 91f137c

Please sign in to comment.