@@ -646,15 +646,23 @@ def start(self):
646646
647647 def ident_any_values_changed (self , func_args ):
648648 """Check for changes to state or attributes on ident any vars"""
649- value = func_args [ 'value' ]
650- old_value = func_args [ 'old_value' ]
651- var_name = func_args [ 'var_name' ]
649+ value = func_args . get ( 'value' )
650+ old_value = func_args . get ( 'old_value' )
651+ var_name = func_args . get ( 'var_name' )
652652
653653 if var_name is None :
654+ _LOGGER .debug (
655+ "%s ident_any change not detected because no var_name" ,
656+ self .name ,
657+ )
654658 return False
655659
656660 for check_var in self .state_trig_ident_any :
657661 if check_var == var_name and old_value != value :
662+ _LOGGER .debug (
663+ "%s ident_any change detected at state" ,
664+ self .name ,
665+ )
658666 return True
659667
660668 if check_var .startswith (f"{ var_name } ." ):
@@ -672,32 +680,74 @@ def ident_any_values_changed(self, func_args):
672680 attrib_val = getattr (value , attribute , None )
673681 attrib_old_val = getattr (old_value , attribute , None )
674682 if attrib_old_val != attrib_val :
683+ _LOGGER .debug (
684+ "%s ident_any change detected in * at %s" ,
685+ self .name ,
686+ attribute ,
687+ )
675688 return True
676689 else :
677690 attrib_val = getattr (value , var_pieces [2 ], None )
678691 attrib_old_val = getattr (old_value , var_pieces [2 ], None )
679692 if attrib_old_val != attrib_val :
693+ _LOGGER .debug (
694+ "%s ident_any change detected at %s" ,
695+ self .name ,
696+ var_pieces [2 ],
697+ )
680698 return True
699+
700+ _LOGGER .debug (
701+ "%s no ident_any change detected" ,
702+ self .name ,
703+ )
681704 return False
682705
683706 def ident_values_changed (self , func_args ):
684707 """Check for changes to state or attributes on ident vars"""
685- value = func_args ['value' ]
686- old_value = func_args ['old_value' ]
687- var_name = func_args ['var_name' ]
708+ value = func_args .get ('value' )
709+ old_value = func_args .get ('old_value' )
710+ var_name = func_args .get ('var_name' )
711+
712+ if var_name is None :
713+ _LOGGER .debug (
714+ "%s ident changes detected because no var_name" ,
715+ self .name ,
716+ )
717+ return True
718+
688719 for check_var in self .state_trig_ident :
689- if check_var in self .state_trig_ident_any :
690- continue
720+ # if check_var in self.state_trig_ident_any:
721+ # _LOGGER.debug(
722+ # "%s ident change skipping %s because also ident_any",
723+ # self.name,
724+ # check_var,
725+ # )
726+ # continue
691727 var_pieces = check_var .split ('.' )
692728 if len (var_pieces ) == 2 and check_var == var_name :
693729 if value != old_value :
730+ _LOGGER .debug (
731+ "%s ident change detected at state" ,
732+ self .name
733+ )
694734 return True
695735 elif len (var_pieces ) == 3 and f"{ var_pieces [0 ]} .{ var_pieces [1 ]} " == var_name :
696736 attrib_val = getattr (value , var_pieces [2 ], None )
697737 attrib_old_val = getattr (old_value , var_pieces [2 ], None )
698738 if attrib_old_val != attrib_val :
739+ _LOGGER .debug (
740+ "%s ident change detected at attribute %s" ,
741+ self .name ,
742+ var_pieces [2 ]
743+ )
699744 return True
700745
746+ _LOGGER .debug (
747+ "%s no ident change detected" ,
748+ self .name ,
749+ )
750+
701751 return False
702752
703753 async def trigger_watch (self ):
@@ -798,7 +848,7 @@ async def trigger_watch(self):
798848 if not self .ident_any_values_changed (func_args ):
799849 if not self .ident_values_changed (func_args ):
800850 continue
801-
851+
802852 if self .state_trig_eval :
803853 trig_ok = await self .state_trig_eval .eval (new_vars )
804854 exc = self .state_trig_eval .get_exception_long ()
0 commit comments