icloud3 icon indicating copy to clipboard operation
icloud3 copied to clipboard

UnboundLocalError: cannot access local variable 'event_recd' where it is not associated with a value in post_event

Open ehendrix23 opened this issue 1 month ago • 2 comments

Seeing the following errors within Home Assistant log file:

2024-05-15 10:22:15.367 ERROR (SyncWorker_57) [custom_components.icloud3] cannot access local variable 'event_recd' where it is not associated with a value Traceback (most recent call last): File "/config/custom_components/icloud3/support/event_log.py", line 368, in post_event or event_recd[ELR_TEXT].startswith(EVLOG_ALERT)): ^^^^^^^^^^ UnboundLocalError: cannot access local variable 'event_recd' where it is not associated with a value

I'm on version 3.0.4 with HASS 2024.5.3.

This is in code:

` if len(event_text) > MAX_EVLOG_RECD_LENGTH: self._break_up_event_text(devicename, this_update_time, event_text, MAX_EVLOG_RECD_LENGTH) else: event_recd = [devicename, this_update_time, event_text]

            self._add_recd_to_event_recds(event_recd)

        if (self.startup_event_save_recd_flag
                or event_recd[ELR_TEXT].startswith(EVLOG_ALERT)):
            self._save_startup_log_recd(Device, event_recd)

`

I'm wondering if the following piece should be under that else as well as event_recd only seems to be set there within this function. if (self.startup_event_save_recd_flag or event_recd[ELR_TEXT].startswith(EVLOG_ALERT)): self._save_startup_log_recd(Device, event_recd)

Or by having _break_up_event_text return event_recd allowing it then to be set as well.

ehendrix23 avatar May 15 '24 17:05 ehendrix23