- Updated __init__.py to include max_sd_files configuration option. - Refactored Marlin2 class to use new namespaces and improved structure. - Added support for binary sensors and select components in binary_sensor.py and select.py. - Enhanced sensor.py and text_sensor.py to include new configuration options for SD card file count and selected file. - Improved code readability and organization across multiple files.
27 lines
806 B
Python
27 lines
806 B
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import select
|
|
from esphome.const import (
|
|
ENTITY_CATEGORY_NONE,
|
|
)
|
|
from . import Marlin2
|
|
|
|
CONF_MARLIN = "marlin2"
|
|
CONF_SD_CARD_FILE_SELECT = "sd_card_file_select"
|
|
|
|
CONFIG_SCHEMA = cv.Schema(
|
|
{
|
|
cv.GenerateID(CONF_MARLIN): cv.use_id(Marlin2),
|
|
cv.Optional(CONF_SD_CARD_FILE_SELECT): select.select_schema(
|
|
entity_category=ENTITY_CATEGORY_NONE,
|
|
),
|
|
}
|
|
).extend(cv.polling_component_schema("15s"))
|
|
|
|
async def to_code(config):
|
|
server = await cg.get_variable(config[CONF_MARLIN])
|
|
|
|
if CONF_SD_CARD_FILE_SELECT in config:
|
|
sel = await select.new_select(config[CONF_SD_CARD_FILE_SELECT], options=[])
|
|
cg.add(server.add_select(CONF_SD_CARD_FILE_SELECT, sel))
|