|
19 | 19 | inherit (pkgs.lib) hasInfix; |
20 | 20 |
|
21 | 21 | haConfig = nixosConfig.config.services.home-assistant.config; |
| 22 | + adaptiveLighting = haConfig.adaptive_lighting or [ ]; |
22 | 23 | automations = haConfig.automation; |
23 | 24 | scenes = haConfig.scene; |
24 | 25 | scripts = haConfig.script; |
|
37 | 38 | in |
38 | 39 | if matches == [ ] then null else head matches; |
39 | 40 |
|
| 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 | + |
40 | 48 | hasHomeAssistantStartTrigger = |
41 | 49 | triggers: any (t: (t.platform or null) == "homeassistant" && (t.event or null) == "start") triggers; |
42 | 50 |
|
|
181 | 189 | goodMorningScene = findScene "Good Morning"; |
182 | 190 | midMorningScene = findScene "Mid-morning"; |
183 | 191 | sundownScene = findScene "Sundown"; |
| 192 | + livingSpaceAdaptiveLighting = findAdaptiveLighting "Living Space"; |
184 | 193 |
|
185 | 194 | assertions = initialStateAssertions ++ [ |
186 | 195 | { |
|
468 | 477 | test = (midMorningScene.entities."light.essentials_a19_a60_5" or null) == "off"; |
469 | 478 | msg = "Mid-morning scene doesn't turn off wall lamp"; |
470 | 479 | } |
| 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 | + } |
471 | 487 | { |
472 | 488 | test = |
473 | 489 | let |
|
486 | 502 | } |
487 | 503 | ]; |
488 | 504 |
|
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; |
491 | 511 |
|
492 | 512 | resultText = |
493 | 513 | if failures == [ ] then |
|
0 commit comments