Sureflap Connect - Pet Door

Hi,
It shouldn’t be any difference. As long as you are running Hass.io these instructions should work.
//Asif

Maybe it’s me or maybe 0.90.1 changed something in the custom components but I can’t get it to work :frowning:

First of all, I had to add these lines before the new lines in __init__.py:

import sys
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) )

Just so it would look for utils.py in the ~/.homeassistant/custom_components/sure_petflap/ directory

But that still doesn’t make the component work. I bugs out with the following error:

AttributeError: module 'custom_components.sensor.sure_petflap' has no attribute 'setup_platform'

Anyone any thoughts? (I cloned the repo today: March 24, 2019)

I can confirm that I my guide works with Hass.io version: 0.90.1 Running on RPI.
hmm, have you configured any template sensors etc?
Start with just setting up the surepet platform. Are you still getting that error?

1 Like

Nope, no template sensore, binairy sensors, groups or anything.
Just:

- platform: sure_petflap
username: [email protected]
password: ******

I will retry all the steps from start and see if I made a mistake somewhere

Nope, redone the whole install according to the steps by @asif

The complete error from home-assistant.log:

2019-03-24 21:49:41 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform sure_petflap
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 124, in _async_setup_platform
task = async_create_setup_task()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py”, line 89, in async_create_setup_task
None, platform.setup_platform, hass, platform_config,
AttributeError: module ‘custom_components.sensor.sure_petflap’ has no attribute ‘setup_platform’

I tried manually running sp_cli.py which gave no issues at all

Could you upload all your files within the config\custom_components\sure_petflap folder?

Found my booboo… In my environment (virtualenv) custom_components is not located under config but directly under ~/.homeassistant and I had the directory sure_petflap located under custom_components/sensors in stead of under custom_components

Fixed my mistakes and now I have my Sure Catflap connected to HASS :smiley:

1 Like

Thank you! It works perfekt!

1 Like

Härligt :)!!

Thanks for the write up, finally go this up and running in hassio. Can you give me some pointers as how to create a Lovelace card for individual items please or to see the list of items. ATM I can only see the list in devtools/States

1 Like

The feeder arrives today!

I’ll let you know how it performs.

1 Like

This is my config to setup the entities:

sensor:
  - platform: sure_petflap
    username: [email protected]
    password: xxxxx
    
  - platform: template
    sensors:
      jenna_status:
        friendly_name: "Jenna Status"
        value_template: "{{ state_attr('sensor.surepet_connect', 'Jenna') }}"
      flap_battery_status:
        friendly_name: "Sure Flap Battery"
        value_template: "{{ state_attr('sensor.surepet_connect', 'battery') }}"
        unit_of_measurement: '%'
      flap_batterystatus:
        friendly_name: Sure Flap Battery
        value_template: >
          {% if is_state('sensor.surepet_connect', 'unknown') %}
            110
          {% else %}
            {{ states.sensor.surepet_connect.attributes["battery"] | float}}
          {% endif %}
        icon_template: > 
          {% set battery_level_xod1 = states.sensor.surepet_connect.attributes.battery|default(0)|int %}
          {% set battery_round_xod1 = (battery_level_xod1 / 10) |int * 10 %}
          {% if battery_round_xod1 >= 100 or is_state('sensor.surepet_connect', 'unknown') %}
            mdi:battery
          {% elif battery_round_xod1 > 0 %}
            mdi:battery-{{ battery_round_xod1 }}
          {% else %}
            mdi:battery-charging-wireless-outline
          {% endif %}
        unit_of_measurement: '%'

  - platform: history_stats
    name: Jenna outside time (today)
    entity_id: sensor.Jenna_status
    state: 'Outside'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
  - platform: history_stats
    name: Jenna trips outside (today)
    entity_id: sensor.Jenna_status
    state: 'Outside'
    type: count
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: '{{ now() }}'
  - platform: history_stats
    name: Jenna outside (yesterday)
    entity_id: sensor.Jenna_status
    state: 'Outside'
    type: time
    end : '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    duration:
      hours: 24
  - platform: history_stats
    name: Jenna trips outside (yesterday)
    entity_id: sensor.Jenna_status
    state: 'Outside'
    type: count
    end : '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
    duration:
      hours: 24

binary_sensor:
  - platform: template
    sensors:
      lock_status:
        friendly_name: "Sure Flap"
        device_class: lock
        value_template: "{{ not states.sensor.surepet_connect.attributes.locked}}"
        icon_template : >
          {% if states.sensor.surepet_connect.attributes.locked %}
            mdi:lock
          {% else %}
            mdi:lock-open
          {% endif %}
      flap_status:
        friendly_name: "Flap online Status"
        device_class: connectivity
        value_template: "{{ states.sensor.surepet_connect.attributes.flap_online }}"
        icon_template : >
          {% if states.sensor.surepet_connect.attributes.flap_online %}
            mdi:wifi
          {% else %}
            mdi:wifi-off
          {% endif %}
      hub_status:
        friendly_name: "Hub online Status"
        device_class: connectivity
        value_template: "{{ states.sensor.surepet_connect.attributes.hub_online }}"
        icon_template : >
          {% if states.sensor.surepet_connect.attributes.hub_online %}
            mdi:wifi
          {% else %}
            mdi:wifi-off
          {% endif %}

