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

Fix errors if rest source becomes unavailable #24986

Merged
merged 2 commits into from
Jul 6, 2019
Merged

Fix errors if rest source becomes unavailable #24986

merged 2 commits into from
Jul 6, 2019

Conversation

slackr31337
Copy link
Contributor

Description:

Fixes errors when rest URL becomes unavailable

Example:
Jul 06 10:39:32 home-assistant hass[346193]: 2019-07-06 10:39:32 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.brayden_tv_source fails
Jul 06 10:39:32 home-assistant hass[346193]: Traceback (most recent call last):
Jul 06 10:39:32 home-assistant hass[346193]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
Jul 06 10:39:32 home-assistant hass[346193]: await self.async_device_update()
Jul 06 10:39:32 home-assistant hass[346193]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 377, in async_device_update
Jul 06 10:39:32 home-assistant hass[346193]: await self.hass.async_add_executor_job(self.update)
Jul 06 10:39:32 home-assistant hass[346193]: File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Jul 06 10:39:32 home-assistant hass[346193]: result = self.fn(*self.args, **self.kwargs)
Jul 06 10:39:32 home-assistant hass[346193]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/scrape/sensor.py", line 115, in update
Jul 06 10:39:32 home-assistant hass[346193]: raw_data = BeautifulSoup(self.rest.data, 'html.parser')
Jul 06 10:39:32 home-assistant hass[346193]: File "/srv/homeassistant/lib/python3.7/site-packages/bs4/init.py", line 245, in init
Jul 06 10:39:32 home-assistant hass[346193]: elif len(markup) <= 256 and (
Jul 06 10:39:32 home-assistant hass[346193]: TypeError: object of type 'NoneType' has no len()

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

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

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@slackr31337 slackr31337 requested a review from fabaff as a code owner July 6, 2019 14:58
@ghost ghost assigned fabaff Jul 6, 2019
@ghost
Copy link

ghost commented Jul 6, 2019

Hey there @fabaff, mind taking a look at this pull request as its been labeled with a integration (scrape) you are listed as a codeowner for? Thanks!

This is a automatic comment generated by codeowners-mention to help ensure issues and pull requests are seen by the right people.

@pvizeli pvizeli merged commit 003ca65 into home-assistant:dev Jul 6, 2019
@lock lock bot locked and limited conversation to collaborators Jul 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants