Skip to content

Conversation

@bushbrother
Copy link

Adding the ability to set a pet as "indoor only" or "outdoor"

Adding the ability to set a pet as "indoor only" or "outdoor"
@M-Bab
Copy link

M-Bab commented Jun 1, 2025

How is the "outdoor" mode supposed to work? Does this still allow the cat to get out but not in again? Or is it the same like unassigning the cat from the corresponding flap?

And is it possible that this functionality is not available in the Sure flap application itself? Because I think it is a missed feature there.

@bushbrother
Copy link
Author

How is the "outdoor" mode supposed to work? Does this still allow the cat to get out but not in again? Or is it the same like unassigning the cat from the corresponding flap?

And is it possible that this functionality is not available in the Sure flap application itself? Because I think it is a missed feature there.

Outdoor means that the cat is allowed outdoors, indoor only essentially blocks the cat leaving but always let's them in. This allows multi pet household to allow some in and out.

The surepet app has this ability but you have to manually trigger it.

I am in a situation where I want to stop one of my cats going out at night. Curfew mode stops ALL cats leaving, so I had to manually trigger this mode each night, now with this HA config I can automatically call the service to set it.

@M-Bab
Copy link

M-Bab commented Jun 1, 2025

So individually set-able for each cat

  • Indoor = Cat can come in, but cannot leave (an option definitely available in the Sure Petcare app)
  • Outdoor = Cat can leave, but cannot come in (never seen an option like this in the app but it would be a great feature)

?

@bushbrother
Copy link
Author

bushbrother commented Jun 1, 2025

So individually set-able for each cat

  • Indoor = Cat can come in, but cannot leave (an option definitely available in the Sure Petcare app)
  • Outdoor = Cat can leave, but cannot come in (never seen an option like this in the app but it would be a great feature)

?

Not quite, outdoor is just "normal" as in the cat is an outdoor cat.

Yes these are in the app but not exposed to homeassistant as not in the API currently.

@M-Bab
Copy link

M-Bab commented Jun 1, 2025

Ahh now I see - sorry that took me too long. But a feature like "outdoor only" would also be surprising since the App does not support that either.

But the app supports a different feature: Unassigning and Reassigning cats to the flap. I think this is also not possible yet with surepy and SureHA.

@okaufmann
Copy link

Hi, thanks a lot for maintaining this project! I’d really love to see this PR merged, it would help a lot with my setup.
I’m happy to help with testing or anything else that’s needed to get it ready. cc @benleb

@bechu89
Copy link

bechu89 commented Sep 10, 2025

Thanks to @bushbrother for making this change. I've been needing this feature since literally forever. If this could be merged @benleb then that would be incredible!

@bushbrother
Copy link
Author

@bechu89 - Thanks! You can manually do this by downloading the client.py raw file and swapping it on your system? I only updated that single file.

@bechu89
Copy link

bechu89 commented Sep 10, 2025

@bechu89 - Thanks! You can manually do this by downloading the client.py raw file and swapping it on your system? I only updated that single file.

Thanks for the quick response. I'm not sure exactly how to do that unfortunately - any pointers would be very much appreciated. I only really know how to edit the sureha files.

@bushbrother
Copy link
Author

bushbrother commented Sep 10, 2025

@bechu89 - what is your setup? I assume running Homeassistant? You need to find surepy library in HA machine. I am running supervised and HA as a VM, but the path should be the same regardless.

/usr/local/lib/python3.13/site-packages/surepy/

You need to reboot HA to take effect. If you update HA core you will need to do this again.

You can then use my repo to pull my modified SureHA (awaiting merge still), that should then expose these functions in HA.

@bechu89
Copy link

bechu89 commented Sep 10, 2025

Thanks @bushbrother. I'm using VMware Workstation to run Home Assistant on a virtual machine. I managed to replace the client.py file in surepy (the path was the same!). I also used your fork of SureHa too.

My issue now is that I can't set up a SureHa integration. Every time I login I get "authentication_failed". The error from the log is:

Logger: custom_components.sureha.config_flow Source: custom_components/sureha/config_flow.py:47 integration: SureHA (documentation, issues) First occurred: 9:28:04 PM (2 occurrences) Last logged: 9:28:35 PM
Unable to connect to surepetcare.io: Wrong credentials!

I'm definitely putting in the right credentials though!

@bushbrother
Copy link
Author

bushbrother commented Sep 10, 2025

