Sureflap Connect - Pet Door

I’m getting this error:
WARNING (MainThread) [homeassistant.config] Package sure_petcare contains invalid customize

Is there any checklist how to get this working? I have followed [xatr0z]'s checklist.

Update: did “pip install requests” and got the module error out of the way. Can connect to sp_cli.py. It just returns an error about no credentials provided.

What Widda said. I got everything installed. Things just go wrong when I try to access sp_cli.py, either with our without the ls_pets added. This is the outcome of the “./sure_petcare/sp_cli.py” command:

Traceback (most recent call last):
File “./sure_petcare/sp_cli.py”, line 7, in
import sure_petcare
File “/config/sure_petcare/sure_petcare/init.py”, line 9, in
import requests
ModuleNotFoundError: No module named ‘requests’

I Should note that the git pull command put everything in /config/sure_petflap instead of /config/custom_components/sure_petflap. (I run hassio on a RPI3B). Will that make a difference?

I used pip install -t /deps, while I was in the config folder. Worked like a charm.

1 Like

I almost got it al working. The last snag refused to go away and eventually seemed to crash my system: the sensor was not found by Home Assistant. I was able to get the pet’s names and all. But the error kept turning up on reboot.

I then gave the sensor file all kinds of permissions, restarted my Pi and… half an hour later I was reinstalling en restoring a snapshot.

Any suggestions?

Has anyone managed to get a definitive set of instructions for this ?

Could anyone please make a step by step install guide for hassio?

1 Like

I think I could, as long as someone helps me iron out the last bug: the sensor not found-error. If I know how to get the sensor to be found, I’ll spend another few hours getting it to work and documenting the process.

1 Like

Great. I’m stucked with not getting it installed. Can not get python3 or pip working in hassio. So the two methods that it seems are refered to in this thread leads me nowhere.

Have you installed the configurator under hass.io in your home screen? It has a command line. From there I could install both without problems.

So you’re creating the sensor in the yaml as described at the link below?

I have a feeling I may have gone off the rails with this part:
" To install i cloned this repository and went into home assistant : from the source folder : pip install . -t /config/deps/"

I installed on Hass.io (.87).

First of all: i cloned from the /config/ dir, since I could not find a homedir for HA. The git command worked like a charm, but it did not install in custom_components, but directly in the config folder. And what does he mean by “source folder”? All next steps - such as installing the python stuff - were done from /config/.

According to this blog post, you need to create an empty file in: /home/homeassistant/.homeassistant/custom_components/sensor called __init__.py.

That got rid of the sensor_not found problem but now I’ve got this:

Capture

1 Like

Maybe there is soon a much simpler way… https://github.com/home-assistant/home-assistant/pull/22155

8 Likes

Fantastic work! Appreciate the implementation of this one, hope to see it in a upcoming release :slight_smile:

Really looking forward to this!

most important sensors implemented :+1:

1 Like

This is such an excellent project. Thank you for your time.

Sure Petcare have a feeder, that discriminates between pets and logs the amount eaten, due for release shortly.

Do you expect to support that too?

Can you sponsor me and my cat such a feeder (you talk about the unreleased „Feeder Connect“ right?) for development? :grin: :sweat_smile:

Hi Guys, For those of you who are running Hass.io, this is the way I got it working.
I’m currently on Version 0.89.2.
Please follow the instructions carefully!

  1. Create a folder called “sure_petflap” within “config\custom_components\
  2. Navigate to “config\custom_components\sure_petflap
  3. Copy and paste the following file: “sure_petflap.py” from the repo to location: “config\custom_components\sure_petflap”. You find the file in the following location of this repo “sure_petcare/home_assistant
  4. Rename the file from: “sure_petflap.py” to: “sensor.py
  5. Copy and paste the following files: “__init__.py” and " “utils.py” from the repo to location: “config\custom_components\sure_petflap”. You find the files in the following location of this repo “sure_petcare/sure_petcare”.
  6. Make the following changes in file “sensor.py”. (The file you renamed in step 4).
    Replace line 5-43 with the following below (If you get any errors. Please copy the code from here to notepad and then from notepad to “sensor.py”):
#def is_hass_component():
#    try:
#        import homeasssistant
#        return True
#    except ImportError:
#        return False

#if is_hass_component():
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD)
import homeassistant.helpers.config_validation as cv

from . import SurePetFlap
from .utils import gen_device_id

import voluptuous as vol

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})
#else:
    # Assume not running within home assistant.  This *does* mean that you
    # won't be able to run this test script if you have homeassistant
    # installed but, if you do, you're probably running (or can run) this
    # component from within hass anyway.
#    from sure_petcare import SurePetFlap
#    from sure_petcare.utils import gen_device_id

    # dummy dependencies
#    class Entity( object ):
#        pass

#    def Throttle( *args, **kwargs ):
#        def decorator( f ):
#            return f
#        return decorator
  1. Make the following changes in file “__init__.py”.
    Replace line 11-12 with the following below (If you get any errors. Please copy the code from here to notepad and then from notepad to “__init__.py”):

import utils as utils
from .utils import mk_enum

  1. Now your file structure should look like this:
    - custom_components
    | - sure_petflap
    | - | - sensor.py
    | - | - utils.py
    | - | - __init__.py
    And you have made changes to: “sensor.py” & “__init__.py

  2. Now it’s time to setup the platform sensor. Please do not set up any other configurations as for now such as template sensors, groups, binary_sensors etc.
    Set up the following in one of your .yaml files:

sensor:
  - platform: sure_petflap
    username: [email protected]
    password: xxxxxxxxxxx
  1. Restart your hassio. Either from the web or with ssh: hassio homeassistant restart

  2. Navigate to dev-state in your Home Assistant to find the entity. Look for: sensor.surepet_connect

Best of luck!
//Asif

6 Likes

Great write up. Thank you for taking the time.

So, does this only apply to Rpi? I run HA on a mac mini. What will the differences be?