esphome/components/esp32_nimble_tracker/__init__.py
2023-12-03 22:19:57 +03:00

30 lines
873 B
Python

import esphome.config_validation as cv
import esphome.codegen as cg
from esphome.const import (
CONF_ID,
)
DEPENDENCIES = ["esp32"]
# CONF_NIMBLE_ID = "esp32_nimble_tracker"
CONF_MY_REQUIRED_KEY = 'my_required_key'
CONF_MY_OPTIONAL_KEY = 'my_optional_key'
esp32_nimble_tracker_ns = cg.esphome_ns.namespace("esp32_nimble_tracker")
ESP32NimbleTracker = esp32_nimble_tracker_ns.class_(
"ESP32NimbleTracker", cg.Component
)
CONFIG_SCHEMA = cv.Schema({
cv.GenerateID(): cv.declare_id(ESP32NimbleTracker),
cv.Required(CONF_MY_REQUIRED_KEY): cv.string,
cv.Optional(CONF_MY_OPTIONAL_KEY, default=10): cv.int_,
}).extend(cv.COMPONENT_SCHEMA)
def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
yield cg.register_component(var, config)
await nimble_tracker.device_listener_to_code(var, config)
await nimble_tracker.register_ble_device(var, config)