File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 182182 speech . text = "Turning on the TV." ;
183183 action = [
184184 {
185- action = "media_player.turn_on" ;
186- target . entity_id = "media_player.tv" ;
185+ action = "script.tv_on" ;
187186 }
188187 ] ;
189188 } ;
Original file line number Diff line number Diff line change 33let
44 inherit ( import ../_lib.nix ) ensureEnabled ;
55
6+ tvEntity = "media_player.living_room" ;
7+
68 # --- Helper functions ---
79 tvAction = action : {
810 inherit action ;
9- target . entity_id = "media_player.tv" ;
11+ target . entity_id = tvEntity ;
1012 } ;
1113
1214 tvOn = tvAction "media_player.turn_on" ;
6668 id = "tv_idle_auto_off" ;
6769 trigger = {
6870 platform = "state" ;
69- entity_id = "media_player.tv" ;
71+ entity_id = tvEntity ;
7072 to = "idle" ;
7173 "for" . hours = 2 ;
7274 } ;
136138 id = "count_tv_sessions" ;
137139 trigger = {
138140 platform = "state" ;
139- entity_id = "media_player.tv" ;
141+ entity_id = tvEntity ;
140142 to = "playing" ;
141143 } ;
142144 action = [
Original file line number Diff line number Diff line change 2121 haConfig = nixosConfig . config . services . home-assistant . config ;
2222 automations = haConfig . automation ;
2323 scenes = haConfig . scene ;
24+ scripts = haConfig . script ;
2425
2526 findAutomation =
2627 id :
8283 hasActionVariable =
8384 actions : variableName : any ( a : a ? variables && builtins . hasAttr variableName a . variables ) actions ;
8485
86+ hasTargetEntity = actions : entityId : any ( a : ( a . target . entity_id or null ) == entityId ) actions ;
87+
8588 hasTimeGuard =
8689 conditions : target :
8790 any ( c : ( c . condition or null ) == "time" && ( c . after or null ) == target ) conditions ;
142145 alDaytimeSleepCorrection = findAutomation "al_daytime_sleep_correction" ;
143146 entranceOccupancyNightLight = findAutomation "entrance_occupancy_night_light" ;
144147 arrivalFlashWallLamp = findAutomation "arrival_flash_wall_lamp" ;
148+ tvOnScript = scripts . tv_on or null ;
145149
146150 # Must stay removed
147151 goodMorningBothAwake = findAutomation "good_morning_both_awake" ;
222226 test = syncIphoneAlarm8sleep != null && ( syncIphoneAlarm8sleep . initial_state or null ) == false ;
223227 msg = "automation 'sync_iphone_alarm_8sleep' should remain present but declaratively disabled until an iOS alarm source exists" ;
224228 }
229+ {
230+ test =
231+ tvOnScript != null
232+ && hasActionCall ( toList ( tvOnScript . sequence or [ ] ) ) "media_player.turn_on"
233+ && hasTargetEntity ( toList ( tvOnScript . sequence or [ ] ) ) "media_player.living_room"
234+ && ! ( hasTargetEntity ( toList ( tvOnScript . sequence or [ ] ) ) "media_player.tv" ) ;
235+ msg = "script.tv_on must target Living Room Apple TV, not Cast media_player.tv" ;
236+ }
225237 {
226238 test = sleepFocusOffEdmund != null ;
227239 msg = "automation 'sleep_focus_off_stop_edmund' missing" ;
You can’t perform that action at this time.
0 commit comments