mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
33 lines
908 B
Python
33 lines
908 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import text_sensor
|
|
from esphome.const import (
|
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
|
ICON_NEW_BOX,
|
|
CONF_HIDE_TIMESTAMP,
|
|
)
|
|
|
|
version_ns = cg.esphome_ns.namespace("version")
|
|
VersionTextSensor = version_ns.class_(
|
|
"VersionTextSensor", text_sensor.TextSensor, cg.Component
|
|
)
|
|
|
|
CONFIG_SCHEMA = (
|
|
text_sensor.text_sensor_schema(
|
|
icon=ICON_NEW_BOX,
|
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
|
)
|
|
.extend(
|
|
{
|
|
cv.GenerateID(): cv.declare_id(VersionTextSensor),
|
|
cv.Optional(CONF_HIDE_TIMESTAMP, default=False): cv.boolean,
|
|
}
|
|
)
|
|
.extend(cv.COMPONENT_SCHEMA)
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = await text_sensor.new_text_sensor(config)
|
|
await cg.register_component(var, config)
|
|
cg.add(var.set_hide_timestamp(config[CONF_HIDE_TIMESTAMP]))
|