-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Fix insteon Hub v1 support #16472
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
+28
−14
Merged
Fix insteon Hub v1 support #16472
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c23daa2
Fix support for Hub version 1 (i.e. pre-2014 Hub model 2242)
teharris1 ef43789
Bump insteonplm to 0.14.1
teharris1 afdab29
Code review changes
teharris1 043860c
Clean up and better document set_default_port
teharris1 482c306
Simplify set_default_port based on code review
teharris1 a0ae438
Remove Callable type import
teharris1 70a3c5b
Simplify port setup
teharris1 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 |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| import asyncio | ||
| import collections | ||
| import logging | ||
| from typing import Callable, Dict | ||
|
|
||
| import voluptuous as vol | ||
|
|
||
| from homeassistant.core import callback | ||
|
|
@@ -18,7 +20,7 @@ | |
| from homeassistant.helpers import discovery | ||
| from homeassistant.helpers.entity import Entity | ||
|
|
||
| REQUIREMENTS = ['insteonplm==0.13.1'] | ||
| REQUIREMENTS = ['insteonplm==0.14.2'] | ||
|
|
||
| _LOGGER = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -27,9 +29,9 @@ | |
| CONF_IP_PORT = 'ip_port' | ||
| CONF_HUB_USERNAME = 'username' | ||
| CONF_HUB_PASSWORD = 'password' | ||
| CONF_HUB_VERSION = 'hub_version' | ||
| CONF_OVERRIDE = 'device_override' | ||
| CONF_PLM_HUB_MSG = ('Must configure either a PLM port or a Hub host, username ' | ||
| 'and password') | ||
| CONF_PLM_HUB_MSG = 'Must configure either a PLM port or a Hub host' | ||
| CONF_ADDRESS = 'address' | ||
| CONF_CAT = 'cat' | ||
| CONF_SUBCAT = 'subcat' | ||
|
|
@@ -66,6 +68,22 @@ | |
| EVENT_BUTTON_OFF = 'insteon.button_off' | ||
| EVENT_CONF_BUTTON = 'button' | ||
|
|
||
|
|
||
| def set_default_port(schema: Dict) -> Dict: | ||
| """Set the default port based on the Hub version.""" | ||
| # If the ip_port is found do nothing | ||
| # If it is not found the set the default | ||
| ip_port = schema.get(CONF_IP_PORT) | ||
| if not ip_port: | ||
| hub_version = schema.get(CONF_HUB_VERSION) | ||
| # Found hub_version but not ip_port | ||
| if hub_version == 1: | ||
| schema[CONF_IP_PORT] = 9761 | ||
| elif not ip_port: | ||
|
Member
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.
|
||
| schema[CONF_IP_PORT] = 25105 | ||
| return schema | ||
|
|
||
|
|
||
| CONF_DEVICE_OVERRIDE_SCHEMA = vol.All( | ||
| cv.deprecated(CONF_PLATFORM), vol.Schema({ | ||
| vol.Required(CONF_ADDRESS): cv.string, | ||
|
|
@@ -88,12 +106,13 @@ | |
| DOMAIN: vol.All( | ||
| vol.Schema( | ||
| {vol.Exclusive(CONF_PORT, 'plm_or_hub', | ||
| msg=CONF_PLM_HUB_MSG): cv.isdevice, | ||
| msg=CONF_PLM_HUB_MSG): cv.string, | ||
| vol.Exclusive(CONF_HOST, 'plm_or_hub', | ||
| msg=CONF_PLM_HUB_MSG): cv.string, | ||
| vol.Optional(CONF_IP_PORT, default=25105): int, | ||
| vol.Optional(CONF_IP_PORT): int, | ||
|
Member
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. Use |
||
| vol.Optional(CONF_HUB_USERNAME): cv.string, | ||
| vol.Optional(CONF_HUB_PASSWORD): cv.string, | ||
| vol.Optional(CONF_HUB_VERSION, default=2): vol.In([1, 2]), | ||
| vol.Optional(CONF_OVERRIDE): vol.All( | ||
| cv.ensure_list_csv, [CONF_DEVICE_OVERRIDE_SCHEMA]), | ||
| vol.Optional(CONF_X10_ALL_UNITS_OFF): vol.In(HOUSECODES), | ||
|
|
@@ -103,14 +122,7 @@ | |
| [CONF_X10_SCHEMA]) | ||
| }, extra=vol.ALLOW_EXTRA, required=True), | ||
| cv.has_at_least_one_key(CONF_PORT, CONF_HOST), | ||
| vol.Schema( | ||
| {vol.Inclusive(CONF_HOST, 'hub', | ||
| msg=CONF_PLM_HUB_MSG): cv.string, | ||
| vol.Inclusive(CONF_HUB_USERNAME, 'hub', | ||
| msg=CONF_PLM_HUB_MSG): cv.string, | ||
| vol.Inclusive(CONF_HUB_PASSWORD, 'hub', | ||
| msg=CONF_PLM_HUB_MSG): cv.string, | ||
| }, extra=vol.ALLOW_EXTRA, required=True)) | ||
| set_default_port) | ||
| }, extra=vol.ALLOW_EXTRA) | ||
|
|
||
|
|
||
|
|
@@ -151,6 +163,7 @@ def async_setup(hass, config): | |
| ip_port = conf.get(CONF_IP_PORT) | ||
| username = conf.get(CONF_HUB_USERNAME) | ||
| password = conf.get(CONF_HUB_PASSWORD) | ||
| hub_version = conf.get(CONF_HUB_VERSION) | ||
| overrides = conf.get(CONF_OVERRIDE, []) | ||
| x10_devices = conf.get(CONF_X10, []) | ||
| x10_all_units_off_housecode = conf.get(CONF_X10_ALL_UNITS_OFF) | ||
|
|
@@ -284,6 +297,7 @@ def _fire_button_on_off_event(address, group, val): | |
| port=ip_port, | ||
| username=username, | ||
| password=password, | ||
| hub_version=hub_version, | ||
| loop=hass.loop, | ||
| workdir=hass.config.config_dir) | ||
| else: | ||
|
|
||
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
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.
'typing.Callable' imported but unused