And this is my Lovelace GUI:

8 Likes

Thank you Asif, I shell work my way through this as Im quite new to HA but learning fast, this helps a lot.

Riktigt snyggt @asif. Har du lust att dela med dig av koden för lovelace-kortet?

Sure/Absolut :slight_smile:

These are the custom js and modules I’m using. Please google on how to add custom js and modules to your ui-lovelace.yaml

- type: js
  url: /customcards/lovelace/card-modder.js

- type: module
  url: /customcards/lovelace/circle-sensor-card.js

And here is the Code:

  - type: vertical-stack
    cards:
      - type: custom:card-modder
        style:
          border-radius: 20px
          border: solid 1px rgba(100,100,100,0.3)
          box-shadow: 3px 3px rgba(0,0,0,0.4)
          overflow: hidden
          animation: '[[ sensor.flap_batterystatus.state ]] 2s linear infinite'
          # animation: [[ if(sensor.washer_animation == 'Clean', "blink 2s linear infinite", "none") ]]
        extra_styles: >
          @keyframes 0.0 {
            
            50% {
              outline: 3px solid #389638;
            }
          }
        card:
          type: picture-elements
          image: /local/images/jenna_inside.jpg
          elements:
            - type: image
              entity: sensor.jenna_status
              style:
                top: 50%
                left: 50%
                width: 100%
              state_image:
                "Inside": /local/images/jenna_inside.jpg
                "Outside": /local/images/jenna_outside.jpg
            - type: image
              entity: sensor.jenna_status
              image: /local/images/cat.svg?v1
              state_filter: 
                "Inside": invert(.5) sepia(1) saturate(8) hue-rotate(10deg)
                "Outside": invert(.90)
              tap_action: more-info
              style: {color: white, left: 10%, top: 88%}
            - type: state-label
              entity: sensor.jenna_status
              style: {color: white, left: 10%, top: 95%}
            - type: state-icon
              entity: binary_sensor.lock_status
              tap_action: more-info
              style: {color: white, left: 25%, top: 88%}
            - type: state-label
              entity: binary_sensor.lock_status
              style: {color: white, left: 25%, top: 95%}
            - type: state-icon
              entity: sensor.flap_batterystatus
              tap_action: more-info
              style: {--paper-item-icon-color: green, color: white, left: 40%, top: 88%}
            - type: state-label
              entity: sensor.flap_batterystatus
              style: {color: white, left: 40%, top: 95%}
            - type: state-icon
              entity: binary_sensor.hub_status
              tap_action: more-info
              style: {color: white, left: 70%, top: 88%}
            - type: state-label
              entity: binary_sensor.hub_status
              style: {color: white, left: 70%, top: 95%}
            - type: state-icon
              entity: binary_sensor.flap_status
              tap_action: more-info
              style: {color: white, left: 90%, top: 88%}
            - type: state-label
              entity: binary_sensor.flap_status
              style: {color: white, left: 90%, top: 95%}

      - type: horizontal-stack
        cards:
          - type: custom:circle-sensor-card
            entity: sensor.jenna_outside_time_today
            show_card: true
            name: Jenna outside (today)
            max: 24
            min: 0
            stroke_width: 7
            gradient: true
            units: 'H'
            font_style:
              color: white
              font-size: 1em
            fill: rgba(54, 128, 173, 0.23)
            color_stops:
              3: '#55FF55'
              10: '#5555FF'
              15: '#FF5555'
            style:
              top: 50%
              left: 50%
              width: 50px
              height: 50px
          - type: custom:circle-sensor-card
            entity: sensor.jenna_outside_yesterday
            show_card: true
            name: Jenna outside (yesterday)
            max: 24
            min: 0
            stroke_width: 7
            gradient: true
            units: 'H'
            font_style:
              color: white
              font-size: 1em
            fill: rgba(54, 128, 173, 0.23)
            color_stops:
              3: '#55FF55'
              10: '#5555FF'
              15: '#FF5555'
            style:
              top: 50%
              left: 50%
              width: 50px
              height: 50px

      - type: vertical-stack
        cards:
          - type: entities
            show_header_toggle: false
            entities:
              - entity: sensor.jenna_trips_outside_today
                name: Jenna trips outside (today)
                icon: mdi:chart-line
              - entity: sensor.jenna_trips_outside_yesterday
                name: Jenna trips outside (yesterday)
                icon: mdi:chart-line
3 Likes

Thank you!

1 Like

Nice! Will this be read and write? So we can set the lock status from HA?

Anyone got pointers on getting this working with HA running in docker on Ubuntu ?

Not having any luck figuring it out.

Thank you so much!

Thanks for this, it’s working well for me on a Pi with hass.io :slight_smile: