diff --git a/Integrations/ESPHome/Core.yaml b/Integrations/ESPHome/Core.yaml index a7045a6..ac4173c 100644 --- a/Integrations/ESPHome/Core.yaml +++ b/Integrations/ESPHome/Core.yaml @@ -1,6 +1,6 @@ substitutions: name: apollo-temp-1 - version: "24.9.21.1" + version: "24.9.21.2" device_description: ${name} made by Apollo Automation - version ${version}. esp32: diff --git a/Integrations/ESPHome/TEMP-1_BLE.yaml b/Integrations/ESPHome/TEMP-1_BLE.yaml index 6188ef5..bdd4c27 100644 --- a/Integrations/ESPHome/TEMP-1_BLE.yaml +++ b/Integrations/ESPHome/TEMP-1_BLE.yaml @@ -15,8 +15,47 @@ esphome: 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: + or: + - binary_sensor.is_on: ota_mode + - switch.is_on: prevent_sleep + then: + - lambda: |- + ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA On Boot"); + id(deep_sleep_1).prevent_deep_sleep(); + + - if: + condition: + switch.is_on: notify_only_outside_temp_difference + then: + - logger.log: "Apollo Automation: Notify Only Outside Temp Difference" + - delay: 2s + - if: # Check If Temp Probe Is Outside Threshold + condition: + - lambda: |- + return std::abs(id(temp_probe).state - id(last_temp)) > id(temp_diff_threshold)->state; + then: # If So Then Turn On Wifi To Update + - logger.log: "Apollo Automation: Outside Temp Change Detected" + - wifi.enable: + - lambda: |- + id(last_temp) = id(temp_probe).state; + else: # If Not Then Check OTA And Sleep + - if: + condition: + and: + - binary_sensor.is_off: ota_mode + - switch.is_off: prevent_sleep + then: + - switch.turn_off: accessory_power + - deep_sleep.enter: + id: deep_sleep_1 on_shutdown: + - light.turn_off: rgb_light - switch.turn_off: accessory_power diff --git a/Integrations/ESPHome/TEMP-1_Minimal.yaml b/Integrations/ESPHome/TEMP-1_Minimal.yaml index 6f69ed7..4a0d663 100644 --- a/Integrations/ESPHome/TEMP-1_Minimal.yaml +++ b/Integrations/ESPHome/TEMP-1_Minimal.yaml @@ -15,8 +15,47 @@ esphome: 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: + or: + - binary_sensor.is_on: ota_mode + - switch.is_on: prevent_sleep + then: + - lambda: |- + ESP_LOGW("Apollo", "Preventing Deep Sleep Due To OTA On Boot"); + id(deep_sleep_1).prevent_deep_sleep(); + + - if: + condition: + switch.is_on: notify_only_outside_temp_difference + then: + - logger.log: "Apollo Automation: Notify Only Outside Temp Difference" + - delay: 2s + - if: # Check If Temp Probe Is Outside Threshold + condition: + - lambda: |- + return std::abs(id(temp_probe).state - id(last_temp)) > id(temp_diff_threshold)->state; + then: # If So Then Turn On Wifi To Update + - logger.log: "Apollo Automation: Outside Temp Change Detected" + - wifi.enable: + - lambda: |- + id(last_temp) = id(temp_probe).state; + else: # If Not Then Check OTA And Sleep + - if: + condition: + and: + - binary_sensor.is_off: ota_mode + - switch.is_off: prevent_sleep + then: + - switch.turn_off: accessory_power + - deep_sleep.enter: + id: deep_sleep_1 on_shutdown: + - light.turn_off: rgb_light - switch.turn_off: accessory_power