Files
esphome-lsm6ds/esphome/components/libretiny/text_sensor.py
T
f5bbff0b05 [core] Add CONF_LIBRETINY constant to const.py (#15141)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-03-25 07:40:39 -04:00

33 lines
871 B
Python

import esphome.codegen as cg
from esphome.components import text_sensor
from esphome.components.const import CONF_LIBRETINY
import esphome.config_validation as cv
from esphome.const import (
CONF_VERSION,
ENTITY_CATEGORY_DIAGNOSTIC,
ICON_CELLPHONE_ARROW_DOWN,
)
from .const import LTComponent
DEPENDENCIES = ["libretiny"]
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_LIBRETINY): cv.use_id(LTComponent),
cv.Optional(CONF_VERSION): text_sensor.text_sensor_schema(
icon=ICON_CELLPHONE_ARROW_DOWN,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
}
)
async def to_code(config):
lt_component = await cg.get_variable(config[CONF_LIBRETINY])
if CONF_VERSION in config:
sens = await text_sensor.new_text_sensor(config[CONF_VERSION])
cg.add(lt_component.set_version_sensor(sens))