Sureflap Connect - Pet Door

Just for reference the battery level went down to -26% before the flap stopped working.

@benleb Do you think there’d be any chance of ever setting the lock state?
I’d like to be able to setup an automation which sets the cat flap to locked-out so the cats can only get out and not back in when the smoke alarm, which is also in HA, is going off.

1 Like

@badguy

I should probably not post here, but you can have a look at how I implemented it (my hack work around).

Clone this repo to get a python cli can that set the lock state: https://github.com/tinuva/sure_petcare
I put that into my HA (Supervisor) /config folder

In short, I took the original python sure_petcare and added in the initial work to push commands to surecare, based on the php repo I found.
The only thing I implemented was setLockMode, I didn’t care about setHubLedBrightness nor setEnableCurfew, but I can see how some might want/need setEnableCurfew.

You can test it with the following commands:

  • To auth:
    sp_cli.py --update -e <user> -p <pass>
  • List flaps on your account: (to get the id)
    sp_cli.py ls_flaps
  • Set the lock state. 0 = unlocked 1 = locked_in 2 = locked_out 3 = locked_all
    sp_cli.py set_flap_lock <flap id> <lock_state>
    so example do the following to set locked out: sp_cli.py set_flap_lock 10010101 2

Then to use it, you can look at https://github.com/tinuva/home-assistant-config/blob/master/packages/surepetcare_shell_cmds.yaml
Be sure to replace the flap id with your own.

If you want to use it in a lovelace card, with the above package already as part of your config, you can just use:

entities:
  - entity: input_boolean.petdoor_mode_unlocked
  - entity: input_boolean.petdoor_mode_locked_in
  - entity: input_boolean.petdoor_mode_locked_out
  - entity: input_boolean.petdoor_mode_locked_all
show_header_toggle: false
title: Pet Door Set Mode
type: entities
3 Likes

Has anyone had any luck with the feeders yet other than the battery level? Even any little hacks?

1 Like

Totally loving the intergration so far, We’ve just purchased 3 feeders and really hoping to get the feed times and feed amounts down if possible? Whilst I’m only new to HA I’m happy to provide outputs where I can :slight_smile:

1 Like

@benleb anywhere that I can buy you a coffee? Would love to put my support behind this!

Hi,

I’ve added the sureflap as per instructions but after a restart I only get two binary_sensors, one for each cat, I don’t see any other sensors for hub_status etc. Am I missing something ?

You’ll only be able to see either the door or the battery life, home/away, and if it’s online.

Don’t see that, just home/away. When I add the flap-id to the config the extension quits with an IndexError on [‘Battery’].

Anyone else’s since attribute for each pet’s binary sensor 1 hour behind the actual event?

My system time etc. is all correct, so I’m wondering if this is a timezone related issue?

EDIT

Looks like the ‘since’ attribute has no timezone information attached by design.


    @property
    def device_state_attributes(self) -> Optional[Dict[str, Any]]:
        """Return the state attributes of the device."""
        attributes = None
        if self._state:
            attributes = {
                "since": str(
                    datetime.fromisoformat(self._state["since"]).replace(tzinfo=None)
                ),
                "where": SureLocationID(self._state["where"]).name.capitalize(),
            }

        return attributes

This means that I cannot convert it to reflect BST:

{{ state_attr('binary_sensor.pet_sami', 'since') }}
{{ as_timestamp(state_attr('binary_sensor.pet_sami', 'since')) | timestamp_local }}
Since TZ: {{ states.binary_sensor.pet_sami.attributes.since.tzinfo }}

2020-05-10 04:36:41
2020-05-10 04:36:41
Since TZ:

@benleb (apologies for tagging) before I raise this as an issue, am I missing something here in how to convert this to current local time?

EDIT
Raised as issue 35576

1 Like

The developer been missing for months not sure this integrations is being worked on anymore so I wouldn’t count on anything :frowning:

He’s actually pretty active on Github, so I can only imagine he’s just busy on other projects.

Hope someone can help me …

I cant get it to work ,

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/config.py”, line 780, in async_process_component_config
platform = p_integration.get_platform(domain)
File “/usr/src/homeassistant/homeassistant/loader.py”, line 273, in get_platform
f"{self.pkg_path}.{platform_name}"
File “/usr/local/lib/python3.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/config/custom_components/sure_petflap/sensor.py”, line 20, in
from .utils import gen_device_id
ImportError: cannot import name ‘gen_device_id’ from ‘custom_components.sure_petflap.utils’ (/config/custom_components/sure_petflap/utils.py)

This integration seems pretty dead…

I have a new issue since HA 0.114
This integration was working fine up to that point…
I get this error


2020-08-12 15:20:41 WARNING (MainThread) [homeassistant.setup] Setup of surepetcare is taking over 10 seconds.
2020-08-12 15:20:48 ERROR (MainThread) [surepy] Can not load data from https://app.api.surehub.io/api/me/start
2020-08-12 15:20:48 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 156, in get_data
    response: aiohttp.ClientResponse = await self._session.get(
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.8/site-packages/aiohttp/streams.py", line 591, 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 160, in get_data
    _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 191, in _async_setup_component
    result = await task
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 131, in async_setup
    await spc.async_update()
  File "/usr/src/homeassistant/homeassistant/components/surepetcare/__init__.py", line 159, in async_update
    await self.surepy.get_data()
  File "/usr/local/lib/python3.8/site-packages/surepy/__init__.py", line 192, in get_data
    raise SurePetcareConnectionError()
surepy.SurePetcareConnectionError

Can this one - rebooted again and it worked this time…
Must have been a timing issue.

Cheers. :grinning:

With perfect timing SurePet had a brief service outage lasting about 40 minutes across all services.
I nearly posted a warning in this thread just in case someone hit the issue during an upgrade :rofl:

Haha, is this why I received a strange notification saying ‘TEST’ when my cat was asleep beside me? Anyone else get that?

Yep, TEST with the content test 2 :slight_smile:

1 Like