-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Upnp properties (fix) #8294
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
Closed
Closed
Upnp properties (fix) #8294
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
df6e569
make port mapping optional
dgomes 4813a82
dependencies + improvements
dgomes 49fba3b
Added bytes and packets sensors from IGD
dgomes cec02ac
flake8 check
dgomes 60c89b4
new sensor with upnp counters
dgomes 985975d
checks
dgomes 3180c19
Merge remote-tracking branch 'home-assistant/dev' into upnp_properties
dgomes 49225ad
whitespaces in blank line
dgomes 5a3b63d
Merge remote-tracking branch 'home-assistant/dev' into upnp_properties
dgomes e12ac4e
requirements update
dgomes 9a4f395
added sensor.upnp to .coveragerc
dgomes 5fc3712
downgrade miniupnpc
dgomes c127fcc
revert to non async
dgomes 03c4507
hof hof
dgomes 626e5e4
Merge remote-tracking branch 'home-assistant/dev' into upnp_properties
dgomes 16681dc
added notification
dgomes d440771
Fixes
dgomes 3b6f451
trailing white space
dgomes bf4e611
missing loader
dgomes 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 |
|---|---|---|
|
|
@@ -25,6 +25,9 @@ | |
| CONF_ENABLE_PORT_MAPPING = 'port_mapping' | ||
| CONF_UNITS = 'unit' | ||
|
|
||
| NOTIFICATION_ID = 'upnp_notification' | ||
| NOTIFICATION_TITLE = 'UPnP Setup' | ||
|
|
||
| UNITS = { | ||
| "Bytes": 1, | ||
| "KBytes": 1024, | ||
|
|
@@ -67,13 +70,26 @@ def setup(hass, config): | |
| host = base_url.hostname | ||
| external_port = internal_port = base_url.port | ||
|
|
||
| upnp.addportmapping( | ||
| external_port, 'TCP', host, internal_port, 'Home Assistant', '') | ||
|
|
||
| def deregister_port(event): | ||
| """De-register the UPnP port mapping.""" | ||
| upnp.deleteportmapping(hass.config.api.port, 'TCP') | ||
|
|
||
| hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, deregister_port) | ||
| persistent_notification = loader.get_component('persistent_notification') | ||
|
|
||
| try: | ||
| upnp.addportmapping( | ||
| external_port, 'TCP', host, internal_port, 'Home Assistant', '') | ||
|
|
||
| def deregister_port(event): | ||
| """De-register the UPnP port mapping.""" | ||
| upnp.deleteportmapping(hass.config.api.port, 'TCP') | ||
|
|
||
| hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, deregister_port) | ||
|
|
||
| except Exception as ex: | ||
| _LOGGER.error("UPnP failed to configure port mapping: %s", str(ex)) | ||
| persistent_notification.create( | ||
|
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. undefined name 'persistent_notification' |
||
| hass, 'Port {} is already mapped,' | ||
| 'please disable port_mapping in upnp configuration section<br />' | ||
| 'You will need to restart hass after fixing.' | ||
| ''.format(external_port), | ||
| title=NOTIFICATION_TITLE, | ||
| notification_id=NOTIFICATION_ID) | ||
| return False | ||
|
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. trailing whitespace |
||
| return True | ||
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.
undefined name 'loader'