1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-05 03:13:49 +01:00
Files
esphome/esphome/components/copy/select/__init__.py
2025-03-20 09:51:23 -10:00

35 lines
970 B
Python

import esphome.codegen as cg
from esphome.components import select
import esphome.config_validation as cv
from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_ID, CONF_SOURCE_ID
from esphome.core.entity_helpers import inherit_property_from
from .. import copy_ns
CopySelect = copy_ns.class_("CopySelect", select.Select, cg.Component)
CONFIG_SCHEMA = (
select.select_schema(CopySelect)
.extend(
{
cv.Required(CONF_SOURCE_ID): cv.use_id(select.Select),
}
)
.extend(cv.COMPONENT_SCHEMA)
)
FINAL_VALIDATE_SCHEMA = cv.All(
inherit_property_from(CONF_ICON, CONF_SOURCE_ID),
inherit_property_from(CONF_ENTITY_CATEGORY, CONF_SOURCE_ID),
)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await select.register_select(var, config, options=[])
await cg.register_component(var, config)
source = await cg.get_variable(config[CONF_SOURCE_ID])
cg.add(var.set_source(source))