[APP][Pro] Sure Petcare App - (Sureflap Pet Door/Sureflap Cat Flap)

Goodmorning

I too have multiple Pet Door Connects and would like to control them individually which does not seem to be possible as I cannot select a specific pet door under ‘THEN’, only the HUB it seems.

My use case is to close only the Pet Door in my Homeoffice door when I finish working there (by locking the door using a smart lock) and open it again when I return for work the next day (by unlocking the door) but that should not influence the Pet Door giving access to my house, that should remain open.

I’ve been reading through this whole thread but did not find any similar usecase except that of @Bernhard_Oberfrank who also owns multiple pet doors.

All suggestions in how to achieve my desired setup are welcome!
I’m using a Homey Pro 2023 V12.0.1 and V2.0.8 of the app
Thanks

Hello,
I have also found no solution to control different doors in flows but it is possible to set the status of each door in the devices manually - I will try to find a solution in Homey Script…

That would be great if you could manage that. I unfortunately am not savvy enough for that.

I was wondering if adding another hub might work as well (a costly solution of course for what seems to be a problem that should be easily fixed through a software setting), then each petdoor connects to its own hub. Not sure however if the Sureflap system allows two hubs in the same household…

Good luck with the script, hope you’ll find a way!

Hello,
I found the following code, but it does not work!


const email = ‘…’;
const password = ‘…’;
const deviceId = ‘…’;

async function lockCatFlap() {
try {
// Login to Sure Petcare
const loginResponse = await fetch(‘https://app.api.surehub.io/api/auth/login’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’
},
body: JSON.stringify({
email: email,
password: password
})
});

const loginData = await loginResponse.json();
const token = loginData.token;

// Lock the cat flap
await fetch(`https://app.api.surehub.io/api/device/${deviceId}/control`, {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    locking: 0 // 2 = locked, 0 = unlocked
  })
});

console.log('Cat flap locked successfully');

} catch (error) {
console.error(‘Error locking cat flap:’, error);
}
}

lockCatFlap();

I think you should be able to add multiple sureflaps to the app.

Hi,
Yes, that is correct. You can add multiple flaps to the app but cannot control them individually in any other step then the IF step (so only as trigger for a flow). You cannot select them under AND or THEN (so as condition or output of a flow). There only the hub shows up which controls all individual devices simultaneously.

At least, I have not been able to do so :wink:

From a code perspective I cannot find that behavior what you describe. Can you give me an example of a flow that you want to achieve?

Yes sure,

When my smart lock locks my office (when the smart lock state is set to locked), the pet door installed in that office should keep all cats out (set state to exit only).
I will try to make some screenshots to make it more clear

Als = If
In this step I can see the individual pet door named Kattenluik Kantoor Paul
So i can trigger a flow using this individual pet flap

Dan = Then
In this step, the individual pet door is no longer selectable

What I can do, is instead of selecting a device, select the app. But then I can only select the Sure Petcare hub it seems and not this specific pet door anymore.

So what i want to achieve is that whenever my device named Kantoorslot is set to locked, the individual pet door named Kattenluik Kantoor Paul is set to keep all pets out

I can only achieve that for (what I believe is) the hub which also changes the state for the other pet door i have.

I hope this clarifies my intention a bit better
Thanks for taking the time to respond!

1 Like

Since a couple of days I also have two catflaps and I ran into the same issue as @12380. If you use the normal flow cards that are provided by the Petcare App, any change in lock state will apply to all your catflaps. Ideally the app would be modified so that you can set this per catflap, but until then, I have created a simple workaround using HomeyScript.

Currenty there are only flow cards per catflap available in the IF-section of a flow. I also need them to be in the AND-section and the THEN-section.

Workaround for the AND-section
To distinguish between different flaps do not use the Petcare app as a flow card, but add a logic card to compare the lockstate of a catflap with a string. This allows you to use the lockstate of a specific flap.

a

Valid values are

  • open
  • keep_outside
  • keep_inside
  • lock_both_ways

Workaround for the THEN-section
With the current version of the Petcare app you cannot use the catflap in the THEN-section to change something. You can only change the lockmode for all catflaps at the same time. I created a workaround by writing a simple HomeyScript to do this.

Here is the script:

//valid values that you can pass as an argument to this script (string)
//keep_inside
//keep_outside
//open
//lock_both_ways

if(typeof args[0] !== "string"){
  throw new Error("Enter a string to start the script.");
}

let catflap = await Homey.devices.getDevice({id: "replace this"}); //catflap device ID

