Skip to content

Commit

Permalink
Lower Minimums On Numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSchirmer committed Aug 5, 2024
1 parent ace2af9 commit 9e90f82
Show file tree
Hide file tree
Showing 2 changed files with 317 additions and 11 deletions.
18 changes: 14 additions & 4 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ number:
- platform: template
name: "Run Duration"
id: deep_sleep_run_duration
min_value: 1
min_value: 0
max_value: 800
step: 1
mode: box
Expand All @@ -142,7 +142,7 @@ number:
- platform: template
name: "Sleep Duration"
id: deep_sleep_sleep_duration
min_value: 1
min_value: 0
max_value: 800
step: 1
mode: box
Expand Down Expand Up @@ -182,6 +182,10 @@ binary_sensor:
// Remove Wifi
id(factory_reset_switch).turn_on();
}
- platform: homeassistant
name: "OTA Mode"
id: ota_mode
entity_id: input_boolean.ota_mode

sensor:
- platform: internal_temperature
Expand Down Expand Up @@ -270,5 +274,11 @@ switch:
name: "Alarm Outside Temp Range"
id: alarm_outside_temp_range
optimistic: true


- platform: template
name: "Prevent Sleep"
id: prevent_sleep
icon: mdi:sleep
restore_mode: RESTORE_DEFAULT_OFF
optimistic: true
entity_category: "config"
initial_value: true
310 changes: 303 additions & 7 deletions Integrations/ESPHome/TEMP-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ esphome:
ESP_LOGW("Apollo", "Power On");
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:
lambda: 'return id(ota_mode).state || id(prevent_sleep).state;'
then:
- lambda: |-
ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA On Boot");
id(deep_sleep_1).prevent_deep_sleep();
on_shutdown:
- switch.turn_off: accessory_power
Expand Down Expand Up @@ -46,10 +53,299 @@ wifi:

logger:

packages:
remote_package:
url: https://github.com/ApolloAutomation/TEMP-1/
ref: main
files:
- Integrations/ESPHome/Core.yaml
refresh: 0d













substitutions:
name: apollo-temp-1
version: "24.8.5.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
board: esp32-c3-devkitm-1
framework:
type: esp-idf

api:
services:
- service: play_buzzer
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
reboot_timeout: 0s

globals:
- id: cycleCounter
type: int
restore_value: no
initial_value: '0'
- id: button_press_timestamp
restore_value: no
type: uint32_t
initial_value: '0'

captive_portal:

web_server:
port: 80

external_components:
- source: github://ApolloAutomation/esphome-battery-component
components: [max17048] #Forked OptionZero

i2c:
sda: GPIO1
scl: GPIO0
id: bus_a

one_wire:
- platform: gpio
pin: GPIO5

# Buzzer
output:
- platform: ledc
pin: GPIO10
id: buzzer
rtttl:
output: buzzer


deep_sleep:
id: deep_sleep_1
sleep_duration: 4h
run_duration: 30s

# TODO: Add temp difference threshold notification. Sensor wakes up, checks temp difference from last measurement, if greater than threshold, send notification.


number:
- platform: template
name: AHT Temperature Offset
id: aht_temperature_offset
restore_value: true
initial_value: 0.0
min_value: -70.0
max_value: 70.0
entity_category: "CONFIG"
unit_of_measurement: "°C"
optimistic: true
update_interval: never
step: 0.1
mode: box

- platform: template
name: AHT Humidity Offset
id: aht_humidity_offset
restore_value: true
initial_value: 0
min_value: -70.0
max_value: 70.0
entity_category: "CONFIG"
unit_of_measurement: "%"
optimistic: true
update_interval: never
step: 0.1
mode: box

- platform: template
name: Max Temp
id: max_temp
restore_value: true
initial_value: 0
min_value: -70.0
max_value: 120.0
entity_category: "CONFIG"
unit_of_measurement: "%"
optimistic: true
update_interval: never
step: 0.1
mode: box

- platform: template
name: Min Temp
id: min_temp
restore_value: true
initial_value: 0
min_value: -70.0
max_value: 120.0
entity_category: "CONFIG"
unit_of_measurement: "%"
optimistic: true
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: 30
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
min_value: 1
max_value: 800
step: 1
mode: box
update_interval: never
optimistic: true
restore_value: true
initial_value: 8
icon: "mdi:arrow-collapse-right"
entity_category: CONFIG
unit_of_measurement: "h"
on_value:
then:
- lambda: |-
id(deep_sleep_1).set_sleep_duration(x * 60 * 60 * 1000);

binary_sensor:
- platform: status
name: Online
id: ink_ha_connected
- platform: gpio
pin:
number: GPIO9
inverted: true
mode:
input: true
pullup: true
id: reset_button
on_press:
then:
- lambda: |-
id(button_press_timestamp) = millis();
on_release:
then:
- lambda: |-
if (millis() - id(button_press_timestamp) >= 5000) {
// Remove Wifi
id(factory_reset_switch).turn_on();
}
- platform: homeassistant
name: "OTA Mode"
id: ota_mode
entity_id: input_boolean.ota_mode

sensor:
- platform: internal_temperature
name: "ESP Temperature"
id: sys_esp_temperature

- platform: uptime
name: Uptime
id: sys_uptime
update_interval: 60s

- platform: wifi_signal
name: RSSI
id: wifi_signal_db
update_interval: 60s
entity_category: "diagnostic"

- platform: dallas_temp
name: "Temperature Probe"
update_interval: 5s

- platform: aht10
variant: AHT20
temperature:
name: "Board Temperature"
filters:
- lambda: return x - id(aht_temperature_offset).state;
humidity:
name: "Board Humidity"
filters:
- lambda: return x - id(aht_humidity_offset).state;
update_interval: 5s

- platform: max17048
battery_voltage:
name: Battery voltage
id: batt_v
battery_level:
name: Battery level
id: batt_pct

light:
- platform: esp32_rmt_led_strip
id: rgb_light
name: "RGB Light"
pin: GPIO3
rmt_channel: 0
default_transition_length: 0s
chipset: WS2812
num_leds: 3
rgb_order: grb
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
min_brightness: 50%
max_brightness: 100%
- pulse:
name: "Fast Pulse"
transition_length: 100ms
update_interval: 100ms
min_brightness: 50%
max_brightness: 100%

button:
- platform: restart
icon: mdi:power-cycle
name: "ESP Reboot"

- platform: factory_reset
disabled_by_default: True
name: "Factory Reset ESP"
id: factory_reset_all


switch:
- platform: factory_reset
id: factory_reset_switch
internal: true
- platform: gpio
pin: GPIO4
name: "Accessory Power"
id: accessory_power
- platform: template
name: "Alarm Outside Temp Range"
id: alarm_outside_temp_range
optimistic: true
- platform: template
name: "Prevent Sleep"
id: prevent_sleep
icon: mdi:sleep
restore_mode: RESTORE_DEFAULT_ON
optimistic: true
entity_category: "config"

0 comments on commit 9e90f82

Please sign in to comment.