Skip to content
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

Issue Unlocking/Locking After Newest HA Update #14

Closed
Palmer-Pesta opened this issue Feb 2, 2023 · 19 comments
Closed

Issue Unlocking/Locking After Newest HA Update #14

Palmer-Pesta opened this issue Feb 2, 2023 · 19 comments
Assignees

Comments

@Palmer-Pesta
Copy link

Palmer-Pesta commented Feb 2, 2023

First, I want to say great job on this integration; I use it a lot.

Recently I've hit this stack trace when trying to lock/unlock. Everything else works, and I've tried to uninstall, wipe pvcs, etc.

Logger: homeassistant.components.websocket_api.http.connection
Source: components/lock/__init__.py:95
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 6:43:27 PM (1 occurrences)
Last logged: 6:43:27 PM

SmartrentLock.async_lock() got an unexpected keyword argument 'entity_id'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 681, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 721, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 95, in _async_lock
    await entity.async_lock(**service_call.data)
TypeError: SmartrentLock.async_lock() got an unexpected keyword argument 'entity_id'
@Palmer-Pesta
Copy link
Author

Note: After looking at breaking changes, it might be the upgrade to python 3.9 -> 3.10.

@tjleach98
Copy link

I also had this problem and it seems to be async_lock and async_unlock should be accepting arguments but currently are not. I made a small change and now the locks are working. I don't know a lot about this system, but I am basing it off this change I saw in the Home Assistant Core repo.

---     async def async_lock(self):
+++     async def async_lock(self, **kwargs):

---     async def async_unlock(self):
+++     async def async_unlock(self, **kwargs):

@ZacheryThomas ZacheryThomas self-assigned this Feb 3, 2023
@ZacheryThomas
Copy link
Owner

Hi @Palmer-Pesta! Glad to hear this integration is working out for you!

Guess you saw my latest release. Low key I haven't updated my HA instance yet & make sure everything works out there but i'm guessing its all good since the issue is closed! Let me know if theres any other issues in general though

Also thanks for the help @tjleach98!

@Palmer-Pesta
Copy link
Author

This error originated from a custom integration.

Logger: homeassistant.loader
Source: custom_components/smartrent/lock.py:63
Integration: SmartRent (documentation, issues)
First occurred: 3:01:20 PM (2 occurrences)
Last logged: 3:04:30 PM

Unexpected exception importing platform custom_components.smartrent.lock
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 749, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 766, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/smartrent/lock.py", line 22, in <module>
    class SmartrentLock(LockEntity):
  File "/config/custom_components/smartrent/lock.py", line 63, in SmartrentLock
    async def async_lock(self, **kwargs: Any):
NameError: name 'Any' is not defined

@Palmer-Pesta Palmer-Pesta reopened this Feb 3, 2023
@Palmer-Pesta
Copy link
Author

Palmer-Pesta commented Feb 3, 2023

Apologies, I might have too hastefully resolved this issue. It looks like it is now rejecting the Any keyword.

@Palmer-Pesta
Copy link
Author

Palmer-Pesta commented Feb 3, 2023

---     async def async_lock(self, **kwargs: Any):
+++  async def async_lock(self, **kwargs):

---    async def async_unlock(self, **kwargs: Any):
+++ async def async_unlock(self, **kwargs):

Please note I made the following changes and the integration works again.

@anthonymkz
Copy link

Since upgrading not only does my lock not work, but it can't even be set up. Please help!

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 749, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 766, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/config/custom_components/smartrent/lock.py", line 22, in
class SmartrentLock(LockEntity):
File "/config/custom_components/smartrent/lock.py", line 63, in SmartrentLock
async def async_lock(self, **kwargs: Any):
NameError: name 'Any' is not defined
2023-02-04 11:02:50.097 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform smartrent.lock: Platform not found (Exception importing custom_components.smartrent.lock).
2023-02-04 11:02:56.630 WARNING (MainThread) [homeassistant.components.media_player] Setup of media_player platform dlna_dmr is taking over 10 seconds.
2023-02-04 11:02:56.631 WARNING (MainThread) [homeassistant.components.media_player] Setup of media_player platform dlna_dmr is taking over 10 seconds.
2023-02-04 11:06:43.274 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities lock.front_door_lock or it is/they are currently not available
2023-02-04 11:06:44.290 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities lock.front_door_lock or it is/they are currently not available
2023-02-04 11:06:44.455 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities lock.front_door_lock or it is/they are currently not available
2023-02-04 11:06:44.598 WARNING (MainThread) [homeassistant.helpers.service] Unable to find referenced entities lock.front_door_lock or it is/they are currently not available

