Sureflap Connect - Pet Door

Yes, this would be great.

@antb via github sponsors :crazy_face: but we do not expect something :+1: :smile: PRs would also be a great way to „help“ :smile::wink:

@insertjokehere if you need something in the lib or a new release or anything, tell me :slight_smile:

@bda55 @getsmokes already available in the lib, so it’s „on the way“ more or less, without any guarantees :smile::v:

The config option for a device_tracker entity as well as the binary sensor would be a nice touch. Would save us having to use workarounds to configure a tracker to implement into the person’s component.

Anyone create a template switch that allows the door to be fully unlocked and locked (locked_all) using one switch so I can integrate into our voice assistants?

@nckslater can I ask how you get the information about how many hours and times your cat was outside please.

I can’t seem the get it work, or did you create sensors for that? If so could you please share your yaml code?

Thanks

EDIT: Got it with https://www.home-assistant.io/integrations/history_stats

1 Like

For anyone looking to mimic the Sureflap LCD screen, I’ve created a picture-glance that does exactly that. Works a treat!

Sureflap

type: picture-glance
entities: []
title: []
state_image:
  Locked_all: /local/sureflap_fully_locked.jpg
  Unlocked: /local/sureflap_fully_unlocked.jpg
  Locked_in: /local/sureflap_in_only.jpg
  Locked_out: /local/sureflap_out_only.jpg
  Curfew: /local/sureflap_curfew.jpg
entity: sensor.pet_flap_laundry_door
show_state: []

Download the picture assets here and copy to your www folder:

EDIT: 14th March. Assets tidied up so they are now all the same size.

EDIT: 13th May. Added Curfew Mode icon to indicate if lock state was overridden by the app

image

7 Likes

Another idea which works with this integration (if you have a 3D printer)

Couple weeks ago I printed 2 lithophane’s and modified a existing box printed that one with wood filament, than added 2 Sonoff zigbee mini’s.

So if one of the cats goes outside her lithophane lights up, this way we can directly see which cat is outside.

Here some pictures:
kat_belet_01
kat_belet_02

Thanks for this integration guys, it makes possible to make nice things!

7 Likes

Hoping somone might be able to point me in the correct direction as to why i cant get this working.

First error is

Logger: homeassistant.util.async_
Source: util/async_.py:129
First occurred: 19:51:21 (1 occurrences)
Last logged: 19:51:21

Detected I/O inside the event loop. This is causing stability issues. Please report issue for surepetcare doing I/O at homeassistant/components/surepetcare/__init__.py, line 114: device_data = await surepy.device(device[CONF_ID])

Followed by

Logger: homeassistant.setup
Source: /usr/local/lib/python3.8/asyncio/events.py:81
First occurred: 19:51:31 (1 occurrences)
Last logged: 19:51:31

Setup of surepetcare is taking over 10 seconds.

And finally

Logger: homeassistant.setup
Source: components/surepetcare/__init__.py:114
First occurred: 19:51:37 (1 occurrences)
Last logged: 19:51:37

Error during setup of component surepetcare
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 278, in _get_resource
    response: aiohttp.ClientResponse = await self._session.get(resource, headers=headers, timeout=timeout)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 890, in start
    message, payload = await self._protocol.read()  # type: ignore
  File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 604, in read
    await self._waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 280, in _get_resource
    logger.debug("response.status: %d", response.status)
  File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
    result = await task
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 114, in async_setup
    device_data = await surepy.device(device[CONF_ID])
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 184, in device
    device: Dict[str, Any] = (await self.devices).get(device_id, {})
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 181, in devices
    return await self.get_entities("devices")
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 244, in get_entities
    await self._get_resource(resource=MESTART_RESOURCE)
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 311, in _get_resource
    raise SurePetcareConnectionError()
surepy.SurePetcareConnectionError

Quite often when I restart HA, this doesn’t always start and I’m not sure what the problem is…

2021-03-12 13:06:34 ERROR (MainThread) [surepy] Can not load data from https://app.api.surehub.io/api/me/start
2021-03-12 13:06:34 ERROR (MainThread) [homeassistant.setup] Error during setup of component surepetcare
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 278, in _get_resource
response: aiohttp.ClientResponse = await self._session.get(resource, headers=headers, timeout=timeout)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 544, in _request
await resp.start(conn)
File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 890, in start
message, payload = await self._protocol.read() # type: ignore
File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 604, in read
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 280, in _get_resource
logger.debug("response.status: %d", response.status)
File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 45, in __exit__
self._do_exit(exc_type)
File "/usr/local/lib/python3.8/site-packages/async_timeout/__init__.py", line 92, in _do_exit
raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 213, in _async_setup_component
result = await task
File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 114, in async_setup
device_data = await surepy.device(device[CONF_ID])
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 184, in device
device: Dict[str, Any] = (await self.devices).get(device_id, {})
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 181, in devices
return await self.get_entities("devices")
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 244, in get_entities
await self._get_resource(resource=MESTART_RESOURCE)
File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 311, in _get_resource
raise SurePetcareConnectionError()
surepy.SurePetcareConnectionError

Any idea why this might be?

I blame the poor cloud implementation by Surepetcare. I also get these same errors and most times need multiple reboots before I get the integration to be able to connect.

That said, hopefully soon we will have a non-cloud option for DIYers in Surepet hub local for pet/cat door and feeder

@peterl is doing epic work on it.

2 Likes

Thanks @tinuva I have made some great progress and would love some help getting a few of the last issues sorted. So any assistance folks can provide especially with the CRC calculation of the message in https://github.com/plambrechtsen/pethublocal/issues/1 would really help.

Wait, what is the difference between that integration and this one?

Local access would be awesome. I will take a look :ok_hand:

I have made an alternative cloud integration for HA: https://github.com/Danielhiversen/home_assistant_petcare

Still work in progress.
Compatible with HACS.
No I/O inside the event loop.
Can be configurated from UI.
In addition to the sensors, you get locks for lock/unlocking the flap from the UI
I try to limit the number of requests to the sureflap server, and make sure do not to do any in parallel.

2 Likes

Any chance this includes the ability to set the pet home or away?

How quickly will the status of the pet update in Home Assistant after it comes through the flap with your integration? The sure per are app on my phone is immediate but when I use the official integration with a lower scan_interval I have FREQUENT disconnects in the hub and the ears are red quite a bit.

I see the messages almost instantly depending on the message types.
If you have a CC2531 you can sniff the traffic yourself using zigsniff. I have the dexoring code and dumping the message to console there. Also the advantage there is it creates a wireshark pcap so you can analyse offline in the future once you make changes to the python.
My main stumbling block now is how the CRC byte is calculated as that will need to be correct for the devices to accept any messages we try and send to it.

Made a breakthrough last night where I have figured out how to send a frame to the feeder / pet door using the surepet hub… So running a fully local solution will be 100% possible once the code is written, posted an update in my development thread: https://community.home-assistant.io/t/surepet-hub-local-for-pet-cat-door-and-feeder

2 Likes

This doesn’t show up in HACS for me.

Taking shape and almost there for the local instance. Would be interested in feed back from deploying the docker compose setup.

1 Like

Hi,
I found this Forum and I wanted to know if it would be possible to set up different lock times for different cats?