await catflap.setCapabilityValue("sureflap_lock_mode", args[0])
      .then(() => log("OK"))
      .catch((error) => log("Error:", error));

Steps to make this work:

  • Copy the script above and save it as a HomeyScript and give it a name that indicates for which catflap this is, like ‘catflap-backdoor.js’
  • Lookup the ID of the catflap that you want to control and put it in the ‘replace this’ in the script.
  • Save the script
  • Repeat the above steps for your other catflaps and give the script unique names, so that you know which device this script controls.

Now create a flow that calls the script for the catflap you want to control and supply a string with the lockmode as a parameter.
image

One thing that I’m still having issues with is to get triggers from both of my catflaps when a cat leaves or enters. It seems like I only get these notifications from one of the two catflaps. I haven’t found a solution to that yet, so hopefully that can be fixed in a future version of this app. Or if anyone has a good suggestion how to fix this, happy to read that.

1 Like

I have a feature request; Support for widgets! With pictures from my cats, status, battery level, etc.

2 Likes

Hi Tycho,

First of all: WOW :flushed: Thank you very much for taking the time to look into my question with this much detail!
Being a rather long time-but-still-novice-user of Homey, this is the first time i have ever looked into Homey Script which looks rather impressive.

I have (at least) tried to execute the instructions to the letter, but am unfortunately not able to make it work (simply due to lack of knowledge on scripting on my part). When testing the script, i receive no error nor output, when testing the flow in which i am using the script, the script gives a warning ‘Invalid or unexpected token’. I have tried a combination of possible solutions (as described below as questions), but it unfortunately does not seem to work

Some ideas where I might go wrong:

  • Device ID: when i look up the device in Developer Tools i see 2 times an ID, one under Property (long ID code) and one under Data (7 digits only). Which ID am I to use?
  • When pasting the device id, I should place them between the available " " i assume and not remove them?
  • This part of the script, am i correct to assume i should remove it? //device id of your catflap, to be found at Homey Developer Tools or leave it be?

Thanks for your patience :zipper_mouth_face:

Hi @12380 thanks for your response.

The reason you are getting errors is probably because I quoted my own script in an incorrect way on this forum. When I tried copy-pasting my own post into HomeyScript I got errors too. It appears that when I copied the code, the types of quote characters changed, which broke it. I have now put the script in an actual code block in my original post and now copy-pasting should work properly.

For the ID, you need the ID property of the catflap from the developer tools. So your line of code will look similar to this:

let catflap = await Homey.devices.getDevice({id: "d1355a9c-a925-4864-9bfd-b8b8406b56b1"}); //catflap achterdeur

Everything behind two slashes (//) is just a comment in the code and will not be executed. So you can either leave it or remove it. In HomeyScript these comments look green.

Let me know if you get this to work.

1 Like

Hi @Tycho,

Excellent, that indeed fixed it!
Thank you so much! I will have fun tinkering around with the new options this provides me.

Thanks again! :saluting_face:

1 Like

Hi.
I get an error every time I click on “Configure”.
I created a diagnostic report, will the report-guid be helpful for you?

Hi

I like to keep one cat inside during night and the other still able to go outside.
For this i think the best option would be if i could enable “only inside mode” for one of the cats during the night.

Would it be possibly to add that option to the app?

Regards
Magnus

2 Likes

Hi, i’m looking for exactly the same.

@Koktail

I am using this app to send me a push when a cat enters or leave. Along with changing a light to a spesific colour inditcating wich of the two cats are in/out.
Since thursday I think, this have stopped working.
I also use the app to set curfew at a given time and temperature conditions. This works.

Have anything happened that prevents the app being notified when a cat leaves/enters?

Hi! I am trying to install the Sure Petcare app and start using it with my Cat Flap Connect. I have a Sure Petcare account. When I try to set up the app, I get an error message “Error: Missing Parameter: value”. After clicking OK (reluctantly) I see the Sure Petcare login screen. After entering my credentials, I see “undefined undefined” above the “Uitloggen” button. It seems I am not properly logged in?
After that, when I try to add my Catflap, the app again asks my Sure Petcare credentials. After entering those again, the next error message appears: “Request failed with status code 401”. I looked that up and it denotes a general HTTP authentication problem.
Do you know how to fix this?
Kind regards. Ron

Hi, do you know if it’s possible to use Homey directly with the cat flap or do we have to buy the little connector (cat)?

Hi @Maryline_Bilello

You do have to buy the bridge (‘cat’) as well.

Rogier

1 Like