I copy and past this so the dummies have a starting point.
I hope you like it.
esphome:
name: camera_1
friendly_name: Camera
esp32:
board: esp32cam
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "??????????????"
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.87
gateway: 192.168.1.1
subnet: 255.255.255.0
ap:
ssid: "Jj Fallback Hotspot"
password: "???????????"
esp32_camera:
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: 640x480
reset_pin: GPIO15
name: Camera
id: camera
jpeg_quality: 10
special_effect: none
saturation: 0
brightness: 1
contrast: 0
horizontal_mirror: True
vertical_flip: False
agc_mode: auto
agc_gain_ceiling: 2x
aec_mode: auto
agc_value: 0
wb_mode: auto
test_pattern: False
#on_stream_start (Optional, Automation):
#on_stream_stop (Optional, Automation):
servo:
- id: pan_servo_1
output: pan
transition_length: 22s # this is for the speed lower is quicker
- id: tilt_servo_1
output: tilt
transition_length: 22s
output:
- platform: ledc
pin: GPIO4
channel: 2 # channel 1 is used for esp32_camera
id: ledlamp
- platform: ledc
id: pan
pin: GPIO13
frequency: 50 Hz
- platform: ledc
pin: GPIO12
#channel: 2 # channel 1 is used for esp32_camera
frequency: 50 Hz
id: tilt
number:
- platform: template
name: Led
optimistic: true
min_value: 0
max_value: 100
step: 1
mode: slider
on_value:
then:
lambda: 'id(ledlamp).set_level(x/100);'
- platform: template
name: Pan
min_value: -100
initial_value: 0
max_value: 100
step: 1
mode: slider
optimistic: true
set_action:
then:
- servo.write:
id: pan_servo_1
level: !lambda 'return x / 100.0;'
- platform: template
name: Tilt
min_value: -100
initial_value: 0
max_value: 100
step: 10
mode: slider
optimistic: true
set_action:
then:
- servo.write:
id: tilt_servo_1
level: !lambda 'return x / 100.0;'
#mqtt:
# broker: 192.168.1.44
# username: !secret mqtt_username
# password: !secret mqtt_passwort
# birth_message:
# will_message:
# on_message:
# - topic: led
# payload: 'ON'
# then:
# - output.set_level:
# id: ledlamp
# level: "100%"
# - delay: 1000ms
#This works for restarting the esp every 30 minutes:
time:
- platform: sntp
# ...
on_time:
# Every 30 minutes
- minutes: 30
then:
- switch.toggle: restart_cam
switch:
- platform: restart
name: "Restart cam"
id: restart_cam
- platform: gpio
pin: GPIO32
name: "Pan auto"
id: pan_auto
- platform: gpio
pin: GPIO33
name: "Tilt auto"
id: tilt_auto
# camera webserver
esp32_camera_web_server:
- port: 8080
mode: stream
- port: 8081
mode: snapshot
#### automation.yaml and sure the same for tilt change pan to tilt ########
#alias: Auto Pan Camera 1
#description: ""
#trigger:
# - platform: state
# entity_id:
# - switch.camera_1_pan_auto
# from: "off"
# to: "on"
# for:
# hours: 0
# minutes: 0
# seconds: 1
#condition: []
#action:
# - repeat:
# sequence:
# - device_id: a7e1d6ab0e735ede7c5e2f2c960e7ffe
# domain: number
# entity_id: d389ac3c7768143fdf89d5664484b8d2
# type: set_value
# value: -100
# - delay:
# hours: 0
# minutes: 0
# seconds: 22
# milliseconds: 0
# - device_id: 18891684c1237bb6cff2994830aaedbc
# domain: number
# entity_id: c495fcb21ef93d9503973d2289140b4f
# type: set_value
# value: 100
# - delay:
# hours: 0
# minutes: 0
# seconds: 22
# milliseconds: 0
# until:
# - condition: state
# entity_id: switch.camera_1_pan_auto
# state: "off"
# for:
# hours: 0
# minutes: 0
# seconds: 1
# - condition: state
# entity_id: switch.camera_1_pan_auto
# state: "off"
# for:
# hours: 0
# minutes: 0
# seconds: 1
# - device_id: 18891684c1237bb6cff2994830aaedbc
# domain: number
# entity_id: c495fcb21ef93d9503973d2289140b4f
# type: set_value
# value: 0
#mode: single
##################