Refactor ESP32 camera configuration and add dynamic controls for brightness, contrast, and AE level tuning

This commit is contained in:
Joshua King
2026-09-08 10:01:04 -04:00
parent 29f65b921e
commit b782e249f5
+59 -12
View File
@@ -56,34 +56,42 @@ mdns:
web_server:
port: 80
i2c:
- id: camera_i2c
sda: GPIO8
scl: GPIO9
scan: false
esp32_camera:
name: "${friendly_name}"
external_clock:
pin: GPIO5
frequency: 20MHz
i2c_id: camera_i2c
i2c_pins:
sda: GPIO8
scl: GPIO9
data_pins: [GPIO16, GPIO18, GPIO21, GPIO17, GPIO14, GPIO7, GPIO6, GPIO4]
vsync_pin: GPIO1
href_pin: GPIO2
pixel_clock_pin: GPIO15
# Start conservative for reliability; increase later if stable.
resolution: 800X600
jpeg_quality: 15
# Resolution & quality (ESP32-S3 with Octal PSRAM handles XGA easily)
resolution: 1024X768
jpeg_quality: 10
max_framerate: 20 fps
idle_framerate: 0.2 fps
frame_buffer_count: 1
frame_buffer_count: 2
# Common orientation defaults for this module.
# Orientation
vertical_flip: true
horizontal_mirror: false
# Image tuning for chamber monitoring through tinted door
brightness: 1
contrast: -1
saturation: 0
# Auto-Exposure & Gain tuning (AEC2 + AE Level lift shadows away from bright LEDs)
aec_mode: auto
aec2: true
ae_level: 1
agc_mode: auto
agc_gain_ceiling: 8X
wb_mode: auto
# Camera endpoints:
# Stream: http://<ip>:8080
@@ -144,3 +152,42 @@ interval:
- logger.log: "Wi-Fi not connected for 5 min, rebooting..."
- delay: 10s
- lambda: 'App.safe_reboot();'
# Dynamic controls exposed to Home Assistant for real-time camera tuning
number:
- platform: template
name: "${friendly_name} Brightness"
min_value: -2
max_value: 2
step: 1
initial_value: 1
optimistic: true
set_action:
- lambda: |-
sensor_t *s = esp_camera_sensor_get();
if (s) s->set_brightness(s, (int)x);
- platform: template
name: "${friendly_name} Contrast"
min_value: -2
max_value: 2
step: 1
initial_value: -1
optimistic: true
set_action:
- lambda: |-
sensor_t *s = esp_camera_sensor_get();
if (s) s->set_contrast(s, (int)x);
- platform: template
name: "${friendly_name} AE Level"
min_value: -2
max_value: 2
step: 1
initial_value: 1
optimistic: true
set_action:
- lambda: |-
sensor_t *s = esp_camera_sensor_get();
if (s) s->set_ae_level(s, (int)x);