@bechu89 I had this same issue a couple of times. No idea what causes it, but you can fix by removing and re-adding surepy, use pip uninstall surepy and then pip install surepy within your VM. Then replace the client.py file again.

@bechu89
Copy link

bechu89 commented Sep 10, 2025

@bushbrother thanks again. I've taken the following steps. I'm getting the same results though. Am I doing something wrong? Do I need to remove SureHa too?

Step 1: Remove SurePy
docker exec -it homeassistant pip uninstall surepy -y
Step 2: Reinstall SurePy
docker exec -it homeassistant pip install surepy
Step 3: Replace client.py Again
docker exec -it homeassistant wget -O /tmp/client.py https://raw.githubusercontent.com/bushbrother/surepy/master/surepy/client.py
docker exec -it homeassistant cp /tmp/client.py /usr/local/lib/python3.13/site-packages/surepy/client.py
Step 4: Restart

@bushbrother
Copy link
Author

You may need to restart after the reinstall of surepy. Also check chmod and chown for client.py, should be same as other files in that directory

@bechu89
Copy link

bechu89 commented Sep 11, 2025

You may need to restart after the reinstall of surepy. Also check chmod and chown for client.py, should be same as other files in that directory

It works! Thank you so much @bushbrother - you're a life saver.

@bushbrother
Copy link
Author

@bechu89 That is great to hear! Does the SureHA work as expected? I have only had my own setup to try against. You should have a switch for each cat exposed to set the mode and then 2 additional attributes within the cat data showing which mode they are set as.

Note that it can take some seconds to update the switch due to surepetcare.io taking a while to do it's thing.

@bechu89
Copy link

bechu89 commented Sep 11, 2025

It does indeed work as expected. I can confirm that there is a mode switch, with the logbook updating as the mode is switched on (indoor mode enabled) and off (indoor mode disabled). Automations to enable mode and disable mode work as intended.

@bushbrother
Copy link
Author

bushbrother commented Sep 11, 2025 via email

@FredrikM97
Copy link

Out of interest. What is the different profiles, what is the purpose for it? Instead of number can it be a enum to clearly describe it instead of a number?

@bushbrother
Copy link
Author

bushbrother commented Sep 17, 2025

@FredrikM97 - The mode attribute is the enum of the profile ID. 2 is Outdoor, 3 is Indoor only. I exposed the id number and the enum into the attributes in SureHA.

The API requires it as a number against the pet, in the logs it's clearly labeled.

@FredrikM97
Copy link

Meant that either
The methods could be one method and take the profile as input with a Enum type for validation. Alternatively

response and response.get("data", {}).get("profile") == 2:

Where 2 instead is an Enum in case of API changes. I also noticed in the swagger api that there is a endpoint to fetch devices for a pet. Could be used for validation/fetching available devices to reduce complexity in SureHA.

@bushbrother
Copy link
Author

bushbrother commented Sep 17, 2025 via email

@FredrikM97
Copy link

FredrikM97 commented Sep 19, 2025

Made my own integration instead which include a similar solution. Just wanted to point out so this integration is easy to maintain in the future. Overall it is a great idea and nice that you found it!

@bushbrother
Copy link
Author

bushbrother commented Sep 19, 2025 via email

@FredrikM97
Copy link

FredrikM97 commented Sep 19, 2025

Sure https://github.com/FredrikM97/hass-surepetcare and https://github.com/FredrikM97/py-surepetcare

At first I hoped that I could merge py-surepetcare with surepy but I think dont think it is possible to due the difference in structure.

@AlexC
Copy link
Contributor

AlexC commented Dec 7, 2025

For those interested, I have opened a PR for home-assistant/core which implements this feature without requiring changes to this library. See home-assistant/core#158073

It's working well for me

@durosity
Copy link

durosity commented Dec 7, 2025

For those interested, I have opened a PR for home-assistant/core which implements this feature without requiring changes to this library. See home-assistant/core#158073

It's working well for me

Is it possible to do the same for this repository as I'm using it outside of HomeAssistant?

@AlexC
Copy link
Contributor

AlexC commented Dec 7, 2025

Is it possible to do the same for this repository as I'm using it outside of HomeAssistant?

That's what this PR from @bushbrother does, however it would need one of the maintainers to review and merge in (which I am not).

That's why I've opened the HA PR in a way which doesn't depend on changes to this library, to hopefully get this feature into HA quicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants