Files
esphome-votronic/components/votronic_ble/__init__.py
Sebastian Muszynski a6d882de4a
Some checks failed
CI / yamllint (push) Has been cancelled
CI / Bundle external component and ESPHome (push) Has been cancelled
CI / Create common environment (push) Has been cancelled
CI / Check ruff (push) Has been cancelled
CI / Check flake8 (push) Has been cancelled
CI / Check pylint (push) Has been cancelled
CI / Check pyupgrade (push) Has been cancelled
CI / Run script/ci-custom (push) Has been cancelled
CI / Check clang-format (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 1/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 2/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 3/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 Arduino 4/4 (push) Has been cancelled
CI / Run script/clang-tidy for ESP32 IDF (push) Has been cancelled
CI / Run script/clang-tidy for ESP8266 (push) Has been cancelled
CI / Validate example configurations (push) Has been cancelled
CI / Build example configurations (push) Has been cancelled
Fix ble_client build issue (#70)
2025-07-21 18:33:07 +02:00

45 lines
1.2 KiB
Python

import esphome.codegen as cg
from esphome.components import ble_client
import esphome.config_validation as cv
from esphome.const import CONF_ID, CONF_THROTTLE
AUTO_LOAD = ["binary_sensor", "sensor", "text_sensor"]
CODEOWNERS = ["@syssi"]
MULTI_CONF = True
CONF_VOTRONIC_BLE_ID = "votronic_ble_id"
votronic_ble_ns = cg.esphome_ns.namespace("votronic_ble")
VotronicBle = votronic_ble_ns.class_(
"VotronicBle", ble_client.BLEClientNode, cg.PollingComponent
)
CONFIG_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(VotronicBle),
cv.Optional(
CONF_THROTTLE, default="2s"
): cv.positive_time_period_milliseconds,
}
)
.extend(ble_client.BLE_CLIENT_SCHEMA)
.extend(cv.polling_component_schema("2s"))
)
# Centralized schema for subcomponents
VOTRONIC_BLE_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_VOTRONIC_BLE_ID): cv.use_id(VotronicBle),
}
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await ble_client.register_ble_node(var, config)
cg.add_define("USE_ESP32_BLE_DEVICE")
cg.add(var.set_throttle(config[CONF_THROTTLE]))