Skip to content

Improve netgear_lte logging when unconnected#18163

Merged
MartinHjelmare merged 2 commits intohome-assistant:devfrom
amelchio:netgear-retry-log-once
Nov 4, 2018
Merged

Improve netgear_lte logging when unconnected#18163
MartinHjelmare merged 2 commits intohome-assistant:devfrom
amelchio:netgear-retry-log-once

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

@amelchio amelchio commented Nov 3, 2018

Description:

  • Log a single time on lost/resumed connection.
  • Use a single task for startup retries and cancel it during shutdown (avoids an error log).
  • Only log a single time when the connection is retried during startup.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Two possible changes.

self.unread_count = sum(1 for x in information.sms if x.unread)
self.usage = information.usage
if not self.connected:
_LOGGER.warning("Connected to %s", self.host)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe info level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should match the warnings for lost connections so it is clear that the problem is resolved even if the log file filters out info level logs.

(Note that it does not print during normal startup, only after connection failures.)

retry_task = hass.loop.create_task(
_retry_login(hass, modem_data, password))

async def cleanup_retry(event):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a callback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I changed that.

@MartinHjelmare MartinHjelmare merged commit 164c680 into home-assistant:dev Nov 4, 2018
@ghost ghost removed the in progress label Nov 4, 2018
@balloob balloob mentioned this pull request Nov 29, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants