Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brother Integration not initializing, stopping HA 2024.3 from fully starting #112568

Closed
Max6993109 opened this issue Mar 7, 2024 · 28 comments · Fixed by #113235
Closed

Brother Integration not initializing, stopping HA 2024.3 from fully starting #112568

Max6993109 opened this issue Mar 7, 2024 · 28 comments · Fixed by #113235

Comments

@Max6993109
Copy link

The problem

Updated to 2024.3. Everything works well, except for my Brother integration not finalizing the initializing phase. This stops Home Assistant from fully starting when it boots up. Can’t ask it to reboot. Have to delete or disable the Brother integration and shut down my entire VM to get Home Assistant to fully start

What version of Home Assistant Core has the issue?

core-2024.3

What was the last working version of Home Assistant Core?

core-2024.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Brother

Link to integration documentation on our website

https://www.home-assistant.io/integrations/brother/

Diagnostics information

Updated to 2024.3. Everything works well, except for my Brother integration not finalizing the initializing phase. This stops Home Assistant from fully starting when it boots up. Can’t ask it to reboot. Have to delete or disable the Brother integration and shut down my entire VM to get Home Assistant to fully start

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Mar 7, 2024

Hey there @bieniu, mind taking a look at this issue as it has been labeled with an integration (brother) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of brother can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign brother Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


brother documentation
brother source
(message by IssueLinks)

@balloob balloob added this to the 2024.3.1 milestone Mar 7, 2024
@bieniu
Copy link
Member

bieniu commented Mar 7, 2024

Please attach the log.

@alsFC
Copy link

alsFC commented Mar 7, 2024

Seems that it's only blocking when the printer is unavailable. I attached a Debug-Log from reloading the integration while my printer was off power.
home-assistant_brother_2024-03-07T10-01-37.891Z.log

@holdestmade
Copy link

I noticed this in the beta that it blocks for 3-4 minutes if the printer is powered off. As soon as the printer is powered on, it starts up as normal.

@bieniu bieniu changed the title HA 2024.3 Bug - Brother Integration not initializing, stopping HA from fully starting Brother Integration not initializing, stopping HA 2024.3 from fully starting Mar 8, 2024
@bieniu
Copy link
Member

bieniu commented Mar 8, 2024

I cannot reproduce this problem either on 2024.3.0 or on the dev branch:

2024-03-08 13:56:03.857 DEBUG (MainThread) [homeassistant.components.brother.utils] Creating SNMP engine
2024-03-08 13:56:03.910 DEBUG (MainThread) [brother] Initializing device 192.168.32.2
2024-03-08 13:56:46.587 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 20.001 seconds (success: False)
2024-03-08 13:56:46.603 DEBUG (MainThread) [brother] Initializing device 192.168.32.2
2024-03-08 13:57:28.268 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 20.002 seconds (success: False)
2024-03-08 13:42:27.160 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 20.002 seconds (success: False)
2024-03-08 13:42:37.603 DEBUG (MainThread) [brother] Initializing device 192.168.3.12

@holdestmade
Copy link

Just tried again. As I said above, if I power off (not just sleep) the printer it blocks the startup of HA for 4 minutes

Logger: homeassistant.config_entries
Source: config_entries.py:504
First occurred: 1:07:38 pm (1 occurrences)
Last logged: 1:07:38 pm

