Add EntityBase properties to ESP32 Camera (#2600)

This commit is contained in:
Paul Monigatti
2021-10-22 23:10:29 +13:00
committed by GitHub
parent f7b3f52731
commit be3cb9ef00
7 changed files with 18 additions and 7 deletions
+4 -7
View File
@@ -2,10 +2,8 @@ import esphome.codegen as cg
import esphome.config_validation as cv
from esphome import pins
from esphome.const import (
CONF_DISABLED_BY_DEFAULT,
CONF_FREQUENCY,
CONF_ID,
CONF_NAME,
CONF_PIN,
CONF_SCL,
CONF_SDA,
@@ -17,6 +15,7 @@ from esphome.const import (
)
from esphome.core import CORE
from esphome.components.esp32 import add_idf_sdkconfig_option
from esphome.cpp_helpers import setup_entity
DEPENDENCIES = ["esp32", "api"]
@@ -63,11 +62,9 @@ CONF_TEST_PATTERN = "test_pattern"
camera_range_param = cv.int_range(min=-2, max=2)
CONFIG_SCHEMA = cv.Schema(
CONFIG_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(ESP32Camera),
cv.Required(CONF_NAME): cv.string,
cv.Optional(CONF_DISABLED_BY_DEFAULT, default=False): cv.boolean,
cv.Required(CONF_DATA_PINS): cv.All(
[pins.internal_gpio_input_pin_number], cv.Length(min=8, max=8)
),
@@ -127,8 +124,8 @@ SETTERS = {
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID], config[CONF_NAME])
cg.add(var.set_disabled_by_default(config[CONF_DISABLED_BY_DEFAULT]))
var = cg.new_Pvariable(config[CONF_ID])
await setup_entity(var, config)
await cg.register_component(var, config)
for key, setter in SETTERS.items():