esphome_optoma_rs232/binary_sensor.py
2025-03-14 15:23:22 +01:00

22 lines
661 B
Python

import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import binary_sensor
from esphome.const import DEVICE_CLASS_POWER, ICON_POWER
from . import CONF_OPTOMA_RS232_ID, OptomaRS232Component
DEPENDENCIES = ["optoma_rs232"]
CONFIG_SCHEMA = binary_sensor.binary_sensor_schema(
icon=ICON_POWER,
device_class=DEVICE_CLASS_POWER,
).extend({
cv.GenerateID(CONF_OPTOMA_RS232_ID): cv.use_id(OptomaRS232Component),
})
async def to_code(config):
hub = await cg.get_variable(config[CONF_OPTOMA_RS232_ID])
sens = await binary_sensor.new_binary_sensor(config)
cg.add(hub.set_beamer_power_binary_sensor(sens))