I was tinkering with my ESP32-Cam board /w ESPhome 1.12.2 and 0.91 Home Assistant. I made a working doorbell with telegram notification via an automation. Its not perfect but I thought I’d share what I got so far.
You need:
An ESPhome Node with a camera (duh), also I made the trigger/button on the same node.
(I used a board like this )
A whitelisted folder to store the image the camera takes.
Telegrambot set up in home assistant.
I will try to flesh out this post further as needed.
(flashing connections for the board I have, the green wire is connected when flashing only)
ESPHome node:
esphome:
name: doorbellcam
platform: ESP32
board: esp-wrover-kit
wifi:
ssid: 'yourssid'
password: 'yourpass'
manual_ip:
static_ip: x.x.x.x
gateway: x.x.x.x
subnet: 255.255.255.0
logger:
api:
ota:
esp32_camera:
name: doorbellcam
external_clock:
pin: GPIO0
frequency: 20MHz
i2c_pins:
sda: GPIO26
scl: GPIO27
data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
vsync_pin: GPIO25
href_pin: GPIO23
pixel_clock_pin: GPIO22
power_down_pin: GPIO32
resolution: 1024x768
jpeg_quality: 10
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: True
name: snap
text_sensor:
- platform: wifi_info
ip_address:
icon: "mdi:ip"
name: doorbellcam IP
ssid:
name: doorbellcam SSID
icon: "mdi:access-point-network"
bssid:
name: doorbellcam BSSID
icon: "mdi:access-point-network"
sensor:
- platform: wifi_signal
name: "WiFi doorbellcam"
update_interval: 60s
Automation:
- alias: Doorbell
trigger:
- platform: state
entity_id: binary_sensor.snap
to: 'on'
action:
- service: camera.snapshot
data:
entity_id: camera.doorbellcam
filename: '/myfolder/doorbell.jpg'
- delay: '00:00:02'
- service: notify.doorbellbot
data:
title: TEST
message: "Doorbell rung!"
data:
photo:
- file: /myfolder/doorbell.jpg
caption: Doorbell View
In configuration.yaml:
(in my docker I made the /myfolder relfect the /www folder inside Home Assistant)
homeassistant:
whitelist_external_dirs:
- /myfolder
telegram_bot:
- platform: polling
api_key: !!! INSERT API KEY HERE !!!
allowed_chat_ids:
- XXXXXXXXXXXX
notify:
- name: doorbellbot
platform: telegram
chat_id: xxxxxxx
End result:
It is working, however if anyone has improvements I’m all ears
Its a $10 doorbell!
It could probably use an “anti spam” mechanism, and some of the data I’m supposed to send to telegram doesn’t arrive; the title and message.
The ‘snap’ binary sensor is connected to GPIO12 and when you connect it to ground via a button or the redneck way by touching two wires like i did, it will snap a image. Also the board has a built in flash that is connected to GPIO4, it lights up when you give it power. Not really figured out how to use it in a good way yet, kinda have to use a relay or pwm on it coupled with a lux sensor and have it activate when needed. Personally I’m thinking of just adding some IR leds that light up for the camera when needed.