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
Added support for alternate SSH ports in AsusWRT (#4832) #5198
Conversation
@swbradshaw, thanks for your PR! By analyzing the history of the files in this pull request, we identified @kellerza, @balloob and @linjef to be potential reviewers. |
@@ -16,7 +16,7 @@ | |||
|
|||
from homeassistant.components.device_tracker import ( | |||
DOMAIN, PLATFORM_SCHEMA, DeviceScanner) | |||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME | |||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, CONF_PORT |
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.
line too long (82 > 79 characters)
Travis builds are failing but in real life these tests work on actual configs. The default port config is defined at the top of the file in the PLATFORM_SCHEMA. I copied this method from usage in other files (netgear.py, cisco_ios.py, etc). This method works, but fails Travis tests. It turns out Netgear and Cisco IOS don't have tests written - otherwise they would be failing, too. Go figure. :-) So what is the correct way to write this to pass the tests? If you could point me to an example, I will correct. |
The tests are failing because of the new configuration variable. Add the |
…ation. Fixed long line
@@ -16,7 +16,8 @@ | |||
|
|||
from homeassistant.components.device_tracker import ( | |||
DOMAIN, PLATFORM_SCHEMA, DeviceScanner) | |||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME | |||
from homeassistant.const import (CONF_HOST, CONF_PASSWORD, | |||
CONF_USERNAME, CONF_PORT) |
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.
continuation line under-indented for visual indent
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.
Newline immediately after opening the bracket (
and then 4 spaces indented on next line start with first one
@swbradshaw you can run tests locally for quicker feedback. Some shortcuts for The following will show style errors (like the hound-bot) $ script/lint --changed The following will show you the first failure & what test you still need to work on $ py.test -x -k asus |
@@ -173,7 +173,7 @@ def test_ssh_login_without_password_or_pubkey(self): \ | |||
|
|||
conf_dict = { | |||
CONF_PLATFORM: 'asuswrt', | |||
CONF_HOST: 'fake_host', | |||
CONF_HOST: 'fake_host', |
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.
trailing whitespace
@@ -146,7 +146,7 @@ def test_ssh_login_with_password(self): | |||
self.addCleanup(ssh_mock.stop) | |||
conf_dict = PLATFORM_SCHEMA({ | |||
CONF_PLATFORM: 'asuswrt', | |||
CONF_HOST: 'fake_host', | |||
CONF_HOST: 'fake_host', |
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.
trailing whitespace
@@ -121,7 +121,7 @@ def test_ssh_login_with_pub_key(self): | |||
self.addCleanup(ssh_mock.stop) | |||
conf_dict = PLATFORM_SCHEMA({ | |||
CONF_PLATFORM: 'asuswrt', | |||
CONF_HOST: 'fake_host', | |||
CONF_HOST: 'fake_host', |
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.
trailing whitespace
@@ -97,7 +97,7 @@ def test_get_scanner_with_pubkey_no_password(self, asuswrt_mock): \ | |||
conf_dict = { | |||
device_tracker.DOMAIN: { | |||
CONF_PLATFORM: 'asuswrt', | |||
CONF_HOST: 'fake_host', | |||
CONF_HOST: 'fake_host', |
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.
trailing whitespace
@@ -72,7 +72,7 @@ def test_get_scanner_with_password_no_pubkey(self, asuswrt_mock): \ | |||
conf_dict = { | |||
DOMAIN: { | |||
CONF_PLATFORM: 'asuswrt', | |||
CONF_HOST: 'fake_host', | |||
CONF_HOST: 'fake_host', |
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.
trailing whitespace
elif self.password: | ||
self.ssh_secret = {'password': self.password} | ||
self.ssh_args['password'] = self.password; |
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.
statement ends with a semicolon
trailing whitespace
if self.ssh_key: | ||
self.ssh_secret = {'ssh_key': self.ssh_key} | ||
self.ssh_args['ssh_key'] = self.ssh_key; |
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.
statement ends with a semicolon
trailing whitespace
|
||
if self.port != DEFAULT_SSH_PORT: | ||
self.ssh_args['port'] = self.port | ||
|
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.
blank line contains whitespace
@kellerza Thanks for the info. Unforunately, I tried getting these tools to run on 2 different machines, and was not successful. This simple change has taken me several hours to commit. I'll get it working, but this will probably be my last contribution to the project. I don't have the time to get my dev environment working correctly to pass the CI tests :-( |
|
||
if self.protocol == 'ssh': | ||
|
||
if self.port != DEFAULT_SSH_PORT: | ||
self.ssh_args['port'] = self.port |
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.
trailing whitespace
Unfortunately my time and Python skills aren't up to completing this change. The code works but I don't have the capability to complete this to pass the CI task. Closing this request. I'll close the doc PR, too. |
Description:
My Asus router doesn't run SSH on port 22. This allows Home Assistant to work now by exposing this the SSH port as a parameter.
Related issue (if applicable): fixes #4832
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#1721
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests pass