@@ -170,9 +170,8 @@ def collected_pulses(
170170 from_timestamp ,
171171 )
172172 _LOGGER .debug ("collected_pulses 1a | _log_production=%s" , self ._log_production )
173- if not is_consumption :
174- if self ._log_production is None or not self ._log_production :
175- return (None , None )
173+ if not is_consumption and not self ._log_production :
174+ return (None , None )
176175
177176 if is_consumption and self ._rollover_consumption :
178177 _LOGGER .debug ("collected_pulses 2 | %s | _rollover_consumption" , self ._mac )
@@ -425,7 +424,6 @@ def add_log(
425424 return False
426425 if address != self ._last_log_address and slot != self ._last_log_slot :
427426 return False
428- # self._update_log_direction(address, slot, timestamp)
429427 self ._update_log_references (address , slot )
430428 self ._update_log_interval ()
431429 self ._update_rollover ()
@@ -473,57 +471,13 @@ def _add_log_record(
473471 self ._last_empty_log_slot = None
474472 return True
475473
476- def _update_log_direction (
477- self , address : int , slot : int , timestamp : datetime
478- ) -> None :
479- """Update Energy direction of log record.
480-
481- Two subsequential logs with the same timestamp indicates the first
482- is consumption and second production.
483- """
484- if self ._logs is None :
485- return
486-
487- prev_address , prev_slot = calc_log_address (address , slot , - 1 )
488- if self ._log_exists (prev_address , prev_slot ):
489- if self ._logs [prev_address ][prev_slot ].timestamp == timestamp :
490- # Given log is the second log with same timestamp,
491- # mark direction as production
492- self ._logs [address ][slot ].is_consumption = False
493- self ._logs [prev_address ][prev_slot ].is_consumption = True
494- self ._log_production = True
495- elif self ._log_production :
496- self ._logs [address ][slot ].is_consumption = True
497- if self ._logs [prev_address ][prev_slot ].is_consumption :
498- self ._logs [prev_address ][prev_slot ].is_consumption = False
499- self ._reset_log_references ()
500- elif self ._log_production is None :
501- self ._log_production = False
502-
503- next_address , next_slot = calc_log_address (address , slot , 1 )
504- if self ._log_exists (next_address , next_slot ):
505- if self ._logs [next_address ][next_slot ].timestamp == timestamp :
506- # Given log is the first log with same timestamp,
507- # mark direction as production of next log
508- self ._logs [address ][slot ].is_consumption = True
509- if self ._logs [next_address ][next_slot ].is_consumption :
510- self ._logs [next_address ][next_slot ].is_consumption = False
511- self ._reset_log_references ()
512- self ._log_production = True
513- elif self ._log_production :
514- self ._logs [address ][slot ].is_consumption = False
515- self ._logs [next_address ][next_slot ].is_consumption = True
516- elif self ._log_production is None :
517- self ._log_production = False
518-
519474 def _update_log_interval (self ) -> None :
520475 """Update the detected log interval based on the most recent two logs."""
521- if self ._logs is None or self . _log_production is None :
476+ if self ._logs is None :
522477 _LOGGER .debug (
523- "_update_log_interval | %s | _logs=%s, _log_production=%s" ,
478+ "_update_log_interval fail | % s | _logs = % s ,
524479 self ._mac ,
525480 self ._logs ,
526- self ._log_production ,
527481 )
528482 return
529483
0 commit comments