-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1d29c6b
fix for LocationParseError in netgear platform
etsinko 03e3e97
added unit tests for get_scanner()
etsinko 52655a5
fixed houndci-bot warnings
etsinko bcdc9be
fixed lint warnings
etsinko 96953f0
fixed lint warnings
etsinko cf99d64
fixed broken test
etsinko 5d4d4b5
removed guard clause from netgear.py
etsinko f51fa0b
removed discovery related tests
etsinko a3c81fa
removed unused import
etsinko d22b8ed
removed unused import
etsinko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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): | ||
|
@@ -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): | ||
"""Load a platform.""" | ||
yield from async_setup_platform(platform, {}, disc_info=info) | ||
|
||
discovery.async_listen_platform(hass, DOMAIN, async_platform_discovered) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still needed.
There was a problem hiding this comment.
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 bynetgear
platform. What should be returned isasync_platform_discovered()
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.