mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
import esphome.codegen as cg
|
|
import esphome.config_validation as cv
|
|
from esphome.components import climate, remote_transmitter, sensor
|
|
from esphome.components.remote_base import CONF_TRANSMITTER_ID
|
|
from esphome.const import CONF_ID, CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT
|
|
|
|
AUTO_LOAD = ["sensor"]
|
|
|
|
yashima_ns = cg.esphome_ns.namespace("yashima")
|
|
YashimaClimate = yashima_ns.class_("YashimaClimate", climate.Climate, cg.Component)
|
|
|
|
CONFIG_SCHEMA = cv.All(
|
|
climate.CLIMATE_SCHEMA.extend(
|
|
{
|
|
cv.GenerateID(): cv.declare_id(YashimaClimate),
|
|
cv.GenerateID(CONF_TRANSMITTER_ID): cv.use_id(
|
|
remote_transmitter.RemoteTransmitterComponent
|
|
),
|
|
cv.Optional(CONF_SUPPORTS_COOL, default=True): cv.boolean,
|
|
cv.Optional(CONF_SUPPORTS_HEAT, default=True): cv.boolean,
|
|
cv.Optional(CONF_SENSOR): cv.use_id(sensor.Sensor),
|
|
}
|
|
).extend(cv.COMPONENT_SCHEMA)
|
|
)
|
|
|
|
|
|
async def to_code(config):
|
|
var = cg.new_Pvariable(config[CONF_ID])
|
|
await cg.register_component(var, config)
|
|
await climate.register_climate(var, config)
|
|
|
|
cg.add(var.set_supports_cool(config[CONF_SUPPORTS_COOL]))
|
|
cg.add(var.set_supports_heat(config[CONF_SUPPORTS_HEAT]))
|
|
if CONF_SENSOR in config:
|
|
sens = await cg.get_variable(config[CONF_SENSOR])
|
|
cg.add(var.set_sensor(sens))
|
|
|
|
transmitter = await cg.get_variable(config[CONF_TRANSMITTER_ID])
|
|
cg.add(var.set_transmitter(transmitter))
|