File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
plugwise_usb/nodes/helpers Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -905,18 +905,22 @@ def _last_known_duration(self) -> timedelta:
905905 """Duration for last known logs."""
906906 if self ._logs is None :
907907 raise EnergyError ("Unable to return last known duration without any logs" )
908+
908909 if len (self ._logs ) < 2 :
909910 return timedelta (hours = 1 )
911+
910912 address , slot = self ._last_log_reference ()
911913 if address is None or slot is None :
912914 raise EnergyError ("Unable to return last known duration without any logs" )
915+
913916 last_known_timestamp = self ._logs [address ][slot ].timestamp
914917 address , slot = calc_log_address (address , slot , - 1 )
915918 while (
916919 self ._log_exists (address , slot )
917- or self ._logs [address ][slot ].timestamp == last_known_timestamp
920+ and self ._logs [address ][slot ].timestamp == last_known_timestamp
918921 ):
919922 address , slot = calc_log_address (address , slot , - 1 )
923+
920924 return self ._logs [address ][slot ].timestamp - last_known_timestamp
921925
922926 def _missing_addresses_before (
You can’t perform that action at this time.
0 commit comments