core icon indicating copy to clipboard operation
core copied to clipboard

surepetcare - cat flap: "ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY"

Open Stono opened this issue 1 year ago • 21 comments

The problem

This integration has suddenly become rather flakey; it had been working fine until recently (last 2 days) where it's been failing.

The error doesn't give much away unfortunately:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/script/__init__.py", line 594, in _async_run
    return await self.script.async_run(script_vars, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 951, in _async_if_step
    await self._async_run_script(if_data["if_then"])
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 1069, in _async_run_script
    await self._async_run_long_action(
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 1578, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/script.py", line 720, in _async_device_step
    await device_action.async_call_action_from_config(
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config
    await platform.async_call_action_from_config(hass, config, variables, context)
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/lock/device_action.py", line 88, in async_call_action_from_config
    await hass.services.async_call(
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/core.py", line 2072, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/service.py", line 876, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/lock/__init__.py", line 99, in _async_lock
    await entity.async_lock(**remove_entity_service_fields(service_call))
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/surepetcare/lock.py", line 88, in async_lock
    await self.coordinator.lock_states_callbacks[self._lock_state](self._id)
  File "/lsiopy/lib/python3.11/site-packages/surepy/client.py", line 347, in lock_out
    return await self._set_lock_state(device_id, LockState.LOCKED_OUT)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/surepy/client.py", line 373, in _set_lock_state
    raise SurePetcareError("ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY!")
surepy.exceptions.SurePetcareError: ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY!

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

core-2023.11.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

surepetcare

Link to integration documentation on our website

https://www.home-assistant.io/integrations/surepetcare/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Stono avatar Dec 12 '23 15:12 Stono

Hey there @benleb, @danielhiversen, mind taking a look at this issue as it has been labeled with an integration (surepetcare) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of surepetcare can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign surepetcare Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


surepetcare documentation surepetcare source (message by IssueLinks)

home-assistant[bot] avatar Dec 12 '23 15:12 home-assistant[bot]

With debug logging on SurePet api returns a 422 Unprocessable Content error message

2023-12-12 18:35:47.996 INFO (MainThread) [surepy.client] 🐾 [38;2;255;0;255m·[0m PUT app.api.surehub.io/api/device/9XXXXXX/control: 422 | <ClientResponse(https://app.api.surehub.io/api/device/9XXXXXX/control) [422 Unprocessable Entity]>
<CIMultiDictProxy('Date': 'Tue, 12 Dec 2023 17:35:47 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'nginx', 'Access-Control-Allow-Origin': '*', 'api-supported-versions': '1.0', 'Strict-Transport-Security': 'max-age=31536000; includeSubdomains; preload', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block')>

Arney avatar Dec 12 '23 17:12 Arney

Same issue here and it´s also been happening for the last couple of days or so, it seems SurePetcare have done anything at their end that broke the integration.

Similar issue is happening when trying to set the pet location to inside/outside:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 235, in handle_set_pet_location
    await self.surepy.sac.set_pet_location(device_id, Location[location.upper()])
  File "/usr/local/lib/python3.11/site-packages/surepy/client.py", line 335, in set_pet_location
    raise SurePetcareError(f"Setting position of {pet_id} failed!")
surepy.exceptions.SurePetcareError: Setting position of xxxxxxx failed!

heisenberg2980 avatar Dec 12 '23 17:12 heisenberg2980

Can confirm, I have the same issue. Tried removing the integration and login again, but that fails as well. This might be related

ivo-toby avatar Dec 12 '23 18:12 ivo-toby

They changed the API url. I opened #105459 for this and also there is discussion on surepy as mentioned by @ivo-toby (https://github.com/benleb/surepy/pull/200)

chrisdrackett avatar Dec 12 '23 18:12 chrisdrackett

Sunday i updated home-assistant (docker) from 2023.8.4 (not really sure about the .4) to version 2023.12.1. it looks like coincidence but since then the integration stopped working and gave the same message as above.

the strange thing is that the status of the pet is working. just checked, if i change the location of the pet in the official app. it will reflect in home-assistant.

So requests are working fine. only updates are not working (update pet location from app. or unlocking the flap)

koos147 avatar Dec 13 '23 18:12 koos147

I'm encountering the same issue, where all functionality has ceased. Upon deleting the login in HA, I'm now unable to log back in (ADD ENTRY - Failed to connect).

We would be very greatfull when someone is able to fix it.

Moreover, it would be amazing if there is a way to read the Timeline (for example to be able to know which cat used which cat window) and to be able to manage the cat permissions for a cat window from HA.

Kiphouder avatar Dec 13 '23 21:12 Kiphouder

Same issue here, started two days ago. Removed the integration and now can't log back in.

rnc030 avatar Dec 13 '23 21:12 rnc030

I have the same problem since yesterday evening (HA version 2023.11.3). I see status changes to flaps and cat locations, but I no longer send commands to lock and unlock the cat flaps. Error message by trying to lock/unlock the flaps with HA: Error calling service lock/lock. ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY!

chrisannen avatar Dec 13 '23 21:12 chrisannen

For what it's worth i use another project that just fixed this problem; so you might be able to take inspiration from their latest commits. https://github.com/fabieu/sureflap-api/issues/25#event-11256640641

Stono avatar Dec 15 '23 08:12 Stono

there’s an open MR from a sureflap dev already, will merge it later today probably ✌️

benleb avatar Dec 15 '23 10:12 benleb

Same problem here. It is still possible to read everything, but sending commands is impossible. Also already checked if the account I shared the Sure Petcare ecosystem with still has write access

eversteegt avatar Dec 18 '23 14:12 eversteegt

It seems https://github.com/benleb/surepy/pull/201 solves the issue and it has been merged today, hopefully it will be available in Home Assistant soon

heisenberg2980 avatar Dec 18 '23 23:12 heisenberg2980

@benleb, I'm a bit confused. It looks like, from reading the above, that the issue was solved. But when I try to recreate the integration of Sure PetCare in my HA instance, it still doesn't work. Am I missing something?

mluckolson avatar Dec 22 '23 22:12 mluckolson

The merge is slates for 2023.12.4 release, which isn't released yet, what build did you use?

Endolf avatar Dec 22 '23 22:12 Endolf

@benleb, I'm a bit confused. It looks like, from reading the above, that the issue was solved. But when I try to recreate the integration of Sure PetCare in my HA instance, it still doesn't work. Am I missing something?

Need to wait for the next patch release?

luke-barnett avatar Dec 22 '23 22:12 luke-barnett

The merge is slates for 2023.12.4 release, which isn't released yet, what build did you use?

Ah yes, this is the problem I'm still on core 2023.12.3 and, as you say, awaiting 12.4.. Just for my future edification, is there somewhere on the PR (or elsewhere) I could have seen this for myself?

mluckolson avatar Dec 23 '23 18:12 mluckolson

The merge is slates for 2023.12.4 release, which isn't released yet, what build did you use?

Ah yes, this is the problem I'm still on core 2023.12.3 and, as you say, awaiting 12.4.. Just for my future edification, is there somewhere on the PR (or elsewhere) I could have seen this for myself?

more or less :D in the MR https://github.com/home-assistant/core/pull/106101 you can see it here

image

or in the sidebar

image

benleb avatar Dec 23 '23 21:12 benleb

Another confirmation of the issue. I have updated to 2023.12.3. Still same issue. Don't know if it is helpful, here the error message:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 107, in _async_lock
    await entity.async_lock(**_add_default_code(entity, service_call))
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/lock.py", line 88, in async_lock
    await self.coordinator.lock_states_callbacks[self._lock_state](self._id)
  File "/usr/local/lib/python3.11/site-packages/surepy/client.py", line 339, in lock
    return await self._set_lock_state(device_id, LockState.LOCKED_ALL)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/surepy/client.py", line 373, in _set_lock_state
    raise SurePetcareError("ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY!")
surepy.exceptions.SurePetcareError: ERROR (UN)LOCKING DEVICE - PLEASE CHECK IMMEDIATELY!

There seem to be other integrations which have the same/similar issue: #660020

akrea avatar Dec 25 '23 15:12 akrea

There is no need to add more comments to this issue confirming it´s still there, as previously mentioned the issue is already fixed but it will not be available to everyone until the 2023.12.4 is released. If anyone wants to manually implement the changes in their HA instance you can follow these instructions: https://github.com/benleb/surepy/pull/201#issuecomment-1862579709

heisenberg2980 avatar Dec 25 '23 15:12 heisenberg2980

Sorry, didn't pay enough attention to the details of the thread.

akrea avatar Dec 26 '23 09:12 akrea

Version 2023.12.4 has been released. @Stono once you update your HA instance please close this issue if it is fixed after the update

heisenberg2980 avatar Dec 27 '23 14:12 heisenberg2980

@heisenberg2980 just tested - works perfectly, thanks so much :)

Stono avatar Dec 27 '23 15:12 Stono