@@ -454,6 +454,7 @@ def __init__(
454454 self .global_sym_table = trig_cfg .get ("global_sym_table" , {})
455455 self .notify_q = asyncio .Queue (0 )
456456 self .active_expr = None
457+ self .state_active_ident = None
457458 self .state_trig_expr = None
458459 self .state_trig_ident = None
459460 self .event_trig_expr = None
@@ -546,6 +547,9 @@ async def do_func_call(func, ast_ctx, task_unique, kwargs=None):
546547 if len (self .state_trig_ident ) > 0 :
547548 State .notify_add (self .state_trig_ident , self .notify_q )
548549
550+ if self .active_expr :
551+ self .state_active_ident = await self .active_expr .get_names ()
552+
549553 if self .event_trigger is not None :
550554 _LOGGER .debug ("trigger %s adding event_trigger %s" , self .name , self .event_trigger [0 ])
551555 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):
591595 # check the trigger-specific expressions
592596 #
593597 trig_ok = True
598+ new_vars = {}
594599 if notify_type == "state" :
595600 new_vars , func_args = notify_info
596601
@@ -613,7 +618,8 @@ async def do_func_call(func, ast_ctx, task_unique, kwargs=None):
613618 # now check the state and time active expressions
614619 #
615620 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 )
617623 exc = self .active_expr .get_exception_long ()
618624 if exc is not None :
619625 self .active_expr .get_logger ().error (exc )
0 commit comments