Skip to content

Commit eac47b6

Browse files
committed
test(hass): capture wall lamp adaptive lighting regression
1 parent 7e8270e commit eac47b6

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

modules/services/hass/_tests/eval-automations.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ let
1919
inherit (pkgs.lib) hasInfix;
2020

2121
haConfig = nixosConfig.config.services.home-assistant.config;
22+
adaptiveLighting = haConfig.adaptive_lighting or [ ];
2223
automations = haConfig.automation;
2324
scenes = haConfig.scene;
2425
scripts = haConfig.script;
@@ -37,6 +38,13 @@ let
3738
in
3839
if matches == [ ] then null else head matches;
3940

41+
findAdaptiveLighting =
42+
name:
43+
let
44+
matches = filter (c: (c.name or null) == name) adaptiveLighting;
45+
in
46+
if matches == [ ] then null else head matches;
47+
4048
hasHomeAssistantStartTrigger =
4149
triggers: any (t: (t.platform or null) == "homeassistant" && (t.event or null) == "start") triggers;
4250

@@ -181,6 +189,7 @@ let
181189
goodMorningScene = findScene "Good Morning";
182190
midMorningScene = findScene "Mid-morning";
183191
sundownScene = findScene "Sundown";
192+
livingSpaceAdaptiveLighting = findAdaptiveLighting "Living Space";
184193

185194
assertions = initialStateAssertions ++ [
186195
{
@@ -468,6 +477,13 @@ let
468477
test = (midMorningScene.entities."light.essentials_a19_a60_5" or null) == "off";
469478
msg = "Mid-morning scene doesn't turn off wall lamp";
470479
}
480+
{
481+
test =
482+
livingSpaceAdaptiveLighting != null
483+
&& builtins.elem "light.essentials_a19_a60_5" (livingSpaceAdaptiveLighting.lights or [ ]);
484+
expectedFailure = true;
485+
msg = "Living Space Adaptive Lighting must include wall lamp to avoid stale flash colors";
486+
}
471487
{
472488
test =
473489
let
@@ -486,8 +502,12 @@ let
486502
}
487503
];
488504

489-
failures = filter (a: !a.test) assertions;
490-
failureMessages = map (a: " FAIL: ${a.msg}") failures;
505+
failures = filter (
506+
a: (!a.test && !(a.expectedFailure or false)) || (a.test && (a.expectedFailure or false))
507+
) assertions;
508+
failureMessages = map (
509+
a: if a.expectedFailure or false then " XPASS: ${a.msg}" else " FAIL: ${a.msg}"
510+
) failures;
491511

492512
resultText =
493513
if failures == [ ] then

0 commit comments

Comments
 (0)