Skip to content

Commit

Permalink
Merge pull request #9 from ApolloAutomation/UsePowerSupply
Browse files Browse the repository at this point in the history
Use power supply
  • Loading branch information
TrevorSchirmer authored Nov 25, 2024
2 parents b8210f5 + 23fba6b commit 52e9aa0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 52 deletions.
52 changes: 13 additions & 39 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
substitutions:
version: "24.11.24.1"
version: "24.11.25.1"

esp32:
board: esp32-c3-devkitm-1
Expand Down Expand Up @@ -47,8 +47,8 @@ i2c:

deep_sleep:
id: deep_sleep_1
sleep_duration: 12h
run_duration: 60s
sleep_duration: 24h
run_duration: 90s
wakeup_pin:
number: GPIO4
allow_other_uses: true
Expand All @@ -57,13 +57,11 @@ deep_sleep:
input: true
pullup: true

switch:
- platform: gpio
power_supply:
- id: 'power_supply_1'
pin: GPIO5
name: "Accessory Power"
id: accessory_power
restore_mode: ALWAYS_ON
setup_priority: 1100

switch:
- platform: factory_reset
id: factory_reset_switch
internal: true
Expand All @@ -76,25 +74,6 @@ button:
internal: true

number:
- 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: 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 All @@ -105,7 +84,7 @@ number:
update_interval: never
optimistic: true
restore_value: true
initial_value: 12
initial_value: 24
icon: "mdi:arrow-collapse-right"
entity_category: CONFIG
unit_of_measurement: "h"
Expand Down Expand Up @@ -257,6 +236,7 @@ light:
chipset: WS2812
num_leds: 22
rgb_order: grb
power_supply: power_supply_1
effects:
- pulse:
name: "Slow Pulse"
Expand Down Expand Up @@ -351,16 +331,14 @@ light:
script:
- id: play_song_1
then:
- switch.turn_on: accessory_power
- light.turn_on:
brightness: 50%
brightness: 40%
id: rgb_light
effect: "RainbowWave"
- rtttl.play:
rtttl: !lambda 'return id(song_1).state;'
- delay: 30s
- light.turn_off: rgb_light
- switch.turn_off: accessory_power
- if:
condition:
- switch.is_off: prevent_sleep
Expand All @@ -370,16 +348,14 @@ script:

- id: play_song_2
then:
- switch.turn_on: accessory_power
- light.turn_on:
brightness: 50%
brightness: 40%
id: rgb_light
effect: "TwinklingWhite"
- rtttl.play:
rtttl: !lambda 'return id(song_2).state;'
- delay: 30s
- light.turn_off: rgb_light
- switch.turn_off: accessory_power
- if:
condition:
- switch.is_off: prevent_sleep
Expand All @@ -389,16 +365,14 @@ script:

- id: play_song_3
then:
- switch.turn_on: accessory_power
- light.turn_on:
brightness: 50%
brightness: 40%
id: rgb_light
effect: "RedGreen"
- rtttl.play:
rtttl: !lambda 'return id(song_3).state;'
- delay: 30s
- light.turn_off: rgb_light
- switch.turn_off: accessory_power
- if:
condition:
- switch.is_off: prevent_sleep
Expand All @@ -411,7 +385,7 @@ script:
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
brightness: 50%
brightness: 40%
red: 0%
green: 100%
blue: 0%
Expand Down
12 changes: 5 additions & 7 deletions Integrations/ESPHome/H-1.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 All @@ -36,7 +34,6 @@ esphome:
- lambda: "id(testScript).execute();"
on_shutdown:
- light.turn_off: rgb_light
- switch.turn_off: accessory_power

dashboard_import:
package_import_url: github://ApolloAutomation/H-1/Integrations/ESPHome/H-1.yaml
Expand Down Expand Up @@ -100,6 +97,7 @@ api:
reboot_timeout: 0s
on_client_connected:
then:
- delay: 5s
- if:
condition:
or:
Expand All @@ -108,7 +106,7 @@ api:
then:
- lambda: |-
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA Or Switch");
id(deep_sleep_1).prevent_deep_sleep();
id(deep_sleep_1).prevent_deep_sleep();
switch:
- platform: template
name: "Prevent Sleep"
Expand Down Expand Up @@ -168,7 +166,7 @@ script:
- logger.log: "Apollo Automation: Connected To HA"
- light.turn_on:
id: rgb_light
brightness: 100%
brightness: 40%
red: 0%
green: 0%
blue: 100%
Expand All @@ -180,15 +178,15 @@ script:
- logger.log: "Apollo Automation: Connected To Wifi"
- light.turn_on:
id: rgb_light
brightness: 100%
brightness: 40%
red: 0%
green: 100%
blue: 0%
else:
- logger.log: "Apollo Automation: Not Connected To Wifi"
- light.turn_on:
id: rgb_light
brightness: 100%
brightness: 40%
red: 100%
green: 100%
blue: 0%
Expand Down
7 changes: 1 addition & 6 deletions Integrations/ESPHome/H-1D.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 All @@ -34,7 +32,6 @@ esphome:
- lambda: "id(testScript).execute();"
on_shutdown:
- light.turn_off: rgb_light
- switch.turn_off: accessory_power

safe_mode:

Expand All @@ -48,15 +45,13 @@ switch:
restore_mode: ALWAYS_OFF
optimistic: true
entity_category: "config"



script:
- id: statusCheck
then:
- light.turn_on:
id: rgb_light
brightness: 100%
brightness: 40%
red: 0%
green: 100%
blue: 0%
Expand Down

0 comments on commit 52e9aa0

Please sign in to comment.