Files
esphome/esphome/components/ecocomfort2/binary_sensor.py
T
4cae63bbaa [ecocomfort2] Add the read-only sensors and clock sync (Part 2) (#15447)
Co-authored-by: gledian <gledina.kruja@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-10-12 14:27:16 -10:00

34 lines
1.1 KiB
Python

import esphome.codegen as cg
from esphome.components import binary_sensor
from esphome.components.const import CONF_CONNECTED
import esphome.config_validation as cv
from esphome.const import DEVICE_CLASS_CONNECTIVITY, ENTITY_CATEGORY_DIAGNOSTIC
from esphome.types import ConfigType
from . import CONF_ECOCOMFORT2_ID, ECOCOMFORT2_CLIENT_SCHEMA
CODEOWNERS = ["@gledian"]
DEPENDENCIES = ["ecocomfort2"]
CONF_BOOST = "boost"
CONFIG_SCHEMA = cv.All(
ECOCOMFORT2_CLIENT_SCHEMA.extend(
{
cv.Optional(CONF_CONNECTED): binary_sensor.binary_sensor_schema(
device_class=DEVICE_CLASS_CONNECTIVITY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
cv.Optional(CONF_BOOST): binary_sensor.binary_sensor_schema(),
}
),
cv.has_at_least_one_key(CONF_CONNECTED, CONF_BOOST),
)
async def to_code(config: ConfigType) -> None:
hub = await cg.get_variable(config[CONF_ECOCOMFORT2_ID])
sensors = binary_sensor.sub_binary_sensors(config)
await sensors(CONF_CONNECTED, hub.set_connected_binary_sensor)
await sensors(CONF_BOOST, hub.set_boost_binary_sensor)