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

Auto tests #40

Merged
merged 3 commits into from
Oct 10, 2024
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
2 changes: 1 addition & 1 deletion Integrations/ESPHome/AIR-1.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Define Project
substitutions:
name: apollo-air-1
version: "24.10.3.1"
version: "24.10.10.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esphome:
Expand Down
15 changes: 9 additions & 6 deletions Integrations/ESPHome/AIR-1_Factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ esphome:
version: "${version}"

min_version: 2024.6.4
on_boot:
- priority: -10
then:
- if:
condition:
- lambda: "return id(runTest);"
then:
- lambda: "id(testScript).execute();"

dashboard_import:
package_import_url: github://ApolloAutomation/AIR-1/Integrations/ESPHome/AIR-1.yaml
Expand All @@ -37,9 +45,4 @@ wifi:
ssid: "Apollo AIR1 Hotspot"

packages:
remote_package:
url: https://github.com/ApolloAutomation/AIR-1/
ref: main
files:
- Integrations/ESPHome/Core.yaml
refresh: 0d
core: !include Core.yaml
148 changes: 112 additions & 36 deletions Integrations/ESPHome/Core.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
substitutions:
name: apollo-air-1
version: "24.10.3.1"
version: "24.10.10.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esp32:
Expand Down Expand Up @@ -40,6 +40,26 @@ globals:
restore_value: no
type: uint32_t
initial_value: '0'
- id: runTest
restore_value: yes
type: bool
initial_value: "true"
- id: testCycleCount
type: int
restore_value: no
initial_value: "0"
- id: dps310Passed
restore_value: no
type: bool
initial_value: "false"
- id: sen55VOCPassed
restore_value: no
type: bool
initial_value: "false"
- id: sen55PMPassed
restore_value: no
type: bool
initial_value: "false"


i2c:
Expand Down Expand Up @@ -87,18 +107,23 @@ binary_sensor:
mode:
input: true
pullup: true
id: reset_button
id: reset_button
on_press:
then:
- lambda: |-
id(button_press_timestamp) = millis();
on_release:
then:
- lambda: |-
if (millis() - id(button_press_timestamp) >= 5000) {
if (millis() - id(button_press_timestamp) >= 8000) {
// Remove Wifi
id(factory_reset_switch).turn_on();
}
else if (millis() - id(button_press_timestamp) >= 1000) {
id(testCycleCount) = 0;
id(runTest) = true;
id(testScript).execute();
}

sensor:
- platform: internal_temperature
Expand Down Expand Up @@ -310,42 +335,93 @@ text_sensor:
return std::string("Extremely abnormal");}

switch:
- platform: template
name: "Startup Light Blink"
id: startup_light_blink
icon: mdi:lightbulb
restore_mode: RESTORE_DEFAULT_ON
optimistic: true
entity_category: "config"
- platform: factory_reset
id: factory_reset_switch
internal: true

#Used To Control RGB Light On Startup. Tells User Status Of Device
interval:
- interval: 1s
then:
- if:
condition:
- binary_sensor.is_off: ink_ha_connected
- lambda: 'return id(cycleCounter) < 30;'
- switch.is_on: startup_light_blink

then:
- light.toggle:
id: rgb_light
- lambda: 'id(cycleCounter) += 1;'

- interval: 1s
script:
- id: testScript
then:
- if:
condition:
- binary_sensor.is_off: ink_ha_connected
- lambda: 'return id(cycleCounter) > 30;'
- lambda: 'return id(cycleCounter) < 31;'
- switch.is_on: startup_light_blink

then:
- light.turn_off:
id: rgb_light
- lambda: 'id(cycleCounter) += 1;'
if:
condition:
- lambda: "return id(runTest) == true;"
then:
- lambda: "id(runTest) = false;"
- lambda: "id(testCycleCount) = 0;"
- while:
condition:
- lambda: "return id(testCycleCount) < 5;"
then:
- if:
condition:
- lambda: "return id(dps310Passed) == false;"
then:
- if:
condition:
- lambda: "return id(dps310pressure).state > 800 && id(dps310pressure).state < 1200;"
then:
- lambda: "id(dps310Passed) = true;"
- if:
condition:
- lambda: "return id(sen55VOCPassed) == false;"
then:
- if:
condition:
- lambda: "return id(sen55_voc).state > 10;"
then:
- lambda: "id(sen55VOCPassed) = true;"
- if:
condition:
- lambda: "return id(sen55PMPassed) == false;"
then:
- if:
condition:
- lambda: "return id(pm_10_0).state > 0.2;"
then:
- lambda: "id(sen55PMPassed) = true;"

- if:
condition:
- lambda: "return id(dps310Passed) && id(sen55VOCPassed) && id(sen55PMPassed);"
then:
- lambda: "id(testCycleCount) = 10;"
- lambda: "id(runTest) = false;"
- delay: 1s
- lambda: "id(testCycleCount) += 1;"

#Check If Test Passed To Trigger Lights
- if:
condition:
- lambda: "return id(dps310Passed) && id(sen55VOCPassed) && id(sen55PMPassed);"
then:
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
red: 0%
green: 100%
blue: 0%
- delay: 5s
- light.turn_on:
id: rgb_light
red: 0%
green: 0%
blue: 0%
- light.turn_off:
id: rgb_light

else:
- lambda: "id(runTest) = false;"
- light.turn_on:
id: rgb_light
red: 100%
green: 0%
blue: 0%
- delay: 5s
- light.turn_on:
id: rgb_light
red: 0%
green: 0%
blue: 0%
- light.turn_off:
id: rgb_light
Loading