Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test script #10

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
substitutions:
version: "25.1.23.1"
version: "25.1.24.1"

esp32:
board: esp32-c3-devkitm-1
Expand Down Expand Up @@ -190,9 +190,12 @@ binary_sensor:
- lambda: |-
if (millis() - id(button_press_timestamp) >= 10000) {
// Remove Wifi
id(testCycleCount) = 0;
id(runTest) = true;
id(prevent_sleep).turn_on();
id(factory_reset_switch).turn_on();
}
else if (millis() - id(button_press_timestamp) >= 1000) {
else if (millis() - id(button_press_timestamp) >= 3000) {
//Turn Prevent Sleep On
id(prevent_sleep).turn_on();
//Prevent Sleep
Expand All @@ -201,6 +204,10 @@ binary_sensor:
else {
// StatusCheck
id(statusCheck).execute();
delay(3000);
id(testCycleCount) = 0;
id(runTest) = true;
id(testScript).execute();
}
- platform: homeassistant
name: "OTA Mode"
Expand Down Expand Up @@ -486,6 +493,7 @@ script:
then:
- lambda: "id(runTest) = false;"
- lambda: "id(testCycleCount) = 0;"
- switch.turn_on: accessory_power
- while:
condition:
- lambda: "return id(testCycleCount) < 5;"
Expand Down
114 changes: 61 additions & 53 deletions Integrations/ESPHome/TEMP-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,62 +12,70 @@ esphome:

min_version: 2024.2.0
on_boot:
priority: 800
then:
- lambda: |-
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 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();
- priority: 800
then:
- lambda: |-
id(deep_sleep_1).set_sleep_duration(id(deep_sleep_sleep_duration).state * 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"
- lambda: |-
id(reportAllValues).execute();
- delay: 5s
- if: # Check If Temp Probe Is Outside Threshold
condition:
- lambda: |-
// Determine the selected probe
std::string selected_probe = id(temp_probe_select).state.c_str();
float current_temp;
- if:
condition:
switch.is_on: notify_only_outside_temp_difference
then:
- logger.log: "Apollo Automation: Notify Only Outside Temp Difference"
- lambda: |-
id(reportAllValues).execute();
- delay: 5s
- if: # Check If Temp Probe Is Outside Threshold
condition:
- lambda: |-
// Determine the selected probe
std::string selected_probe = id(temp_probe_select).state.c_str();
float current_temp;

if (selected_probe == "Dallas") {
current_temp = id(temp_probe).state;
} else {
current_temp = id(ntc_sensor).state;
}
if (selected_probe == "Dallas") {
current_temp = id(temp_probe).state;
} else {
current_temp = id(ntc_sensor).state;
}

// Check temperature difference
if (std::abs(current_temp - id(last_temp)) > id(temp_diff_threshold)->state) {
return true;
id(last_temp) = current_temp;
} else {
return false;
}
then: # If So Then Turn On Wifi To Update
- logger.log: "Apollo Automation: Outside Temp Change Detected"
- 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:
- deep_sleep.enter:
id: deep_sleep_1

// Check temperature difference
if (std::abs(current_temp - id(last_temp)) > id(temp_diff_threshold)->state) {
return true;
id(last_temp) = current_temp;
} else {
return false;
}
then: # If So Then Turn On Wifi To Update
- logger.log: "Apollo Automation: Outside Temp Change Detected"
- 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:
- deep_sleep.enter:
id: deep_sleep_1
- priority: -500
then:
- switch.turn_on: accessory_power
- if:
condition:
- lambda: "return id(runTest);"
then:
- delay: 10s
- lambda: "id(testScript).execute();"
on_shutdown:
- light.turn_off: rgb_light

Expand Down
114 changes: 61 additions & 53 deletions Integrations/ESPHome/TEMP-1B.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,69 @@ esphome:

min_version: 2024.2.0
on_boot:
priority: 500
then:
- lambda: |-
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();
- priority: 500
then:
- lambda: |-
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"
- lambda: |-
id(reportAllValues).execute();
- delay: 5s
- if: # Check If Temp Probe Is Outside Threshold
condition:
- lambda: |-
// Determine the selected probe
std::string selected_probe = id(temp_probe_select).state.c_str();
float current_temp;
- if:
condition:
switch.is_on: notify_only_outside_temp_difference
then:
- logger.log: "Apollo Automation: Notify Only Outside Temp Difference"
- lambda: |-
id(reportAllValues).execute();
- delay: 5s
- if: # Check If Temp Probe Is Outside Threshold
condition:
- lambda: |-
// Determine the selected probe
std::string selected_probe = id(temp_probe_select).state.c_str();
float current_temp;

if (selected_probe == "Dallas") {
current_temp = id(temp_probe).state;
} else {
current_temp = id(ntc_sensor).state;
}
if (selected_probe == "Dallas") {
current_temp = id(temp_probe).state;
} else {
current_temp = id(ntc_sensor).state;
}

// Check temperature difference
if (std::abs(current_temp - id(last_temp)) > id(temp_diff_threshold)->state) {
return true;
id(last_temp) = current_temp;
} else {
return false;
}
then: # If So Then Turn On Wifi To Update
- logger.log: "Apollo Automation: Outside Temp Change Detected"
- 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:
- deep_sleep.enter:
id: deep_sleep_1
// Check temperature difference
if (std::abs(current_temp - id(last_temp)) > id(temp_diff_threshold)->state) {
return true;
id(last_temp) = current_temp;
} else {
return false;
}
then: # If So Then Turn On Wifi To Update
- logger.log: "Apollo Automation: Outside Temp Change Detected"
- 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:
- deep_sleep.enter:
id: deep_sleep_1
- priority: -300
then:
- if:
condition:
- lambda: "return id(runTest);"
then:
- delay: 10s
- lambda: "id(testScript).execute();"

on_shutdown:
- light.turn_off: rgb_light
Expand Down Expand Up @@ -108,7 +116,7 @@ wifi:
on_disconnect:
- ble.enable:
ap:
ssid: "Apollo TEMP1 Hotspot"
ssid: "Apollo TEMP1B Hotspot"

logger:

Expand Down
Loading