1
0
mirror of https://github.com/esphome/esphome.git synced 2025-04-03 09:20:29 +01:00
Oleg Tarasov 58d028ac13
Add OpenTherm component (part 3: rest of the sensors) (#7676)
Co-authored-by: FreeBear <freebear@tuxcnc.org>
Co-authored-by: FreeBear-nc <67865163+FreeBear-nc@users.noreply.github.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-11-12 16:19:42 +13:00

34 lines
973 B
Python

from typing import Any
import esphome.config_validation as cv
from esphome.components import binary_sensor
from .. import const, schema, validate, generate
DEPENDENCIES = [const.OPENTHERM]
COMPONENT_TYPE = const.BINARY_SENSOR
def get_entity_validation_schema(entity: schema.BinarySensorSchema) -> cv.Schema:
return binary_sensor.binary_sensor_schema(
device_class=(
entity.device_class
or binary_sensor._UNDEF # pylint: disable=protected-access
),
icon=(entity.icon or binary_sensor._UNDEF), # pylint: disable=protected-access
)
CONFIG_SCHEMA = validate.create_component_schema(
schema.BINARY_SENSORS, get_entity_validation_schema
)
async def to_code(config: dict[str, Any]) -> None:
await generate.component_to_code(
COMPONENT_TYPE,
schema.BINARY_SENSORS,
binary_sensor.BinarySensor,
generate.create_only_conf(binary_sensor.new_binary_sensor),
config,
)