ESPhome ESP32 controlled Cat Deterrent station

Thought I’d share this project because it’s been very successful at encouraging the numerous stray cats in my suburb from coming into my yard at night and pissing on everything and anything, causing foul stink, and house & car damage (cat pee strips off paint and zinc metal coatings if done often enough).
We have our own cats too, so the system has to deactivate (via HA automation) during day light hours when our cats are allowed outside.
The unit squirts commercial party silly string at the cats, which scares them away but causes no physical harm. They don’t seem to come back…

The build consists of a 3D printed ABS plastic RC servo spray can adapter (STL file from Thingiverse.com), an ESP32 board, a servo (obviously), a AM312 Infrared motion sensor (same as used in the Bruh Automation Multi Sensor project), a mini SPST switch, a couple of LEDs and 0.5k resistors, a small project box etc. Additionally I home printed a tall ring go block the side vision of the AM312 to get a narrow detection angle from it.

It operates by sitting outside in the yard in an area where the stray cats piss regularly, and is only armed at night by HA (don’t want to scare the meter reader or postman do I !). When a hot object is detected by the AM312 the ESPhome code check that the manual ARM switch on the back of the box is ON, then also checks if the HA remote blocking is OFF (off at night), then squirts 0.7 seconds of silly string by moving the servo by a set amount and back. The code gives the operator 10 seconds to clear out once the local arm switch is thrown, HA can block anyway and the final ARM be done remotely if wanted.

The wiring can be worked out from the ESPhome devices YAML file, it’s nothing special.

The pictures will tell the story best I hope.

esphome:
  name: servo_actuator_1
  platform: ESP32
  board: esp32doit-devkit-v1

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

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

# Create Status LED using the ESP32 blue LED
status_led:
  pin: GPIO2

sensor:
  - platform: wifi_signal
    name: "Servo actuator #1 WiFi Signal Sensor"
    update_interval: 60s  
    
binary_sensor:

  - platform: status
    name: "Servo actuator #1 Status"
    
  - platform: gpio
    pin: GPIO23
    name: "Servo actuator #1 Motion"
    device_class: motion
    on_press:
      then:
        if:
          condition:
            and:
              - binary_sensor.is_on: esp32_arm_switch
              - switch.is_off: ha_remote_arm_switch
          then:
            - output.turn_on: yellow_led
            - output.set_level:
                id: gpio_21_servo
                level: 100.0% # 100% = 2mS as set by 'max_power'
            - delay: 700ms    
            - output.set_level:
                id: gpio_21_servo
                level: 0.0%  # 0% = 1mS as set by 'min_power'
          else:
            - output.turn_on: yellow_led

    on_release:
      then:
        - output.turn_off: yellow_led  
        - output.set_level:
            id: gpio_21_servo
            level: 0.0%  # 0% = 1mS as set by 'min_power'     

  - platform: gpio
    pin: GPIO18
    name: "Control Board Arm Switch"
    id: esp32_arm_switch
    device_class: safety    # ...
    filters:
      - delayed_on: 10000ms
    on_press:
      then:
        - output.turn_on: yellow_led
        - delay: 1500ms
        - output.turn_off: yellow_led

# Using Light component to set a standard RC servo position
light:
  - platform: monochromatic
    output: gpio_21_servo
    name: "Servo actuator #1 - Servo Pos"
    default_transition_length: 0ms

#create a logical switch that HA can control
switch:
  - platform: output
    name: "HA Remote Arm Switch"
    output: 'green_led'
    id: ha_remote_arm_switch

# Using ledc output to control a standard 50Hz RC servo over the normal 1 to 2 mS pulse range
output:
  - platform: ledc
    pin: GPIO21
    id: gpio_21_servo
    frequency: 50 Hz
    min_power: 5.0%    # 5% at 50Hz is 1mS  (20mS cycles)
    max_power: 10.0%   # 10% at 50Hz is 2mS (20mS cycles)

  - platform: gpio
    pin: GPIO15
    inverted: false
    id: yellow_led
    
  - platform: gpio
    pin: GPIO19
    inverted: false
    id: green_led

In HA lovelace frontend I’ve renamed the switches and sensors to something more fitting to the task.

6 Likes

Is that you Turnah81? https://www.youtube.com/user/Turnah81/videos

1 Like

Fantastic. Just amazing concept.

One question though, what is that silly string made of? Are you left with a whole lot of plastic waste?

LOL, no. Same country though, he’s a few thousand K’s West of me.

No, silly string seems to be something more organic. It eventually dries out and breaks up like paper and can be swept up and disposed of.
http://www.silly-string.com//silly-info/index.cfm

The entertaining end of the project comes from here, though most super markets sell it here anyway.
https://www.rejectshop.com.au/All-Products/Stationery/Partyware/Silly-String-100g/p/22125422

Looks amazing,
would you mind sharing more information?

  • link to the STL
  • how you did connect the components
  • some tips

Thanks a lot

Just looked for the STL’s unsuccessfully, too many HDD’s ago…
I’ve found a better way now as well.

A trespassing cat ‘hydration system’. So my home lawn irrigation is now controlled by HA and ESPhome. I have various 433Mhz RF motion sensors spare. One of which I have a weather shield over (plastic milk bottle) with slot for the IR sensor. When the sensor is triggered late at night across the lawn (while my own cat is inside like a good owner would do) HA can ‘test’ my lawn sprinklers for 30 seconds. Worked as treat so far. As a precaution it will be disabled for ten minutes by the house door opening, don’t need to hydrate myself on a dark night…

Perhaps Servo controlled Silly-String Trigger by sliptonic - Thingiverse

Yep that’s it. 300+ designs in my current 3D printing folder so forgot I cribbed this one. I did make a different side plate for the servo as I had a different size one. I also made a thin collar that snaps under the main assembly because that design is very loose when on the can, and the servo action was a bit erratic without it. Looking at my image above I have made slightly sloped upwards can base as well to get more range :slight_smile: