Skip to content

Commit

Permalink
Update Automated Test
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorSchirmer committed May 9, 2024
1 parent d468652 commit c09a414
Showing 1 changed file with 131 additions and 43 deletions.
174 changes: 131 additions & 43 deletions Integrations/ESPHome/MSR-2.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Define Project
substitutions:
name: apollo-msr-2
version: "24.4.16.1"
version: "24.5.9.1"
device_description: ${name} made by Apollo Automation - version ${version}.

esphome:
Expand All @@ -17,6 +17,13 @@ esphome:
then:
- lambda: |-
id(radar_bluetooth).turn_off();
- priority: -10
then:
- if:
condition:
- lambda: "return id(runTest);"
then:
- lambda: "id(testScript).execute();"

project:
name: "ApolloAutomation.MSR-2"
Expand All @@ -38,26 +45,38 @@ logger:
level: WARN

globals:
- id: cpu_speed
- id: button_press_timestamp
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: cycleCounter
type: int
- id: dps310Passed
restore_value: no
initial_value: '0'
- id: button_press_timestamp
type: bool
initial_value: "false"
- id: ltr390lightPassed
restore_value: no
type: uint32_t
initial_value: '0'
type: bool
initial_value: "false"
- id: ltr390uvindexPassed
restore_value: no
type: bool
initial_value: "false"
- id: ld2410Passed
restore_value: no
type: bool
initial_value: "false"

# Enable Home Assistant API
# Also Add Buzzer Service Connection
api:
on_client_connected:
- delay: 1s
- light.turn_off: rgb_light
- lambda: 'id(cycleCounter) = 30;'
services:
- service: play_buzzer
variables:
Expand Down Expand Up @@ -325,8 +344,12 @@ binary_sensor:
on_release:
then:
- lambda: |-
if (millis() - id(button_press_timestamp) >= 5000) {
// Remove Wifi
if (millis() - id(button_press_timestamp) >= 1000) {
id(testCycleCount) = 0;
id(runTest) = true;
id(testScript).execute();
}
else if (millis() - id(button_press_timestamp) >= 8000) {
id(factory_reset_switch).turn_on();
}
Expand Down Expand Up @@ -481,8 +504,8 @@ light:
effects:
- pulse:
name: "Slow Pulse"
transition_length: 250ms
update_interval: 250ms
transition_length: 1000ms
update_interval: 1000ms
min_brightness: 50%
max_brightness: 100%
- pulse:
Expand Down Expand Up @@ -550,31 +573,96 @@ select:



#Used To Control RGB Light On Startup. Tells User Status Of Device
interval:
- interval: 1s
script:
- id: testScript
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
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 > 0;"
then:
- lambda: "id(dps310Passed) = true;"
- if:
condition:
- lambda: "return id(ltr390lightPassed) == false;"
then:
- if:
condition:
- lambda: "return id(ltr390light).state > 10;"
then:
- lambda: "id(ltr390lightPassed) = true;"
- if:
condition:
- lambda: "return id(ltr390uvindexPassed) == false;"
then:
- if:
condition:
- lambda: "return !isnan(id(ltr390uvindex).state);"
then:
- lambda: "id(ltr390uvindexPassed) = true;"
- if:
condition:
- lambda: "return id(ld2410Passed) == false;"
then:
- if:
condition:
- lambda: "return (id(radar_has_target).state == true && id(radar_detection_distance).state > 10);"
then:
- lambda: "id(ld2410Passed) = true;"
- if:
condition:
- lambda: "return id(dps310Passed) && id(ltr390lightPassed) && id(ltr390uvindexPassed) && id(ld2410Passed);"
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(ltr390lightPassed) && id(ltr390uvindexPassed) && id(ld2410Passed);"
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

0 comments on commit c09a414

Please sign in to comment.