mirror of
https://github.com/esphome/esphome.git
synced 2026-09-16 01:28:39 +00:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import esphome.codegen as cg
|
|
from esphome.components import text_sensor
|
|
import esphome.config_validation as cv
|
|
from esphome.const import CONF_IAQ_ACCURACY
|
|
from esphome.cpp_generator import MockObj
|
|
from esphome.types import ConfigType
|
|
|
|
from . import CONF_BME68X_BSEC2_ID, BME68xBSEC2Component
|
|
|
|
DEPENDENCIES = ["bme68x_bsec2"]
|
|
|
|
ICON_ACCURACY = "mdi:checkbox-marked-circle-outline"
|
|
|
|
TYPES = [CONF_IAQ_ACCURACY]
|
|
|
|
CONFIG_SCHEMA = cv.Schema(
|
|
{
|
|
cv.GenerateID(CONF_BME68X_BSEC2_ID): cv.use_id(BME68xBSEC2Component),
|
|
cv.Optional(CONF_IAQ_ACCURACY): text_sensor.text_sensor_schema(
|
|
icon=ICON_ACCURACY
|
|
),
|
|
}
|
|
)
|
|
|
|
|
|
async def setup_conf(config: ConfigType, key: str, hub: MockObj) -> None:
|
|
if conf := config.get(key):
|
|
sens = await text_sensor.new_text_sensor(conf)
|
|
cg.add(getattr(hub, f"set_{key}_text_sensor")(sens))
|
|
|
|
|
|
async def to_code(config: ConfigType) -> None:
|
|
hub = await cg.get_variable(config[CONF_BME68X_BSEC2_ID])
|
|
for key in TYPES:
|
|
await setup_conf(config, key, hub)
|