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

Hi, great app.

However I’d love to have a status indicator on the tile, showing the battery level of the cat flap.

Great application. Status indicator on tiles should be great or hub LED controls as well.

Exp. if a pet is inside the hub light will be on if it is out it will be off. During night should decrease the light intensity

Hi Koktail, thank you for the nice SurePet-flap app for Homey !

The flowcards ‘a pet left the house’ en ‘“find pet” has left the house’ or came back home variants seem not to work as I expect. I cannot add the name of the pet, this is preventing the Homey Flow to execute. Do I do something wrong, or is this a bug in the flowcards ?

kr, Ollifant

SOLVED , homey app logoff , logon : name visible in the flowcard.

Future request: Make the app do global timeline in Homey :slightly_smiling_face:

Changes in 3.0.0 (test):

  • Added support for the Felaqua Connect water dispenser
  • Added a flow condition card to check whether a pet is home
  • Added insights for the bowl weight, so you can track feeding over time
  • Improved translations for flow cards and store texts, now including Arabic

Hi there,

When a feeder plate is filled. Only testing works if flow. The flow itself does not start with that.

Any hint?

. Hidden

Continuing the discussion from [APP][Pro] Sure Petcare App - (Sureflap Pet Door/Sureflap Cat Flap):

Hi! First of all, thank you for maintaining the Sure Petcare app for Homey.

I recently ran into an issue where the app suddenly started failing every 60 seconds with AxiosError: Request failed with status code 401.

After inspecting the stored token in the app settings, I found the root cause:

  1. The JWT bearer token issued by https://app.api.surehub.io/api/auth/login has a fixed 1-year expiration (exp).
  2. Once that 1-year timestamp passes, the app continues polling every minute using the expired token from homey.settings.get('token') and emits an error log event on every poll. Restarting the app does not renew the token either, because the expired token string is still present in settings.

Suggested improvement — a built-in refreshToken() function in the app: Since the app already stores username and password in homey.settings, adding a dedicated refreshToken() method in the app class would solve this completely:

  1. Proactive check on startup & daily timer: Decode the JWT exp claim locally in refreshToken(), and if the token is missing or expires within the next 14 days, automatically authenticate against /api/auth/login using the stored credentials and save the new token via homey.settings.set('token', newToken).
  2. Reactive fallback on HTTP 401: If any API poll returns HTTP 401 Unauthorized, call refreshToken() once (with a cooldown/backoff guard to prevent login loops if a user changed their password) and retry the request.
  3. Optional Flow Action Card / Settings button: Expose refreshToken() as a Flow action card (“Refresh authentication token”) or a button in the app settings page so users can also trigger a manual token refresh without having to re-enter their credentials.

Thanks again for your work on the app!

I Use this for now:

// Auto-renew Sure Petcare 1-year JWT token if < 14 days remaining

const settings = await Homey.apps.getAppSettings({ id: ‘com.sure-petcare’ });

if (!settings || !settings.username || !settings.password) {

return;

}

let needsRenewal = false;

let deviceId = ‘552961069’;

if (!settings.token) {

needsRenewal = true;

} else {

try {

const parts = String(settings.token).split('.');

const payloadJson = Buffer.from(parts\[1\], 'base64').toString('utf8');

const payload = JSON.parse(payloadJson);

if (payload.device_id) deviceId = String(payload.device_id);

const daysLeft = (payload.exp \* 1000 - Date.now()) / (1000 \* 3600 \* 24);

log('Sure Petcare token days left:', Math.round(daysLeft));

if (daysLeft < 14) {

  needsRenewal = true;

}

} catch (err) {

needsRenewal = true;

}

}

if (!needsRenewal) {

return;

}

const res = await fetch(‘https://app.api.surehub.io/api/auth/login’, {

method: ‘POST’,

headers: {

'Content-Type': 'application/json',

'Accept': 'application/json, text/plain, \*/\*',

'User-Agent': 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36',

'Origin': 'https://surepetcare.io',

'Referer': 'https://surepetcare.io/'

},

body: JSON.stringify({

email_address: settings.username,

password: settings.password,

device_id: deviceId

})

});

if (!res.ok) {

throw new Error('SureHub login failed with HTTP ’ + res.status);

}

const json = await res.json();

const newToken = json && json.data && json.data.token;

if (!newToken) {

throw new Error(‘SureHub login response did not contain token’);

}

await Homey.apps.setAppSetting({

id: ‘com.sure-petcare’,

name: ‘token’,

value: newToken

});

await Homey.apps.restartApp({ id: ‘com.sure-petcare’ });

await Homey.notifications.createNotification({

excerpt: ‘Sure Petcare: Innloggingstoken ble automatisk fornyet for 1 nytt år!’

});

I don’t own any Sure Petcare product anymore and have transferred the app to @sverrelp. Thank you for improving the app for the community! :folded_hands:

I am grateful for the trust placed in me to take over such a great app.

I already have a completely redeveloped version, but since I don’t yet fully understand the existing architecture or potential bugs, I need to evaluate whether to integrate it with new features or take a different approach.

The new features include widgets, app-level settings, and a brand-new driver for pets. I’ve also added new flow cards. My primary goal is to ensure that these new features are working optimally. After that, I’ll decide whether to implement them into the existing app!