Greetings…
I thought I would offer what solution I have in place to monitor perimeter activity. I have several laser beams that I use to trigger, not alarms, but notifications of someone or something such as a vehicle passing through my perimeter. The events can, of course, be tailored to trigger any kind of action you desire.
I use the Seco PN# E-931-S35RRQ Laser beam. It is available on Amazon. It runs around $50. I have had great success with these. I use the following ESPHome code to create the sensors. I have never had a single false positive. When the laser beam is broken, it was indeed broken. Albeit I have had a few birds fly though it and triggered it. If the beam is placed high enough off the ground, it will prevent animals such as dogs, cats and the like from triggering. And aside from owls and bats, no flying creatures at night, at least not in my neck of the woods.
Here’s the code I use.
esphome:
name: 'gatecontroller'
friendly_name: Frontgate Controller
platformio_options:
upload_speed: 115200
esp32:
board: 'wt32-eth01'
ethernet:
type: 'LAN8720'
mdc_pin: 'GPIO23'
mdio_pin: 'GPIO18'
clk_mode: 'GPIO0_IN'
phy_addr: 1
power_pin: 'GPIO16'
manual_ip:
static_ip: 10.2.4.10
gateway: 10.2.4.1
subnet: 255.255.255.0
#web_server:
# port: 8089
# local: true
mqtt:
broker: 10.2.0.44
username: !secret mqtt_user
password: !secret mqtt_password
topic_prefix: frontgate
logger:
on_message:
level: DEBUG
then:
- mqtt.publish:
topic: frontgate/log
payload: !lambda |-
return "level: " + to_string(level) + "|tag: " + tag + "|message: " + message;
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
password: !secret ota_password
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
binary_sensor:
# Gate Status - Reed Switch Open/Closed?
- platform: gpio
pin:
number: 15
mode:
input: true
# pullup: true
pullup: true
output: false
open_drain: false
pulldown: false
inverted: false
id: gate_position
name: Front Gate Position
icon: "mdi:door-sliding-lock"
device_class: door
# filters:
# - delayed_on: 10ms
# disabled_by_default: false
# GATE BEAM1
# PhotoElectic Beam Sensor
# Seco PN# E-931-S35RRQ
# - GRAY Wire - Normally Closed - is a CLOSED circuit which opens when the beam is broken
# - WHITE Wire - Comm
# - BLUE wire - Ground
# - BROWN Wire - Voltage 24v
- platform: gpio
pin:
number: 14
# mode: INPUT_PULLUP # Will go LOW when the beam is broken and circuit is closed
# inverted: True
mode:
input: true
pullup: true
output: false
open_drain: false
pulldown: false
inverted: false
id: gate_beam1_sensor
icon: "mdi:dots-horizontal"
name: "Beam 1 Status"
device_class: motion
filters:
- delayed_on: 10ms
# Perimeter BEAM2
# PhotoElectic Beam Sensor
# Seco PN# E-931-S35RRQ
# - GRAY Wire - Normally Closed - is a CLOSED circuit which opens when the beam is broken
# - WHITE Wire - Comm
# - BLUE wire - Ground
# - BROWN Wire - Voltage 24v
- platform: gpio
pin:
number: 12
# mode: INPUT_PULLUP # Will go LOW when the beam is broken and circuit is closed
# inverted: True
mode:
input: true
pullup: true
output: false
open_drain: false
pulldown: false
inverted: false
id: perimeter_beam2_sensor
icon: "mdi:dots-horizontal"
name: "Beam 2 Status"
device_class: motion
filters:
- delayed_on: 10ms
# GATE OPENER RELAY
switch:
- platform: gpio
pin: GPIO2
name: "Gate Relay"
id: gate_motor_controller
internal: false
sensor:
- platform: dht
pin: GPIO4
temperature:
name: "Gate Controller Box Temperature"
humidity:
name: "Gate Controller Box Humidity"
update_interval: 60s
cover:
- platform: template
device_class: gate
name: "Frontgate Status"
id: template_cover_frontgate
lambda: |-
if (id(gate_position).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: gate_motor_controller
- delay: 300ms
- switch.turn_off: gate_motor_controller
close_action:
- switch.turn_on: gate_motor_controller
- delay: 300ms
- switch.turn_off: gate_motor_controller