@@ -86,6 +86,16 @@ def create_x10(plm, housecode, unitcode, feature):
8686 return device
8787
8888
89+ def _get_most_recent_message (recent_messages ):
90+ if not recent_messages :
91+ return None
92+ most_recent = recent_messages [0 ]
93+ for recent in recent_messages [1 :]:
94+ if recent ["received" ] > most_recent ["received" ]:
95+ most_recent = recent
96+ return most_recent ["msg" ]
97+
98+
8999# pylint: disable=too-many-instance-attributes
90100# pylint: disable=too-many-public-methods
91101class Device :
@@ -842,7 +852,7 @@ def _is_duplicate(self, msg):
842852
843853 # Address an edge case where two directACKs arrive back to back
844854 # Keep the first one (see insteonplm issue # 215)
845- recent = self . _get_most_recent_message (recent_messages )
855+ recent = _get_most_recent_message (recent_messages )
846856 for recent_msg in recent_messages :
847857 _LOGGER .debug ("RCT: %s" , recent_msg ['msg' ])
848858 if recent and msg .flags .isDirectACK and recent .flags .isDirectACK :
@@ -857,15 +867,6 @@ def _save_recent_message(self, msg):
857867 recent_message = {"msg" : msg , "received" : datetime .datetime .now ()}
858868 self ._recent_messages .put_nowait (recent_message )
859869
860- def _get_most_recent_message (self , recent_messages ):
861- if not recent_messages :
862- return None
863- most_recent = recent_messages [0 ]
864- for recent in recent_messages [1 :]:
865- if recent ["received" ] > most_recent ["received" ]:
866- most_recent = recent
867- return most_recent ["msg" ]
868-
869870 def _send_msg (self , msg , callback = None , on_timeout = False ):
870871 _LOGGER .debug (
871872 "Starting %s Device._send_msg: Queuing message" , self .address .human
0 commit comments