2024-09-16 22:38:48 +02:00
|
|
|
import esphome.codegen as cg
|
|
|
|
import esphome.config_validation as cv
|
|
|
|
from esphome.components import select
|
|
|
|
from esphome.const import CONF_POWER, ENTITY_CATEGORY_CONFIG, CONF_ID
|
|
|
|
|
|
|
|
from .. import tw7100, tw7100_ns, CONF_TW7100_ID
|
|
|
|
|
|
|
|
DEPENDENCIES = ["tw7100"]
|
|
|
|
CODEOWNERS = ["@sqozz"]
|
|
|
|
|
|
|
|
tw7100Select = tw7100_ns.class_("tw7100Select", select.Select, cg.Component)
|
|
|
|
|
2024-09-19 22:44:44 +02:00
|
|
|
selects = [
|
|
|
|
("SOURCE", "mdi:video-input-hdmi"),
|
|
|
|
("LUMINANCE", "mdi:brightness-6"),
|
|
|
|
("CMODE", ""),
|
|
|
|
("GAMMA", "mdi:gamma"),
|
|
|
|
("IMGPRESET", "mdi:palette"),
|
|
|
|
("MCFI", "mdi:image-multiple"),
|
|
|
|
("CLRSPACE", ""),
|
|
|
|
("DYNRANGE", "mdi:hdr"),
|
|
|
|
("IMGPROC", ""),
|
|
|
|
("MSEL", "mdi:image-off"),
|
|
|
|
("SPEED", "mdi:speedometer"),
|
|
|
|
("OVSCAN", "mdi:overscan"),
|
|
|
|
("ASPECT", "mdi:aspect-ratio")
|
|
|
|
]
|
|
|
|
|
|
|
|
schema={cv.GenerateID(): cv.use_id(tw7100)}
|
|
|
|
for name,icon in selects:
|
|
|
|
schema.update({cv.Optional(name): select.select_schema(tw7100Select, icon=icon)})
|
|
|
|
|
|
|
|
CONFIG_SCHEMA = cv.Schema(schema)
|
2024-09-16 22:38:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
async def to_code(config):
|
|
|
|
parent = await cg.get_variable(config[CONF_ID])
|
|
|
|
|
2024-09-19 22:44:44 +02:00
|
|
|
for name,icon in selects:
|
|
|
|
if name in config:
|
|
|
|
select_ = await select.new_select(config[name], options=[])
|
|
|
|
cg.add(select_.set_cmd(name))
|
|
|
|
cg.add(select_.set_tw7100_parent(parent))
|
|
|
|
cg.add(getattr(parent, "set_set_{}".format(name.lower()))(select_))
|