-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Add Fritz services #50056
Add Fritz services #50056
Conversation
Hey there @mammuth, @AaronDavidSchneider, mind taking a look at this pull request as its been labeled with an integration ( |
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.
Works well! I think I would change the way how entities and devices are linked to fritzbox_tools.
Also: We need to handle those devices that have no way of reconnecting.
This is what I get if I reconnect a router that is connected as a repeater:
2021-05-04 09:19:34 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/schneider/codes/personal/hass/venv/lib/python3.9/site-packages/fritzconnection/core/fritzconnection.py", line 233, in reconnect
self.call_action("WANIPConn1", "ForceTermination")
File "/Users/schneider/codes/personal/hass/venv/lib/python3.9/site-packages/fritzconnection/core/fritzconnection.py", line 227, in call_action
return self.soaper.execute(service, action_name, arguments)
File "/Users/schneider/codes/personal/hass/venv/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 238, in execute
return handle_response(response)
File "/Users/schneider/codes/personal/hass/venv/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 222, in handle_response
raise_fritzconnection_error(response)
File "/Users/schneider/codes/personal/hass/venv/lib/python3.9/site-packages/fritzconnection/core/soaper.py", line 147, in raise_fritzconnection_error
raise exception(message)
fritzconnection.core.exceptions.FritzConnectionException: UPnPError:
errorCode: 403
errorDescription: Not available Action
I would expect a different error in such cases: |
Updated documentation: https://fritzconnection.readthedocs.io/en/1.2.1/sources/introduction.html#module-usage |
Should be fixed now, please retest. Simone |
target: | ||
entity: | ||
integration: fritz | ||
domain: binary_sensor |
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.
If the goal is to target the binary sensor entities, register these as entity services
https://developers.home-assistant.io/docs/dev_101_services/#entity-services
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.
The idea was to target only a device, but didn't find a way to filter out all entities from GUI.
So I choice to filter by binary sensor and allow both to work ( device and entity).
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.
works as expected
2305cdc
to
a4e59cb
Compare
f"Failed to call service '{service_call.service}'. Config entry for target not found" | ||
) | ||
|
||
for entry in fritzbox_entry_ids: |
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.
Should we use asyncio.gather here?
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.
Actually no since it's generating executor jobs.
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.
We would save some context switches if we would wrap the iteration inside a function and make the service helper sync.
Since this merge mypy check fail -> https://github.com/home-assistant/core/runs/2559970649
|
That's probably because of conflict between this and #50327 @chemelli74 @bdraco can you please fix it? I wish github had merge-time checks against current master 😕 |
This PR adds services, but is missing a documentation PR to document these. This PR should not have been merged without those. @chemelli74 Please open up a documentation PR. Thanks 👍 |
|
||
async def async_setup_services(hass: HomeAssistant): | ||
"""Set up services for Fritz integration.""" | ||
if hass.data.get(FRITZ_SERVICES, False): |
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.
We have hass.services.has_service
that could be used instead.
|
||
for entry in fritzbox_entry_ids: | ||
_LOGGER.debug("Executing service %s", service_call.service) | ||
fritz_tools = hass.data[DOMAIN].get(entry) |
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.
We don't check for None
below. If that's not needed we should use dict[key]
instead of dict.get(key)
.
Proposed change
Add reconnect and reboot services for Fritz devices.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: