Sureflap Connect - Pet Door

Thanks @benleb, I am waiting on your release with full documentation how to install on Hass.io

I am running one of the first versions I think, made by rcastberg, on the day when the server was down, my entities where unavailable but since it came back it does not update anymore, one of the cats is still outside while on sureflap app shows inside and the app updates properly without issues

Is this part of the official integration? is there a HACS custom component that can implement this if not?

Thanks

1 Like

Oh :confused: @Sp4wN I have never used Hass.io and as I have no knowledge about, I probably will not write any documentation about, sorry :sweat_smile:

@Eeeeeediot no that’s a python tool, nothing todo with home assistant

Could someone with a feeder who understands (what they do and if that’s okay to run on your system) the following commands please run them, EDIT THE RESULTING JSON FILES TO REPLACE personal information and send it to me? The commands are pre-prepared, you just have to fill the env vars and everything else should be c&p. But please DO NOT DELETE BUT REPLACE and if possible, replace with something similar (“4444” should not become “hello world!”) and always replace the same value with the same replacement, at least for IDs! Thanks!

If possible, it would be most interesting if these commands are run after Cat A has used the feeder but before Cat A uses a flap afterwards (I have a “activity” field which is always the same as the “position” in my case but maybe that changes when there is a feeder involved…)

Thank you very much!


export SUREPY_TOKEN="DdsQ1BVN3l6ajZrbjYiLCJ......zdWIiOjUwNTcsInBydiI6ImIzZ"

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/me/start" > surepy_me_start.json

export HOUSEHOLD_ID="12345"
export PET_ID="67890"
export FEEDER_ID="445544"


curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/report/household/${HOUSEHOLD_ID}/pet/${PET_ID}/aggregate" > report_hhid_petid_aggregate.json

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/report/household/${HOUSEHOLD_ID}/pet/${PET_ID}" > report_hhid_petid.json

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/report/household/${HOUSEHOLD_ID}/device/${FEEDER_ID}" > report_hhid_devid.json


curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/household/${HOUSEHOLD_ID}?with%5B%5D=invites&with%5B%5D=invites.creating&with%5B%5D=invites.creating.profilePhoto&with%5B%5D=invites.accepting&with%5B%5D=invites.accepting.profilePhoto&with%5B%5D=pets&with%5B%5D=users&with%5B%5D=users.user&with%5B%5D=users.user.profilePhoto&with%5B%5D=users.households&with%5B%5D=timezone" > single_household.json

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/device?with%5B%5D=children&with%5B%5D=tags&with%5B%5D=control&with%5B%5D=status" > device_with.json

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/pet?with%5B%5D=photo&with%5B%5D=breed&with%5B%5D=conditions&with%5B%5D=tag&with%5B%5D=food_type&with%5B%5D=species&with%5B%5D=position&with%5B%5D=status" > pet_with.json


curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/pet/${PET_ID}?with%5B%5D=photo&with%5B%5D=breed&with%5B%5D=conditions&with%5B%5D=tag&with%5B%5D=food_type&with%5B%5D=species&with%5B%5D=position&with%5B%5D=status" > single_pet_with.json

curl -H "Accept: application/json" -H "Authorization: Bearer ${SUREPY_TOKEN}" "https://app.api.surehub.io/api/device/${FEEDER_ID}?with%5B%5D=children&with%5B%5D=tags&with%5B%5D=control&with%5B%5D=status" > single_device_with.json

@benleb no problem at all, I will figure it out. For time being I got it working again with newer files, I don’t know what the problem was, but I had the older files and I am using these now:
https://github.com/home-assistant/core/tree/dev/homeassistant/components/surepetcare

1 Like

Any idea when lock/unlock could be pulled into HA?

I’m planning on buying one of the flaps soon, hopefully I’ll have some time to get lock/unlock/set curfew times exposed in HA over the new year break (assuming someone doesn’t beat me to it :smiley:)

Does anyone have any thoughts about the best way to model this in HA? It probably doesn’t fit with the existing “lock” model, so might just need to expose a new service (surepet.update_lock_mode?) that lets you set a mode (locked, unlocked, in-only, out-only, curfew) and leave it without a UI component until some puts together a custom card?

2 Likes

@benleb has already done the work to get the locks working, it just needs to be pulled into HA. Sadly, I have no idea how to do that, but really, really hope that someone can do so soon!

edit: Actually, as I reread your post, are you saying you know how to do this? If so, awesome!!!

How often does the integration contact the sure petcare servers for pet status?

Im noticing a delay of around 180s between animal status changing on sure petcare and home assistant.

Thanks
(P.S I’m very new at this so I’m sorry if I’ve missed something obvious)

Edit: I just noticed the ‘scan_interval’ option, I missed this initially as it wasn’t in the code. Thought I’d leave this here for any other beginners please delete if it isn’t necessary.
—I’ve set it to update every 1s, would it be possible to configure the scan to only run within my defined curfew hours?

It ended up being easier than I expected; I’ve got a series of PRs open to add support for setting the lock state:

Hopefully these can be merged once someone has time to review them

2 Likes

By way of an update; it turns out that SurePy v0.4.0 dropped support for Python 3.7, so this can’t be merged until the Home Assistant 3.7 deprecation is complete. That was supposed to be done in 0.118, but has been delayed.

@Thunder_Chunky 1 second pull interval is way to much, I am not sure if Sure Pet developers like that when they see this kind a activity on their servers.

See benleb’s post here, he contacted them about this: Sureflap Connect - Pet Door

Would it also be possible to add the ability to ‘manually’ refresh states? I’d like to set the scan interval to like 5-10 minutes, then allow the HA app to watch my phone for notifications from the Surepet app, then force an update.

(I know this is slightly offtopic but…)
Could someone possible help me to understand how to get SurePy running on Ubuntu. After the pip install, I’m not able to just run ‘surepy --help’. Until the full integration gets working, I’d like to call surepy from HA to do things.

See the homeassistant.update_entity service.

Can you explain how that pertains to this? The animals are binary_sensors. I don’t see any way to force an update for the animal. What am I missing?

edit: homeassistant.update_entity does not seem to work

Interestingly it seems that this is an integration that the generic update_entity service does not work with. Normally homeassistant.update_entity requests one or more entities to update their data outside of the configured scan_interval - I use it for my travel time sensors.

I’ve just tested it with my Surepet sensors and the service call does nothing - apologies for the red herring.

It might be worth raising this as a feature request as it seems to be the defacto official way to refresh states on demand - unless there’s a reason why this would be a bad idea for this integration of course.

1 Like

I’m hoping that posting here is good enough for the feature request, as all development updates have been posted here so far.

What happens when you try running surepy --help?

What version of Ubuntu?

Do you have a Python 2 pip installed as well as a Python 3 pip? (not an issue on Ubuntu Focal and newer, compare the output of apt-cache policy python3-pip to apt-cache policy python-pip)

Simplest way to install it is to run pip3 install --user surepy==0.4.0, which should give you a surepy script installed at ~/.local/bin/surepy

1 Like

Huh, I did know this was a thing. I’ll take a look, but I suspect that this isn’t working because the sensors don’t fetch state themselves, the integration manages a surepy object which periodically fetches info about all the known entities, and sends that information “down” to the sensors

2 Likes

That worked. Thanks!