@@ -454,6 +454,7 @@ def __init__(
454
454
self .global_sym_table = trig_cfg .get ("global_sym_table" , {})
455
455
self .notify_q = asyncio .Queue (0 )
456
456
self .active_expr = None
457
+ self .state_active_ident = None
457
458
self .state_trig_expr = None
458
459
self .state_trig_ident = None
459
460
self .event_trig_expr = None
@@ -546,6 +547,9 @@ async def do_func_call(func, ast_ctx, task_unique, kwargs=None):
546
547
if len (self .state_trig_ident ) > 0 :
547
548
State .notify_add (self .state_trig_ident , self .notify_q )
548
549
550
+ if self .active_expr :
551
+ self .state_active_ident = await self .active_expr .get_names ()
552
+
549
553
if self .event_trigger is not None :
550
554
_LOGGER .debug ("trigger %s adding event_trigger %s" , self .name , self .event_trigger [0 ])
551
555
Event .notify_add (self .event_trigger [0 ], self .notify_q )
@@ -591,6 +595,7 @@ async def do_func_call(func, ast_ctx, task_unique, kwargs=None):
591
595
# check the trigger-specific expressions
592
596
#
593
597
trig_ok = True
598
+ new_vars = {}
594
599
if notify_type == "state" :
595
600
new_vars , func_args = notify_info
596
601
@@ -613,7 +618,8 @@ async def do_func_call(func, ast_ctx, task_unique, kwargs=None):
613
618
# now check the state and time active expressions
614
619
#
615
620
if trig_ok and self .active_expr :
616
- trig_ok = await self .active_expr .eval ()
621
+ active_vars = State .notify_var_get (self .state_active_ident , new_vars )
622
+ trig_ok = await self .active_expr .eval (active_vars )
617
623
exc = self .active_expr .get_exception_long ()
618
624
if exc is not None :
619
625
self .active_expr .get_logger ().error (exc )
0 commit comments