From 50c88b7aa797fdc70131febcac5748e4028cac5a Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 13 May 2025 09:15:57 +1200 Subject: [PATCH] [ble_client] Use text_sensor_schema method (#8761) --- esphome/components/ble_client/text_sensor/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/esphome/components/ble_client/text_sensor/__init__.py b/esphome/components/ble_client/text_sensor/__init__.py index afa60f6c0c..a6b8956f93 100644 --- a/esphome/components/ble_client/text_sensor/__init__.py +++ b/esphome/components/ble_client/text_sensor/__init__.py @@ -4,7 +4,6 @@ from esphome.components import ble_client, esp32_ble_tracker, text_sensor import esphome.config_validation as cv from esphome.const import ( CONF_CHARACTERISTIC_UUID, - CONF_ID, CONF_NOTIFY, CONF_SERVICE_UUID, CONF_TRIGGER_ID, @@ -32,9 +31,9 @@ BLETextSensorNotifyTrigger = ble_client_ns.class_( ) CONFIG_SCHEMA = cv.All( - text_sensor.TEXT_SENSOR_SCHEMA.extend( + text_sensor.text_sensor_schema(BLETextSensor) + .extend( { - cv.GenerateID(): cv.declare_id(BLETextSensor), cv.Required(CONF_SERVICE_UUID): esp32_ble_tracker.bt_uuid, cv.Required(CONF_CHARACTERISTIC_UUID): esp32_ble_tracker.bt_uuid, cv.Optional(CONF_DESCRIPTOR_UUID): esp32_ble_tracker.bt_uuid, @@ -54,7 +53,7 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await text_sensor.new_text_sensor(config) if len(config[CONF_SERVICE_UUID]) == len(esp32_ble_tracker.bt_uuid16_format): cg.add( var.set_service_uuid16(esp32_ble_tracker.as_hex(config[CONF_SERVICE_UUID])) @@ -101,7 +100,6 @@ async def to_code(config): await cg.register_component(var, config) await ble_client.register_ble_node(var, config) cg.add(var.set_enable_notify(config[CONF_NOTIFY])) - await text_sensor.register_text_sensor(var, config) for conf in config.get(CONF_ON_NOTIFY, []): trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) await ble_client.register_ble_node(trigger, config)