Sureflap Connect - Pet Door

OK so I figured this out myself, based on various comments in the thread but above all, a lot of trial and error investigation. The net of it is that the snippet of config setup originally given by janmatias, does not work as presented (maybe it did at some time and evolving development broke it - whatever).

Anyway, through trial and error I discovered that the only things needed to make this integration work are
username : [email protected]
password: xxxxxxxx
flaps: [xxxxx , xxxxx, ...]
pets: [yyyy, yyyy]

For flaps and pets, ONLY the ids are acceptable. All of the braces ( {} ) , and name fields, are not acceptable.

In trying to get things working in HA, I’ve noticed a lot of cases where advice and code/config snippets and the like are obsolete. It’s a pity there is not a reliable system to purge - or at least identify as obsolete - older posts.

Now to try and get the custom-card-linky or linky-card Lovelace card operational for this. Another “bête noire” I’ve been beating my head up against for days now. Can’t seem to get HA to recognize that these cards even exist on the system…

I’m totally new to this and still can’t get to work…

Which are the exact files I need to put into custom_componants and where can I find them please?

Thanks in advance. Getting the glass cut for the flap tomorrow and want to get this going

Hi,
I’m not exactly the best guy to ask for the procedure, noob that I am. I stumbled around a lot before I got the sensors working (and didn’t take notes! :hot_face:. I’d be afraid to send you down a wrong path. I will go back and look at my integration and see if I can remember how I finally ended up getting it up and running.

I’m struggling with the custom card issue at the moment so this may take a bit of time.

Cheers.

Getting closer

In the log there are a bunch of errors. Not sure where I am going wrong:

Logger: homeassistant
Source: custom_components/surepetcare/sensor.py:125
First occurred: 1:33:42 (72 occurrences)
Last logged: 13:23:42

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 283, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/config/custom_components/surepetcare/sensor.py", line 125, in state
    return SureLockStateID(self._state["locking"]["mode"]).name.capitalize()
KeyError: 'locking'
Logger: homeassistant
Source: custom_components/surepetcare/sensor.py:173
First occurred: 1:33:42 (72 occurrences)
Last logged: 13:23:42

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 283, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 323, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/config/custom_components/surepetcare/sensor.py", line 173, in device_state_attributes
    voltage_per_battery = float(self._state["battery"]) / 4
KeyError: 'battery'
Logger: homeassistant
Source: custom_components/surepetcare/binary_sensor.py:240
First occurred: 1:33:42 (72 occurrences)
Last logged: 13:23:42

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 283, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 323, in _async_write_ha_state
    attr.update(self.device_state_attributes or {})
  File "/config/custom_components/surepetcare/binary_sensor.py", line 240, in device_state_attributes
    "device_rssi": f'{self._state["signal"]["device_rssi"]:.2f}',
KeyError: 'signal'

Any help would be much appreciated.

I am running Hass.io on a NAS

Thanks for this post. Helped me out man :+1:

1 Like

This is why whenever I find out a solution, it’s always posted back in the thread to help others in the future :slight_smile:

Any ideas why I might be getting this error for the battery status?

File "/config/custom_components/surepetcare/sensor.py", line 47, in async_setup_platform
entities.append(SureBattery(entity[CONF_ID], sure_type, spc))
File "/config/custom_components/surepetcare/sensor.py", line 69, in __init__
f"{self._sure_type.name.capitalize()} "
KeyError: 'name'

And this:

Logger: homeassistant.util.async_
Source: util/async_.py:129
First occurred: 9:53:06 (1 occurrences)
Last logged: 9:53:06

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

Hi, sorry I couldn’t get back to you sooner. Family issues.

I went back and looked at how I got this up and running. If I’m not mistaken, I was wasting my time with a custom component integration, when the latest version of HA has SurePetCare as a third party integration. See this : https://www.home-assistant.io/integrations/surepetcare/

So the above gives you everything you need to get it enabled within your HA. Unless I’m completely off base, you should only have to set this up via configuration.yaml, provided you have a recent (latest!) version of HA.

I have not yet gotten a custom card working with the resulting sensors, I just grabbed an “entities” stock card and put my three pet sensors in there. I’d really like to get a custom card set up for the flap, but it’s going to take a bit of work I think.

image

I’ve had a devil of a time with custom cards of late, HA constantly telling me they didn’t exist, going back tens of times and re-verifying that I installed them correctly, set the resources up in Lovelace, etc.

Only to discover that my biggest problem seems to be how picky YAML is about syntax; you need to make sure that there’s no spaces between the type: and the name of the card. IE, type: xxxx-xxx will throw and error. type:xxxx-xxx is correct. YAML is REALLY picky about syntax.

Besides that, I found that it’s sometimes helpful to completely stop the HA host system and restart it after making numerous changes to try to get the cards working. Oh, and clear the browser cache.

Hope this gets you closer to up and running.

Only to discover that my biggest problem seems to be how picky YAML is about syntax; you need to make sure that there’s no spaces between the type: and the name of the card. IE, type: xxxx-xxx will throw and error. type:xxxx-xxx is correct. YAML is REALLY picky about syntax.

You talk about this?

just quote it :v:

I can’t seem to get the battery sensor to work… Not sure what I’m doing wrong. Can someone share a config.yaml with me please?

Yes I figured this out too but still got few snags. Can’t get the card to work when my cat is away or home, nor can I get the battery to show…

This is what mine looks like (very basic, but works!).

I had it quoted, and was still getting “does not exist” errors. But now, when I go back to look at the same custom card I was having problems with, it works just fine, space or not.

I’m thinking this had to do with HA >really< not being able to find the thing, due to some other step I had to take to refresh things. As I stated in my previous reply to [nckslater], I stopped and restarted HA to no avail, and finally ended up shutting down the host system and rebooting. I did so many things I’m not sure which finally resolved the problem but at least now I’m out of the woods.

I’m now looking for a nice custom card for this integration which I can adapt to my tastes. Any suggestions out there?

You are the man! I’m a total noob and had the name in quotes too!
Battery working now :+1::battery:
Going to get ghe card to show in or out now. Thanks for writing your issues as its helped me out man

My pleasure. I’m working on integrating a card for this, will come back with any probing results.

Ok so I wasn’t aware that the scan_interval should be quite big - I had mine at 3 seconds (oops). Alexa calls out when my cat enters or leaves through the cat flap and the short scan_interval really worked well with it.

Is there another way to make this work? I have made the following automation but a) I dont know if homeassistant.update_entity willw ork with this integration and b) the automation wont work if my phone is out of battery - which happens alot :(.

Any suggestion? thanks

  - id: '8623184961231246'
    alias: Nero Update Entity
    trigger:
      platform: state
      entity_id: sensor.stephen_s20_last_notification
      to: 'Nero has left through Cat Flap... Bye Nero!'
      platform: state
      entity_id: sensor.stephen_s20_last_notification
      to: 'Nero has entered through Cat Flap... Hi Nero!'
    action:
    - service: homeassistant.update_entity
      entity_id: binary_sensor.pet_nero
1 Like

I’ve set up the integration and can see the sensor.pet_flap_cat_flap state, however I can’t call the service surepetcare.set_lock_state as described in the integration webpage. The service is not shown in developer tools service list.

Getting this error when trying to call the service (testing using the button card below):

“Failed to call service surepetcare/set_lock_state. Service not found.”

type: button
tap_action:
  action: call-service
  service: surepetcare.set_lock_state
  service_data:
    flap_id: 'xxxxxx'
    lock_state: locked_all
entity: input_boolean.flap_lock_both_directions_toggle

I have this Warning in the HA System Log file, may be the reason why the service has not loaded:

Logger: homeassistant.setup
Source: /usr/local/lib/python3.8/asyncio/events.py:81
First occurred: 13:14:00 (1 occurrences)
Last logged: 13:14:00
Setup of surepetcare is taking over 10 seconds.

I’ve restarted home assistant a few times. Running HA 2021.1.5 on a pi3.

Any ideas?
Many thanks!

Hi, I have the same issue, the service as documented in the integration description is not available under Developer Tools \ Services.
Should I open an issue in GitHub, or does someone have a solution?

So the automation works but it is not suitable as it’s very slow. If my phone is asleep it takes ages for the notification to come through.

Any other ideas?

What version of HA are you running? I’m on 2021.1.5 and this might be the issue so I’m going to upgrade. Thought I had read the whole thread but obviously missed this post earlier in the topic:

2021.2.1 is available now and it looks like this new feature is included, from the release notes of 2021.2.0:

Add service to lock/unlock Sure Petcare pet flaps