8000 fix for LocationParseError in netgear platform by etsinko · Pull Request #9683 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix for LocationParseError in netgear platform #9683

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

Merged
merged 10 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions homeassistant/components/device_tracker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
from homeassistant.core import callback
from homeassistant.loader import bind_hass
from homeassistant.components import group, zone
from homeassistant.components.discovery import SERVICE_NETGEAR
from homeassistant.config import load_yaml_config_file, async_log_exception
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers import config_per_platform, discovery
from homeassistant.helpers import config_per_platform
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.restore_state import async_get_last_state
Expand Down Expand Up @@ -89,10 +88,6 @@
cv.time_period, cv.positive_timedelta)
})

DISCOVERY_PLATFORMS = {
SERVICE_NETGEAR: 'netgear',
}


@bind_hass
def is_on(hass: HomeAssistantType, entity_id: str=None):
Expand Down Expand Up @@ -180,22 +175,6 @@ def async_setup_platform(p_type, p_config, disc_info=None):

tracker.async_setup_group()

@callback
def async_device_tracker_discovered(service, info):
"""Handle the discovery of device tracker platforms."""
hass.async_add_job(
async_setup_platform(DISCOVERY_PLATFORMS[service], {}, info))

discovery.async_listen(
hass, DISCOVERY_PLATFORMS.keys(), async_device_tracker_discovered)

@asyncio.coroutine
def async_platform_discovered(platform, info):
Copy link
Member

Choose a reason for hiding this comment

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

This is still needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MartinHjelmare I think async_device_tracker_discovered() is not needed, because it was only used by netgear platform. What should be returned is async_platform_discovered()

Copy link
Member
@MartinHjelmare MartinHjelmare Oct 27, 2017

Choose a reason for hiding this comment

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

Yes, only add the code that starts on the lines where my comment starts, eg here that's 193. I haven't marked the import that's needed btw.

"""Load a platform."""
yield from async_setup_platform(platform, {}, disc_info=info)

discovery.async_listen_platform(hass, DOMAIN, async_platform_discovered)
Copy link
Member

Choose a reason for hiding this comment

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

This is still needed for general platform discovery to work.


# Clean up stale devices
async_track_utc_time_change(
hass, tracker.async_update_stale, second=range(0, 60, 5))
Expand Down
33 changes: 1 addition & 32 deletions tests/components/device_tracker/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from homeassistant.components import zone
from homeassistant.core import callback, State
from homeassistant.setup import setup_component
from homeassistant.helpers import discovery
from homeassistant.loader import get_component
from homeassistant.util.async import run_coroutine_threadsafe
import homeassistant.util.dt as dt_util
Expand All @@ -23,7 +22,7 @@
from homeassistant.remote import JSONEncoder

from tests.common import (
get_test_home_assistant, fire_time_changed, fire_service_discovered,
get_test_home_assistant, fire_time_changed,
patch_yaml_files, assert_setup_component, mock_restore_cache, mock_coro)

from ...test_util.aiohttp import mock_aiohttp_client
Expand Down Expand Up @@ -311,36 +310,6 @@ def test_mac_vendor_lookup_on_see(self):
'No http request for macvendor made!'
self.assertEqual(tracker.devices['b827eb000000'].vendor, vendor_string)

def test_discovery(self):
"""Test discovery."""
scanner = get_component('device_tracker.test').SCANNER

with patch.dict(device_tracker.DISCOVERY_PLATFORMS, {'test': 'test'}):
with patch.object(scanner, 'scan_devices',
autospec=True) as mock_scan:
with assert_setup_component(1, device_tracker.DOMAIN):
assert setup_component(
self.hass, device_tracker.DOMAIN, TEST_PLATFORM)
fire_service_discovered(self.hass, 'test', {})
self.assertTrue(mock_scan.called)

@patch(
'homeassistant.components.device_tracker.DeviceTracker.see')
@patch(
'homeassistant.components.device_tracker.demo.setup_scanner',
autospec=True)
def test_discover_platform(self, mock_demo_setup_scanner, mock_see):
Copy link
Member

Choose a reason for hiding this comment

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

This test should be kept.

"""Test discovery of device_tracker demo platform."""
assert device_tracker.DOMAIN not in self.hass.config.components
discovery.load_platform(
self.hass, device_tracker.DOMAIN, 'demo', {'test_key': 'test_val'},
{})
self.hass.block_till_done()
assert device_tracker.DOMAIN in self.hass.config.components
assert mock_demo_setup_scanner.called
assert mock_demo_setup_scanner.call_args[0] == (
self.hass, {}, mock_see, {'test_key': 'test_val'})

def test_update_stale(self):
"""Test stalled update."""
scanner = get_component('device_tracker.test').SCANNER
Expand Down
0