Scaring birds with Home Assistant

I have had issues with birds on our patio. They poop on our furniture and attack our windows (they see their reflection and think it’s another bird). I didn’t want to have bird spikes on our furniture or a fake owl, or any other standard bird control devices, so I used HA with Frigate.

Frigate uses the Amcrest 8MP camera to look for birds. When it sees one it flashes the patio lights and plays an audio track of gunshots to scare the birds away. It also sends me a notification with a snapshot of the bird, I will likely remove the notifications in the future, but it’s been helpful right now as I debug it and adjust the sensitivity.

This automation has a huge WAF!

The system in action

Frigate detecting the bird

Here are my settings

Frigate.yaml

record:
  enabled: true
  retain:
    days: 0
  events:
    max_seconds: 300
    retain:
      default: 10
      mode: motion

motion:
  # Optional: Minimum size in pixels in the resized motion image that counts as motion (default: 30)
  # Increasing this value will prevent smaller areas of motion from being detected. Decreasing will
  # make motion detection more sensitive to smaller moving objects.
  # As a rule of thumb:
  #  - 15 - high sensitivity
  #  - 30 - medium sensitivity
  #  - 50 - low sensitivity
  contour_area: 17

cameras:
  patio:
    ffmpeg:
      inputs:
        - path: rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0
          roles: 
            - detect
    detect:
      width: 3840
      height: 2160
    objects:
      track:
        - person
        - bird 
      filters:
        bird:
          # Optional: minimum score for the object to initiate tracking
          min_score: 0.1
          # Optional: minimum decimal percentage for tracked object's computed score to be considered a true positive
          threshold: 0.2
          mask:
            # Masks near the patio door so it won't detect bugs as birds
            - 0,2160,0,0,709,0,986,2160
            # Masks the window
            - 822,771,1475,664,1472,34,763,124
        person:
          mask:
            # Masks the dining room window
            - 845,944,1489,783,1450,28,735,124
            # Masks the backyard to prevent detection of someone in the yard
            - 3419,1009,3682,0,2667,0,2585,562
    motion:
      mask:
        # Masks the top area of the patio to block the Reserve sign from being seen as a person
        - 3572,337,3584,262,2963,29,2845,0,2629,29
    snapshots:
      enabled: true
      timestamp: false
      bounding_box: true
      retain:
        default: 3

Automation:

- id: '1650462395368'
  alias: Patio - Scare Birds
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.patio_bird_motion
    to: 'on'
  condition:
  - condition: state
    entity_id: binary_sensor.patio_person_motion
    state: 'off'
    for:
      hours: 0
      minutes: 1
      seconds: 0
  action:
  - service: camera.snapshot
    data:
      filename: /config/www/patiobird.jpg
    target:
      entity_id: camera.patio_bird
  - service: media_player.volume_set
    data:
      volume_level: 1
    target:
      entity_id:
      - media_player.chromecastultra8115
      - media_player.patio_google_home
  - service: media_player.play_media
    data:
      media_content_id: https://MYURL.com/local/gunshots.mp3
      media_content_type: Music
    target:
      entity_id:
      - media_player.chromecastultra8115
      - media_player.patio_google_home
  - service: notify.mobile_app_brad_s_s21_ultra
    data:
      message: Bird spotted on patio at {{ now().strftime('%I:%M %p') }}
      data:
        image: https://MYURL.com/local/patiobird.jpg
  - service: script.turn_on
    data: {}
    target:
      entity_id: script.patio_lights_flash
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id:
      - media_player.chromecastultra8115
      - media_player.patio_google_home
  mode: single

Light flash script (There may be a better way to do this)

patio_lights_flash:
  alias: Patio Lights - Flash
  sequence:
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_on
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_on
      data:
        brightness_pct: 100
      target:
        entity_id: light.patio_can_lights
    - delay:
        hours: 0
        minutes: 0
        seconds: 2
        milliseconds: 0
    - service: switch.turn_off
      data: {}
      target:
        entity_id: switch.patio_wall_lights
    - service: light.turn_off
      data: {}
      target:
        entity_id: light.patio_can_lights
  mode: single
10 Likes

This is a great idea, I am thinking of setting up something like this for my balcony.

One thing I can suggest is using sounds of birds of prey instead. That would likely be more effective at scaring them while also being less disruptive.

Brilliant!

We have lots of ground quirrels this year and I should try setting up Frigate to see if it detects them.

I wonder if there is an outdoor rated transducer that produces a gunshot like sound. Or a loud clap.

Are you still around @bphillips921 and is this project still operational at your place?

I’m getting ideas for something very similar (pigeons) and so am interested in long term results.

I’m still here. This is still operational but it has lost some effectiveness. The birds have gotten use to it.

1 Like

Thanks. I’ll keep you posted on where I land.
My solution is likely to be pretty similar. The internet is a rabbit hole of things that people say do and don’t work.

Was thinking flashing lights and various sounds too (predators, distress calls etc) and maybe ultrasonic (also jury is out on that).

Would love a auto homing waterspray rig but not having power or water on my balcony makes things even more challenging;) Might be able to send some power out the window but its a bit sketchy.

Hello

This is awesome!!!

What camera do you have to recognise the birds?

I would love to do this and have my sprinklers turn on as the birds have destroyed the lawn.

Thanks

I had pigeons going to my balcony, so I tried putting bird of prey stickers there, but those had no effect.
I already had a camera there, so I added Echo Dot, and configured Frigate to detect birds. In HA I created automation - if bird is detected, send notification with picture to my phone and play hawk sound on that Echo. Got that notification once and never again saw them on my balcony. That was last summer, so hopefully it stays that way :slight_smile:

I have this camera - https://www.aliexpress.com/item/1005004101225074.html - but as the detection is done by Frigate, I think any camera will work.