Error setting up entry HL-L3230CDW E79010G3N126434 for brother
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/brother/__init__.py", line 33, in async_setup_entry
    brother = await Brother.create(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 114, in create
    await instance.initialize()
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 139, in initialize
    get_result = await hlapi.getCmd(*request_args, *oids)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/cmdgen.py", line 175, in getCmd
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError: Global task timeout
Logger: homeassistant.bootstrap
Source: bootstrap.py:841
First occurred: 1:07:38 pm (1 occurrences)
Last logged: 1:07:38 pm

Setup timed out for stage 2 - moving forward

@bieniu
Copy link
Member

bieniu commented Mar 8, 2024

My printer was also turned off (power cut off) during the test.

Please enable debugging for the Brother integration, restart HA and wait for HA to fully start, then attach the log file here.

@holdestmade
Copy link

Not much extra with homeassistant.components.brother: debug on, relevant lines from log


2024-03-08 14:16:57.079 DEBUG (MainThread) [homeassistant.components.brother.utils] Creating SNMP engine
2024-03-08 14:17:07.538 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2024-03-08 14:18:22.043 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: brother
2024-03-08 14:19:22.101 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: brother
2024-03-08 14:20:25.363 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: brother
2024-03-08 14:21:25.592 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: brother
2024-03-08 14:21:53.480 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry HL-L3230CDW E79010G3N126434 for brother
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/brother/__init__.py", line 33, in async_setup_entry
    brother = await Brother.create(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 114, in create
    await instance.initialize()
  File "/usr/local/lib/python3.12/site-packages/brother/__init__.py", line 139, in initialize
    get_result = await hlapi.getCmd(*request_args, *oids)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pysnmp/hlapi/asyncio/cmdgen.py", line 175, in getCmd
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError: Global task timeout
2024-03-08 14:21:53.492 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward

@holdestmade
Copy link

holdestmade commented Mar 8, 2024

And this is with the printer powered on

2024-03-08 14:28:49.417 DEBUG (MainThread) [homeassistant.components.brother.utils] Creating SNMP engine
2024-03-08 14:28:56.969 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session
2024-03-08 14:28:58.826 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 1.403 seconds (success: True)


2024-03-08 14:29:28.683 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.174 seconds (success: True)
2024-03-08 14:29:58.619 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.116 seconds (success: True)
2024-03-08 14:30:28.533 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.031 seconds (success: True)
2024-03-08 14:30:58.581 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.034 seconds (success: True)
2024-03-08 14:31:28.555 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.053 seconds (success: True)
2024-03-08 14:31:58.560 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.057 seconds (success: True)
2024-03-08 14:32:28.554 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.051 seconds (success: True)
2024-03-08 14:32:58.576 DEBUG (MainThread) [homeassistant.components.brother] Finished fetching brother data in 0.073 seconds (success: True)

@bieniu
Copy link
Member

bieniu commented Mar 8, 2024

Not much extra with homeassistant.components.brother: debug on, relevant lines from log

I think you forgot to attach the log file.

@holdestmade
Copy link

I copied all that was relevant, just a few extra bits from other components, nothing extra with "brother"

@bieniu
Copy link
Member

bieniu commented Mar 8, 2024

I asked you to attach a log file, the whole file, not a tiny fragment. Since your system behaves differently from my dev environment, we must first understand why this is happening. Without this, we will wander in the dark.
Please also attach a diagnostic file for brother integration, you have to turn on your printer to allow the integration to be initialized before you can get the diagnostic file.

@bieniu
Copy link
Member

bieniu commented Mar 9, 2024

home-assistant_brother_2024-03-08T16-37-57.367Z.log

What happened next? Does the integration retry initialization? Once again, I'm asking for the diagnostics file.

@holdestmade
Copy link

No, it doesn't try again. If I turn on the printer, and reload the integration it works fine again

The logs above are the ones that are created when I turn off debug logging in the integration page.

Not sure where the diagnostic file is ?

@bieniu
Copy link
Member

bieniu commented Mar 10, 2024

Not sure where the diagnostic file is ?

image

@holdestmade
Copy link

Strange, I don't have that option

image

@bieniu
Copy link
Member

bieniu commented Mar 10, 2024

This will be available only after proper initialization of integration (the printer should be online).

@holdestmade
Copy link

I restarted HA and it was there, see attached
config_entry-brother-794ce6f44d60e59193b6b007c5f7694b.json

@bieniu
Copy link
Member

bieniu commented Mar 10, 2024

Could you disable all custom components and restart HA while the printer is offline?

@HA-TB303
Copy link

I have the same issue, but only when the printer is offline. It then takes freaking ages for HA to fully startup, waiting for the Brother printer integration. Seems like this could be "fixed" by at least creating a timeout.

@bieniu
Copy link
Member

bieniu commented Mar 12, 2024

As I cannot reproduce this problem in my environment, I'm asking for help in testing the fix. Please unpack the attached ZIP file, copy the brother folder to /config/custom_components and restart HA when the printer is offline.

brother_timeout.zip

@HA-TB303
Copy link

CleanShot 2024-03-13 at 08 15 26

@bieniu
Copy link
Member

bieniu commented Mar 13, 2024

Link to the file updated.

@HA-TB303
Copy link

Could you disable all custom components and restart HA while the printer is offline?

I can confirm this issue does not occur with this custom version.

@frenck frenck removed this from the 2024.3.1 milestone Mar 13, 2024
@Max6993109
Copy link
Author

Hello @bieniu,

I added the folder to /config/custom_components in HA. HA loads pretty fast with no issues, but I do get an error whenever I reboot (see attached screenshots and log)
Brother Log Screenshot
Brother Screenshot
home-assistant_2024-03-13T17-31-39.125Z.log

@bieniu
Copy link
Member

bieniu commented Mar 13, 2024

The change has been merged and the branch is not available. You have to remove folder with a custom brother and wait for 2024.3.1 release.

@Max6993109
Copy link
Author

Got you. Thanks for the update @bieniu

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants