Home Assistant integration for OnlyCat catflap

I just ordered a a onlycat catflap as an replacement for our sure petcare catflap (the hub stopped working several times, never liked the “must be online” idea and now the integration does not work).

I’ll am going to start work on a HA integration. I do have small kids, work and so of course, so it’ll be when ever I have time.

3 Likes

Hoi zäme!

I just started using Home Assistant (via a HA Yellow with a Raspberry Pi Compute Module). Previously, I was a Philips Hue user and separately also had a SureFlap cat flap. I now have an OnlyCat flap and am interested in HA integration.

All of this is to say, I’d be happy to contribute if I could be useful. Nice to meet everyone—this is my first post. :stars:

1 Like

Great to see a community building. Would love to help with this.
Looking at the existing files it appears not all files exist?

import OCPlatform from “./OCPlatform”;
import { User } from “…/models/User”;

1 Like

@OnlyCat can you help answer @Iano_D’s question about the missing files?

The OCPlatform file we use is tied to our app’s data storage, so we didn’t include it as part of the standalone example - however you only need a stub version which includes a getDeviceToken method that returns a string device token, which you can get from the app’s Account tab.

class OCPlatform {
    async getDeviceToken() {
            return '[INSERT TOKEN HERE]';
    }

    getPlatforms() {
        return ['home-assistant'];
    }
}

export default new OCPlatform();

(This mechanism will improve over time with proper developer API keys - but the above approach should get you started).

As for models/User.tsx, this will work:

export interface User {
    id: number;
    sub: string | null;
    email: string | null;
    name: string | null;
    description: string | null;
    avatarUrl: string | null;
    userLevel?: 'ADMIN' | null;
}
3 Likes