mirror of
https://git.steelants.cz/JonatanRek/ESPHomeMarlin2.git
synced 2026-10-11 17:44:36 +00:00
Refactor Marlin2 component and add new features
- 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.
This commit is contained in:
1 parent
cf3039439f
commit
270a92ba06
8 files changed
+492
-410
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.components import binary_sensor
|
||||
from esphome.const import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
)
|
||||
from . import Marlin2
|
||||
|
||||
CONF_MARLIN = "marlin2"
|
||||
CONF_SD_CARD_PRESENT = "sd_card_present"
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(CONF_MARLIN): cv.use_id(Marlin2),
|
||||
cv.Optional(CONF_SD_CARD_PRESENT): binary_sensor.binary_sensor_schema(
|
||||
device_class=DEVICE_CLASS_CONNECTIVITY,
|
||||
),
|
||||
}
|
||||
).extend(cv.polling_component_schema("15s"))
|
||||
|
||||
async def to_code(config):
|
||||
server = await cg.get_variable(config[CONF_MARLIN])
|
||||
|
||||
if CONF_SD_CARD_PRESENT in config:
|
||||
bs = await binary_sensor.new_binary_sensor(config[CONF_SD_CARD_PRESENT])
|
||||
cg.add(server.add_binary_sensor(CONF_SD_CARD_PRESENT, bs))
|
||||
Reference in new issue
Block a user