@Palmer-Pesta
Copy link
Author

Same issue as above. You can edit the code by control + f to find it in vscode (under custom_components) and remove the : Any. Note: you will then need to remove the device integration and readd it. Don't redownload or uninstall in hacs only the HA devices page. Or just wait until a new release of this library is published.

@ZacheryThomas
Copy link
Owner

ZacheryThomas commented Feb 4, 2023

Sorry ya'll! I just pushed out a new release. Should restore the functionality of the locks.

I was able to update my HA instance to latest and test it there too. So the original issue should be fixed as well.

Let me know if anything else is goin wrong and I can take a look at things

@Palmer-Pesta
Copy link
Author

Confirmed that these changes worked. Closing the issue now. Thanks for your help, Zach!

@ZacheryThomas
Copy link
Owner

It's no problem! Thanks for the great feedback & helping me test out stuff!

@yousefmansy1
Copy link

Sorry for noob question, but I am also having this same issue.
I've deleted and reinstalled the integration, and my Home assistant is up to date (2023.2.3)

Yet I get the following error when triggering lock/unlock from the frontend:

Failed to call service lock/lock. SmartrentLock.async_lock() got an unexpected keyword argument 'entity_id'

@ZacheryThomas
Copy link
Owner

ZacheryThomas commented Feb 9, 2023

@yousefmansy1 after you reinstalled the SmartRent integration have you restarted your Homeassistant instance?

@yousefmansy1
Copy link

Yes I have restarted my HA instance.

Is there a way to validate the version of the plug in I'm using?

@ZacheryThomas
Copy link
Owner

Im actually not sure if theres a way to view the info reliably with the UI 🤔

But if you have command line access you can output some information that contains the version number for the integration.
You should be able to navigate to wherever homeassistant stores config and then view the file in custom_components/smartrent/manifest.json

$ cat config/custom_components/smartrent/manifest.json
{
  "domain": "smartrent",
  "name": "SmartRent",
  "documentation": "https://github.com/ZacheryThomas/homeassistant-smartrent",
  "issue_tracker": "https://github.com/ZacheryThomas/homeassistant-smartrent/issues",
  "dependencies": [],
  "codeowners": ["@zacherythomas"],
  "config_flow": true,
  "requirements": ["smartrent.py==0.3.1"],
  "iot_class": "cloud_push",
  "version": "0.3.5"
}

@yousefmansy1
Copy link

yousefmansy1 commented Feb 10, 2023

Yep that looks to be the issue.
Despite reinstalling, I'm somehow on 0.3.2

{
  "domain": "smartrent",
  "name": "SmartRent",
  "documentation": "https://github.com/ZacheryThomas/homeassistant-smartrent",
  "issue_tracker": "https://github.com/ZacheryThomas/homeassistant-smartrent/issues",
  "dependencies": [],
  "codeowners": ["@zacherythomas"],
  "config_flow": true,
  "requirements": ["smartrent.py==0.3.0"],
  "iot_class": "cloud_push",
  "version": "0.3.2"
}

So pt2 of noob question, how can I ensure I'm installing the latest version of an integration?
I'm using the web interface but perhaps there's a better way?

@ZacheryThomas
Copy link
Owner

ZacheryThomas commented Feb 11, 2023

@yousefmansy1 what normally works for me is when you are on the HACS page for Smartrent is clicking:

  • Update Information
  • Redownload
  • And then restart homeassistant

image

If thats not working at all you can delete your custom-component/smartrent directory and then install things manually. You can download the code as a zip file, unzip it then move the content from my repos homeassistant-smartrent/custom-component/smartrent into the right location in your HA instance

Here is some more info about that method:
https://github.com/ZacheryThomas/homeassistant-smartrent#installing-manually

@yousefmansy1
Copy link

I had a major brain fart, I forgot about the HACS store showing its own updates.
It updated perfectly through there and my lock integration works perfectly fine now.

Thanks!

@ZacheryThomas
Copy link
Owner

haha no problem!! Glad you got everything working out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants