Catdoor - autoclose

Hi,

We have a catdoor which, with 9 cats, is very often in use. Depending on the cat walking through and the weather outside I get wind drafts which are so strong the lid does not close. This is not good for our heating costs.

The first step I took was to add a homematic closing sensor on the lid. if it stays open for 60 seconds all alexa devices in the house will say a random sentence.

Thats nice - but not enough. I want this damn thing closed and not woken up at 3 in the morning.

For the longest time i wanted to play around with ESP8266 - and with esphome i dont have to learn how to code. (i can code - but not in that language, and i feel to old and stuborn to learn something new :slight_smile:

So long story short - I was not able to do it without learning something new - which in my case was Fusion360 for the 3dprinted casing :slight_smile: but this was on my bucketlist for the longest time.

The 60second - Door is open automatition looks like:

alias: Wenn Katzenklappe länger als 60 Sekunden als offen gezeigt wird
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.0000dd898a15d7_state
    to: 'on'
    for: '00:01:00'
condition: []
action:
  - service: notify.alexa_media
    data:
      target: group.echo_house
      data:
        type: announce
        method: all
      message: >-
        {{ [ "Katzenklappe, Alter!", "Sags ja ungern, aber die Katzenklappe ist
        schon wieder offen", "Mistress, darf ich Sie darauf aufmerksam machen
        daß die scheiß Katzenklappe schon wieder offen steht!", "Die Katzen
        haben die Klappe schon wieder offen gelassen", "Der Wind pfeift weil die
        Klappe wieder mal offen steht!", "Erhöhe Heizleistung um den Windzug der
        Katzenklappe auszugleichen!", "Katzenklappe!", "Mir ist kalt. Scheiß
        Katzenklappe", "Cookie ist in einem Rohbau aufgewachsen!", "Tür zu es
        zieht!" ] | random }}
      title: Katzenklappe
mode: single

The automation for the 30 second auto close time:

alias: Wenn Katzenklappe länger als 30 Sekunden als offen gezeigt wird mach sie zu
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.0000dd898a15d7_state
    to: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 30
condition: []
action:
  - condition: numeric_state
    entity_id: sensor.distance_sensor
    above: '0.16'
  - service: input_number.set_value
    data:
      value: 100
    target:
      entity_id: input_number.catdoor_servo
  - delay:
      hours: 0
      minutes: 0
      seconds: 8
      milliseconds: 0
  - service: input_number.set_value
    data:
      value: -100
    target:
      entity_id: input_number.catdoor_servo
mode: single

As you can see there is an aditional distance sensor i integrated in to the case. so i know if a cat has left their tail in the door - which happens occasionly. If for any reason it cant be closed or the tiny servo is not strong enough the 60 second warning will still trigger. Lets see how it goes… maybe i add a stronger servo if needed.

Finaly - the moment you waited for Images …



Here a short video of the thing in action

The ESPHome config for it looks like:

esphome:
  name: catdoor
  platform: ESP8266
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: control_servo
      variables:
        level: float
      then:
        - servo.write:
            id: my_servo
            level: !lambda 'return level / 100.0;'
            
ota:
  password: "xxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  ap:
    ssid: "Catdoor Fallback Hotspot"
    password: "xxxxxxxx"

captive_portal:

output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D4
    frequency: 50 Hz

servo:
  - id: my_servo
    output: pwm_output
    transition_length: 5s
    auto_detach_time: 0.5s
    restore: true
    
sensor:
  - platform: ultrasonic
    trigger_pin: D5
    echo_pin: D6
    name: "Distance Sensor"
    update_interval: 5s

Ludwig aka Rufinus

3 Likes