From 9e90f8277345fa42168b1c10e05e7157fdade81d Mon Sep 17 00:00:00 2001 From: Trevor Schirmer Date: Mon, 5 Aug 2024 19:25:29 -0400 Subject: [PATCH] Lower Minimums On Numbers --- Integrations/ESPHome/Core.yaml | 18 +- Integrations/ESPHome/TEMP-1.yaml | 310 ++++++++++++++++++++++++++++++- 2 files changed, 317 insertions(+), 11 deletions(-) diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index cacd9c8..6f055dd 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -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 @@ -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 @@ -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 @@ -270,5 +274,11 @@ switch: name: "Alarm Outside Temp Range" id: alarm_outside_temp_range optimistic: true - - \ No newline at end of file + - platform: template + name: "Prevent Sleep" + id: prevent_sleep + icon: mdi:sleep + restore_mode: RESTORE_DEFAULT_OFF + optimistic: true + entity_category: "config" + initial_value: true \ No newline at end of file diff --git a/Integrations/ESPHome/TEMP-1.yaml b/Integrations/ESPHome/TEMP-1.yaml index f527e1c..72cd777 100644 --- a/Integrations/ESPHome/TEMP-1.yaml +++ b/Integrations/ESPHome/TEMP-1.yaml @@ -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 @@ -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" \ No newline at end of file