I have some esp32 cam modules and wanted to use them. got the stream working
I setup a lamda function to change parameters. i can through a script
the light and led and reset work.
i have a bunch of cameras so i wanted to make a template to change values on the dashboard. I’m hoping to have a sub menu or maybe a on-click popup.
any tips on making it work for all the cameras… i know i need to change some values.
wouldn’t mind adding resolution to the input_select.
been stuck for hours on this error
Failed to call service esphome/cam1_camera_set_param. required key not provided @ data[‘value’]
here are my config files
cam1.yaml
configuration.yaml
input_numbers.yaml
input_select.yaml
and the card config
esphome:
name: cam1
friendly_name: cam1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
level: VERBOSE
tx_buffer_size: 256
# Enable Home Assistant API
api:
encryption:
key: !secret cam1_api
services: # change camera parameters on-the-fly
- service: "camera_set_param"
variables:
name: string
value: int
then:
- lambda: |-
bool state_return = false;
if (("contrast" == name) && (value >= -2) && (value <= 2)) { id(cam1).set_contrast(value); state_return = true; }
if (("brightness" == name) && (value >= -2) && (value <= 2)) { id(cam1).set_brightness(value); state_return = true; }
if (("saturation" == name) && (value >= -2) && (value <= 2)) { id(cam1).set_saturation(value); state_return = true; }
if (("special_effect" == name) && (value >= 0U) && (value <= 6U)) { id(cam1).set_special_effect((esphome::esp32_camera::ESP32SpecialEffect)value); state_return = true; }
if (("aec_mode" == name) && (value >= 0U) && (value <= 1U)) { id(cam1).set_aec_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
if (("aec2" == name) && (value >= 0U) && (value <= 1U)) { id(cam1).set_aec2(value); state_return = true; }
if (("ae_level" == name) && (value >= -2) && (value <= 2)) { id(cam1).set_ae_level(value); state_return = true; }
if (("aec_value" == name) && (value >= 0U) && (value <= 1200U)) { id(cam1).set_aec_value(value); state_return = true; }
if (("agc_mode" == name) && (value >= 0U) && (value <= 1U)) { id(cam1).set_agc_mode((esphome::esp32_camera::ESP32GainControlMode)value); state_return = true; }
if (("agc_value" == name) && (value >= 0U) && (value <= 30U)) { id(cam1).set_agc_value(value); state_return = true; }
if (("agc_gain_ceiling" == name) && (value >= 0U) && (value <= 6U)) { id(cam1).set_agc_gain_ceiling((esphome::esp32_camera::ESP32AgcGainCeiling)value); state_return = true; }
if (("wb_mode" == name) && (value >= 0U) && (value <= 4U)) { id(cam1).set_wb_mode((esphome::esp32_camera::ESP32WhiteBalanceMode)value); state_return = true; }
if (("test_pattern" == name) && (value >= 0U) && (value <= 1U)) { id(cam1).set_test_pattern(value); state_return = true; }
if (true == state_return) {
id(cam1).update_camera_parameters();
}
else {
ESP_LOGW("cam1_camera_set_param", "Error in name or data range");
}
ota:
password: !secret cam1_api
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: .printer.local
power_save_mode: none
manual_ip:
static_ip: 192.168.1.120
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
dns2: 8.8.8.8
# Enable fallback hotspot (captive portal) in case wifi connection fails
# ap:
# ssid: "Cam1 Fallback Hotspot"
# password: !secret cam1_appw
#captive_portal:
esp32_camera:
id: cam1
name: cam1
external_clock:
pin: GPIO0
frequency: 10MHz
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: 800x600
jpeg_quality: 10 # max. 63
max_framerate: 1.0fps
idle_framerate: 0.2fps
vertical_flip: true
horizontal_mirror: false
brightness: 2 # -2 to 2
contrast: 1 # -2 to 2
special_effect: none
# exposure settings
aec_mode: auto
aec2: false
ae_level: 0
aec_value: 300
# gain settings
agc_mode: auto
agc_gain_ceiling: 2x
agc_value: 0
# white balance setting
wb_mode: auto
output:
# white LED
- platform: ledc
channel: 2
pin: GPIO4
id: espCamLED
# red status light
- platform: gpio
pin:
number: GPIO33
inverted: True
id: gpio_33
light:
- platform: monochromatic
output: espCamLED
name: esp-cam light
- platform: binary
output: gpio_33
name: esp-cam led
switch:
- platform: restart
name: esp-cam restart
binary_sensor:
- platform: status
name: esp-cam status
configuration.yaml
Loads default set of integrations. Do not remove.
default_config:
input_number: !include input_number.yaml
input_select: !include input_select.yaml
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
input_numbers.yaml
brightness:
name: Brightness
min: -2
max: 2
step: 1
initial: 2
contrast:
name: Contrast
min: -2
max: 2
step: 1
initial: 1
saturation:
name: Saturation
min: -2
max: 2
step: 1
initial: 0
ae_level:
name: AE Level
min: -2
max: 2
step: 1
initial: 0
aec_value:
name: AEC Value
min: 0
max: 1200
step: 100
initial: 300
agc_value:
name: AGC Value
min: 0
max: 30
step: 1
initial: 0
'''
input_select.yaml
'''
special_effect:
name: Special Effect
options:
- None
- Black and White
- Negative
- Grayscale
- Red Tint
- Green Tint
- Blue Tint
aec_mode:
name: AEC Mode
options:
- Auto
- Manual
agc_mode:
name: AGC Mode
options:
- Auto
- Manual
agc_gain_ceiling:
name: AGC Gain Ceiling
options:
- 2x
- 4x
- 8x
- 16x
- 32x
wb_mode:
name: White Balance Mode
options:
- Auto
- Sunny
- Cloudy
- Office
- Home
test_pattern:
name: Test Pattern
options:
- Off
- Color Bars
and the card config
type: vertical-stack
cards:
- type: entities
entities:
- entity: input_number.contrast
- entity: input_number.brightness
- entity: input_number.saturation
- entity: input_select.special_effect
- entity: input_select.aec_mode
- entity: input_number.ae_level
- entity: input_number.aec_value
- entity: input_select.agc_mode
- entity: input_number.agc_value
- entity: input_select.agc_gain_ceiling
- entity: input_select.wb_mode
- entity: input_select.test_pattern
- show_name: true
show_icon: true
type: button
name: Update Parameters
tap_action:
action: call-service
service: esphome.cam1_camera_set_param
target: {}