@@ -827,29 +827,32 @@ async def trigger_watch(self):
827827 #
828828
829829 # if "value" not in func_args, then we are state_check_now
830- if "value" in func_args and notify_type == 'state' :
830+ if notify_type == 'state' and all ([( x in func_args ) for x in [ 'value' , 'old_value' , 'var_name' ]]) :
831831 trig_ident_change = False
832832
833+ value = func_args ['value' ]
834+ old_value = func_args ['old_value' ]
835+ var_name = func_args ['var_name' ]
833836 # determine if the catchall has been requested in state_trig_ident_any
834- catch_all_entity = f"{ func_args [ ' var_name' ] } .*"
837+ catch_all_entity = f"{ var_name } .*"
835838 if catch_all_entity in self .state_trig_ident_any :
836839 # catch all has been requested, check all attributes for change
837- all_attributes = (set (func_args [ ' value' ] .__dict__ .keys ()) | set (func_args [ ' old_value' ] .__dict__ .keys ())) - {"last_updated" , "last_changed" }
840+ all_attributes = (set (value .__dict__ .keys ()) | set (old_value .__dict__ .keys ())) - {"last_updated" , "last_changed" }
838841 for attribute in all_attributes :
839- attrib_val = getattr (func_args [ ' value' ] , attribute , None )
840- attrib_old_val = getattr (func_args [ ' old_value' ] , attribute , None )
842+ attrib_val = getattr (value , attribute , None )
843+ attrib_old_val = getattr (old_value , attribute , None )
841844 if attrib_old_val != attrib_val :
842845 trig_ident_change = True
843846
844847 if not trig_ident_change :
845848 for var in self .state_trig_ident :
846849 var_pieces = var .split ('.' )
847- if len (var_pieces ) == 2 and var == func_args [ ' var_name' ] :
848- if func_args [ ' value' ] != func_args [ ' old_value' ] :
850+ if len (var_pieces ) == 2 and var == var_name :
851+ if value != old_value :
849852 trig_ident_change = True
850- elif len (var_pieces ) == 3 and f"{ var_pieces [0 ]} .{ var_pieces [1 ]} " == func_args [ ' var_name' ] :
851- attrib_val = getattr (func_args [ ' value' ] , var_pieces [2 ], None )
852- attrib_old_val = getattr (func_args [ ' old_value' ] , var_pieces [2 ], None )
853+ elif len (var_pieces ) == 3 and f"{ var_pieces [0 ]} .{ var_pieces [1 ]} " == var_name :
854+ attrib_val = getattr (value , var_pieces [2 ], None )
855+ attrib_old_val = getattr (old_value , var_pieces [2 ], None )
853856 if attrib_old_val != attrib_val :
854857 trig_ident_change = True
855858
0 commit comments