diff --git a/esphome/components/anova/climate.py b/esphome/components/anova/climate.py index 052296294b..e1fd38fddc 100644 --- a/esphome/components/anova/climate.py +++ b/esphome/components/anova/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import ble_client, climate import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_UNIT_OF_MEASUREMENT +from esphome.const import CONF_UNIT_OF_MEASUREMENT UNITS = { "f": "f", @@ -17,9 +17,9 @@ Anova = anova_ns.class_( ) CONFIG_SCHEMA = ( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(Anova) + .extend( { - cv.GenerateID(): cv.declare_id(Anova), cv.Required(CONF_UNIT_OF_MEASUREMENT): cv.enum(UNITS), } ) @@ -29,8 +29,7 @@ CONFIG_SCHEMA = ( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) await ble_client.register_ble_node(var, config) cg.add(var.set_unit_of_measurement(config[CONF_UNIT_OF_MEASUREMENT])) diff --git a/esphome/components/ballu/climate.py b/esphome/components/ballu/climate.py index 416fa250cc..e35a1d244d 100644 --- a/esphome/components/ballu/climate.py +++ b/esphome/components/ballu/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@bazuchan"] @@ -9,13 +7,8 @@ CODEOWNERS = ["@bazuchan"] ballu_ns = cg.esphome_ns.namespace("ballu") BalluClimate = ballu_ns.class_("BalluClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(BalluClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(BalluClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/bang_bang/climate.py b/esphome/components/bang_bang/climate.py index 6511270f60..bfdb12278f 100644 --- a/esphome/components/bang_bang/climate.py +++ b/esphome/components/bang_bang/climate.py @@ -9,7 +9,6 @@ from esphome.const import ( CONF_DEFAULT_TARGET_TEMPERATURE_LOW, CONF_HEAT_ACTION, CONF_HUMIDITY_SENSOR, - CONF_ID, CONF_IDLE_ACTION, CONF_SENSOR, ) @@ -19,9 +18,9 @@ BangBangClimate = bang_bang_ns.class_("BangBangClimate", climate.Climate, cg.Com BangBangClimateTargetTempConfig = bang_bang_ns.struct("BangBangClimateTargetTempConfig") CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(BangBangClimate) + .extend( { - cv.GenerateID(): cv.declare_id(BangBangClimate), cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor), cv.Optional(CONF_HUMIDITY_SENSOR): cv.use_id(sensor.Sensor), cv.Required(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature, @@ -36,15 +35,15 @@ CONFIG_SCHEMA = cv.All( } ), } - ).extend(cv.COMPONENT_SCHEMA), + ) + .extend(cv.COMPONENT_SCHEMA), cv.has_at_least_one_key(CONF_COOL_ACTION, CONF_HEAT_ACTION), ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) diff --git a/esphome/components/bedjet/climate/__init__.py b/esphome/components/bedjet/climate/__init__.py index 7ba3e439b2..e9c5510256 100644 --- a/esphome/components/bedjet/climate/__init__.py +++ b/esphome/components/bedjet/climate/__init__.py @@ -1,11 +1,8 @@ -import logging - import esphome.codegen as cg from esphome.components import ble_client, climate import esphome.config_validation as cv from esphome.const import ( CONF_HEAT_MODE, - CONF_ID, CONF_RECEIVE_TIMEOUT, CONF_TEMPERATURE_SOURCE, CONF_TIME_ID, @@ -13,7 +10,6 @@ from esphome.const import ( from .. import BEDJET_CLIENT_SCHEMA, bedjet_ns, register_bedjet_child -_LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jhansche"] DEPENDENCIES = ["bedjet"] @@ -30,9 +26,9 @@ BEDJET_TEMPERATURE_SOURCES = { } CONFIG_SCHEMA = ( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(BedJetClimate) + .extend( { - cv.GenerateID(): cv.declare_id(BedJetClimate), cv.Optional(CONF_HEAT_MODE, default="heat"): cv.enum( BEDJET_HEAT_MODES, lower=True ), @@ -63,9 +59,8 @@ CONFIG_SCHEMA = ( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) await register_bedjet_child(var, config) cg.add(var.set_heating_mode(config[CONF_HEAT_MODE])) diff --git a/esphome/components/climate_ir/__init__.py b/esphome/components/climate_ir/__init__.py index d8be61397e..32b614e933 100644 --- a/esphome/components/climate_ir/__init__.py +++ b/esphome/components/climate_ir/__init__.py @@ -1,7 +1,13 @@ +import logging + +from esphome import core import esphome.codegen as cg from esphome.components import climate, remote_base, sensor import esphome.config_validation as cv -from esphome.const import CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT +from esphome.const import CONF_ID, CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT +from esphome.cpp_generator import MockObjClass + +_LOGGER = logging.getLogger(__name__) DEPENDENCIES = ["remote_transmitter"] AUTO_LOAD = ["sensor", "remote_base"] @@ -16,30 +22,58 @@ ClimateIR = climate_ir_ns.class_( remote_base.RemoteTransmittable, ) -CLIMATE_IR_SCHEMA = ( - climate.CLIMATE_SCHEMA.extend( + +def climate_ir_schema( + class_: MockObjClass, +) -> cv.Schema: + return ( + climate.climate_schema(class_) + .extend( + { + 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) + .extend(remote_base.REMOTE_TRANSMITTABLE_SCHEMA) + ) + + +def climare_ir_with_receiver_schema( + class_: MockObjClass, +) -> cv.Schema: + return climate_ir_schema(class_).extend( { - 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), + cv.Optional(remote_base.CONF_RECEIVER_ID): cv.use_id( + remote_base.RemoteReceiverBase + ), } ) - .extend(cv.COMPONENT_SCHEMA) - .extend(remote_base.REMOTE_TRANSMITTABLE_SCHEMA) -) -CLIMATE_IR_WITH_RECEIVER_SCHEMA = CLIMATE_IR_SCHEMA.extend( - { - cv.Optional(remote_base.CONF_RECEIVER_ID): cv.use_id( - remote_base.RemoteReceiverBase - ), - } -) + +# Remove before 2025.11.0 +def deprecated_schema_constant(config): + type: str = "unknown" + if (id := config.get(CONF_ID)) is not None and isinstance(id, core.ID): + type = str(id.type).split("::", maxsplit=1)[0] + _LOGGER.warning( + "Using `climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA` is deprecated and will be removed in ESPHome 2025.11.0. " + "Please use `climate_ir.climare_ir_with_receiver_schema(...)` instead. " + "If you are seeing this, report an issue to the external_component author and ask them to update it. " + "https://developers.esphome.io/blog/2025/05/14/_schema-deprecations/. " + "Component using this schema: %s", + type, + ) + return config + + +CLIMATE_IR_WITH_RECEIVER_SCHEMA = climare_ir_with_receiver_schema(ClimateIR) +CLIMATE_IR_WITH_RECEIVER_SCHEMA.add_extra(deprecated_schema_constant) async def register_climate_ir(var, config): await cg.register_component(var, config) - await climate.register_climate(var, config) await remote_base.register_transmittable(var, config) cg.add(var.set_supports_cool(config[CONF_SUPPORTS_COOL])) cg.add(var.set_supports_heat(config[CONF_SUPPORTS_HEAT])) @@ -48,3 +82,9 @@ async def register_climate_ir(var, config): if sensor_id := config.get(CONF_SENSOR): sens = await cg.get_variable(sensor_id) cg.add(var.set_sensor(sens)) + + +async def new_climate_ir(config, *args): + var = await climate.new_climate(config, *args) + await register_climate_ir(var, config) + return var diff --git a/esphome/components/climate_ir_lg/climate.py b/esphome/components/climate_ir_lg/climate.py index 76d4c00baf..de824bfe5c 100644 --- a/esphome/components/climate_ir_lg/climate.py +++ b/esphome/components/climate_ir_lg/climate.py @@ -1,7 +1,6 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] @@ -14,9 +13,8 @@ CONF_BIT_HIGH = "bit_high" CONF_BIT_ONE_LOW = "bit_one_low" CONF_BIT_ZERO_LOW = "bit_zero_low" -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(LgIrClimate).extend( { - cv.GenerateID(): cv.declare_id(LgIrClimate), cv.Optional( CONF_HEADER_HIGH, default="8000us" ): cv.positive_time_period_microseconds, @@ -37,8 +35,7 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_header_high(config[CONF_HEADER_HIGH])) cg.add(var.set_header_low(config[CONF_HEADER_LOW])) diff --git a/esphome/components/coolix/climate.py b/esphome/components/coolix/climate.py index 339e7de906..b280544a5c 100644 --- a/esphome/components/coolix/climate.py +++ b/esphome/components/coolix/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@glmnet"] @@ -9,13 +7,8 @@ CODEOWNERS = ["@glmnet"] coolix_ns = cg.esphome_ns.namespace("coolix") CoolixClimate = coolix_ns.class_("CoolixClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(CoolixClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(CoolixClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/daikin/climate.py b/esphome/components/daikin/climate.py index 3946513191..2cd44969c1 100644 --- a/esphome/components/daikin/climate.py +++ b/esphome/components/daikin/climate.py @@ -1,20 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] daikin_ns = cg.esphome_ns.namespace("daikin") DaikinClimate = daikin_ns.class_("DaikinClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(DaikinClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(DaikinClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/daikin_arc/climate.py b/esphome/components/daikin_arc/climate.py index 967d080c24..8f6b07315d 100644 --- a/esphome/components/daikin_arc/climate.py +++ b/esphome/components/daikin_arc/climate.py @@ -1,18 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] daikin_arc_ns = cg.esphome_ns.namespace("daikin_arc") DaikinArcClimate = daikin_arc_ns.class_("DaikinArcClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - {cv.GenerateID(): cv.declare_id(DaikinArcClimate)} -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(DaikinArcClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/daikin_brc/climate.py b/esphome/components/daikin_brc/climate.py index aacac408ca..1000784380 100644 --- a/esphome/components/daikin_brc/climate.py +++ b/esphome/components/daikin_brc/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT +from esphome.const import CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir"] @@ -9,15 +9,13 @@ daikin_brc_ns = cg.esphome_ns.namespace("daikin_brc") DaikinBrcClimate = daikin_brc_ns.class_("DaikinBrcClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(DaikinBrcClimate).extend( { - cv.GenerateID(): cv.declare_id(DaikinBrcClimate), cv.Optional(CONF_USE_FAHRENHEIT, default=False): cv.boolean, } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_fahrenheit(config[CONF_USE_FAHRENHEIT])) diff --git a/esphome/components/delonghi/climate.py b/esphome/components/delonghi/climate.py index 0d3bb76c98..ff878b4ff7 100644 --- a/esphome/components/delonghi/climate.py +++ b/esphome/components/delonghi/climate.py @@ -1,20 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] delonghi_ns = cg.esphome_ns.namespace("delonghi") DelonghiClimate = delonghi_ns.class_("DelonghiClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(DelonghiClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(DelonghiClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/emmeti/climate.py b/esphome/components/emmeti/climate.py index b925f4b61e..042f1af64b 100644 --- a/esphome/components/emmeti/climate.py +++ b/esphome/components/emmeti/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID CODEOWNERS = ["@E440QF"] AUTO_LOAD = ["climate_ir"] @@ -9,13 +7,8 @@ AUTO_LOAD = ["climate_ir"] emmeti_ns = cg.esphome_ns.namespace("emmeti") EmmetiClimate = emmeti_ns.class_("EmmetiClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(EmmetiClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(EmmetiClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/fujitsu_general/climate.py b/esphome/components/fujitsu_general/climate.py index 6d2e46512e..0f028d0af3 100644 --- a/esphome/components/fujitsu_general/climate.py +++ b/esphome/components/fujitsu_general/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] @@ -10,13 +8,8 @@ FujitsuGeneralClimate = fujitsu_general_ns.class_( "FujitsuGeneralClimate", climate_ir.ClimateIR ) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(FujitsuGeneralClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(FujitsuGeneralClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/gree/climate.py b/esphome/components/gree/climate.py index 389c9fb3c7..947ef9bb97 100644 --- a/esphome/components/gree/climate.py +++ b/esphome/components/gree/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_MODEL +from esphome.const import CONF_MODEL CODEOWNERS = ["@orestismers"] @@ -21,16 +21,13 @@ MODELS = { "yag": Model.GREE_YAG, } -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(GreeClimate).extend( { - cv.GenerateID(): cv.declare_id(GreeClimate), cv.Required(CONF_MODEL): cv.enum(MODELS), } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_model(config[CONF_MODEL])) - - await climate_ir.register_climate_ir(var, config) diff --git a/esphome/components/haier/climate.py b/esphome/components/haier/climate.py index f77d624649..0393c263d4 100644 --- a/esphome/components/haier/climate.py +++ b/esphome/components/haier/climate.py @@ -30,6 +30,7 @@ from esphome.const import ( CONF_VISUAL, CONF_WIFI, ) +from esphome.cpp_generator import MockObjClass import esphome.final_validate as fv _LOGGER = logging.getLogger(__name__) @@ -185,42 +186,46 @@ def validate_visual(config): return config -BASE_CONFIG_SCHEMA = ( - climate.CLIMATE_SCHEMA.extend( - { - cv.Optional(CONF_SUPPORTED_MODES): cv.ensure_list( - cv.enum(SUPPORTED_CLIMATE_MODES_OPTIONS, upper=True) - ), - cv.Optional( - CONF_SUPPORTED_SWING_MODES, - default=[ - "VERTICAL", - "HORIZONTAL", - "BOTH", - ], - ): cv.ensure_list(cv.enum(SUPPORTED_SWING_MODES_OPTIONS, upper=True)), - cv.Optional(CONF_WIFI_SIGNAL, default=False): cv.boolean, - cv.Optional(CONF_DISPLAY): cv.boolean, - cv.Optional( - CONF_ANSWER_TIMEOUT, - ): cv.positive_time_period_milliseconds, - cv.Optional(CONF_ON_STATUS_MESSAGE): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StatusMessageTrigger), - } - ), - } +def _base_config_schema(class_: MockObjClass) -> cv.Schema: + return ( + climate.climate_schema(class_) + .extend( + { + cv.Optional(CONF_SUPPORTED_MODES): cv.ensure_list( + cv.enum(SUPPORTED_CLIMATE_MODES_OPTIONS, upper=True) + ), + cv.Optional( + CONF_SUPPORTED_SWING_MODES, + default=[ + "VERTICAL", + "HORIZONTAL", + "BOTH", + ], + ): cv.ensure_list(cv.enum(SUPPORTED_SWING_MODES_OPTIONS, upper=True)), + cv.Optional(CONF_WIFI_SIGNAL, default=False): cv.boolean, + cv.Optional(CONF_DISPLAY): cv.boolean, + cv.Optional( + CONF_ANSWER_TIMEOUT, + ): cv.positive_time_period_milliseconds, + cv.Optional(CONF_ON_STATUS_MESSAGE): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + StatusMessageTrigger + ), + } + ), + } + ) + .extend(uart.UART_DEVICE_SCHEMA) + .extend(cv.COMPONENT_SCHEMA) ) - .extend(uart.UART_DEVICE_SCHEMA) - .extend(cv.COMPONENT_SCHEMA) -) + CONFIG_SCHEMA = cv.All( cv.typed_schema( { - PROTOCOL_SMARTAIR2: BASE_CONFIG_SCHEMA.extend( + PROTOCOL_SMARTAIR2: _base_config_schema(Smartair2Climate).extend( { - cv.GenerateID(): cv.declare_id(Smartair2Climate), cv.Optional( CONF_ALTERNATIVE_SWING_CONTROL, default=False ): cv.boolean, @@ -232,9 +237,8 @@ CONFIG_SCHEMA = cv.All( ), } ), - PROTOCOL_HON: BASE_CONFIG_SCHEMA.extend( + PROTOCOL_HON: _base_config_schema(HonClimate).extend( { - cv.GenerateID(): cv.declare_id(HonClimate), cv.Optional( CONF_CONTROL_METHOD, default="SET_GROUP_PARAMETERS" ): cv.ensure_list( @@ -464,10 +468,9 @@ FINAL_VALIDATE_SCHEMA = _final_validate async def to_code(config): cg.add(haier_ns.init_haier_protocol_logging()) - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) await uart.register_uart_device(var, config) - await climate.register_climate(var, config) cg.add(var.set_send_wifi(config[CONF_WIFI_SIGNAL])) if CONF_CONTROL_METHOD in config: diff --git a/esphome/components/heatpumpir/climate.py b/esphome/components/heatpumpir/climate.py index 612b0d6123..21b0168615 100644 --- a/esphome/components/heatpumpir/climate.py +++ b/esphome/components/heatpumpir/climate.py @@ -2,7 +2,6 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_MAX_TEMPERATURE, CONF_MIN_TEMPERATURE, CONF_PROTOCOL, @@ -98,9 +97,8 @@ VERTICAL_DIRECTIONS = { } CONFIG_SCHEMA = cv.All( - climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( + climate_ir.climare_ir_with_receiver_schema(HeatpumpIRClimate).extend( { - cv.GenerateID(): cv.declare_id(HeatpumpIRClimate), cv.Required(CONF_PROTOCOL): cv.enum(PROTOCOLS), cv.Required(CONF_HORIZONTAL_DEFAULT): cv.enum(HORIZONTAL_DIRECTIONS), cv.Required(CONF_VERTICAL_DEFAULT): cv.enum(VERTICAL_DIRECTIONS), @@ -112,8 +110,8 @@ CONFIG_SCHEMA = cv.All( ) -def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) +async def to_code(config): + var = await climate_ir.new_climate_ir(config) if CONF_VISUAL not in config: config[CONF_VISUAL] = {} visual = config[CONF_VISUAL] @@ -121,7 +119,6 @@ def to_code(config): visual[CONF_MAX_TEMPERATURE] = config[CONF_MAX_TEMPERATURE] if CONF_MIN_TEMPERATURE not in visual: visual[CONF_MIN_TEMPERATURE] = config[CONF_MIN_TEMPERATURE] - yield climate_ir.register_climate_ir(var, config) cg.add(var.set_protocol(config[CONF_PROTOCOL])) cg.add(var.set_horizontal_default(config[CONF_HORIZONTAL_DEFAULT])) cg.add(var.set_vertical_default(config[CONF_VERTICAL_DEFAULT])) diff --git a/esphome/components/hitachi_ac344/climate.py b/esphome/components/hitachi_ac344/climate.py index 0988d63995..4fa2d54fbb 100644 --- a/esphome/components/hitachi_ac344/climate.py +++ b/esphome/components/hitachi_ac344/climate.py @@ -1,20 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] hitachi_ac344_ns = cg.esphome_ns.namespace("hitachi_ac344") HitachiClimate = hitachi_ac344_ns.class_("HitachiClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(HitachiClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(HitachiClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/hitachi_ac424/climate.py b/esphome/components/hitachi_ac424/climate.py index 74f3c2fa14..4b20147922 100644 --- a/esphome/components/hitachi_ac424/climate.py +++ b/esphome/components/hitachi_ac424/climate.py @@ -1,20 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] hitachi_ac424_ns = cg.esphome_ns.namespace("hitachi_ac424") HitachiClimate = hitachi_ac424_ns.class_("HitachiClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(HitachiClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(HitachiClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/midea/climate.py b/esphome/components/midea/climate.py index 1d3cac66ba..b08a47afa9 100644 --- a/esphome/components/midea/climate.py +++ b/esphome/components/midea/climate.py @@ -104,9 +104,9 @@ validate_custom_fan_modes = cv.enum(CUSTOM_FAN_MODES, upper=True) validate_custom_presets = cv.enum(CUSTOM_PRESETS, upper=True) CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(AirConditioner) + .extend( { - cv.GenerateID(): cv.declare_id(AirConditioner), cv.Optional(CONF_PERIOD, default="1s"): cv.time_period, cv.Optional(CONF_TIMEOUT, default="2s"): cv.time_period, cv.Optional(CONF_NUM_ATTEMPTS, default=3): cv.int_range(min=1, max=5), @@ -259,10 +259,9 @@ async def power_inv_to_code(var, config, args): async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) await uart.register_uart_device(var, config) - await climate.register_climate(var, config) cg.add(var.set_period(config[CONF_PERIOD].total_milliseconds)) cg.add(var.set_response_timeout(config[CONF_TIMEOUT].total_milliseconds)) cg.add(var.set_request_attempts(config[CONF_NUM_ATTEMPTS])) diff --git a/esphome/components/midea_ir/climate.py b/esphome/components/midea_ir/climate.py index 21fa5f4f56..5c9256b5e4 100644 --- a/esphome/components/midea_ir/climate.py +++ b/esphome/components/midea_ir/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT +from esphome.const import CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir", "coolix"] CODEOWNERS = ["@dudanov"] @@ -10,15 +10,13 @@ midea_ir_ns = cg.esphome_ns.namespace("midea_ir") MideaIR = midea_ir_ns.class_("MideaIR", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(MideaIR).extend( { - cv.GenerateID(): cv.declare_id(MideaIR), cv.Optional(CONF_USE_FAHRENHEIT, default=False): cv.boolean, } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_fahrenheit(config[CONF_USE_FAHRENHEIT])) diff --git a/esphome/components/mitsubishi/climate.py b/esphome/components/mitsubishi/climate.py index 23f8ed21fa..5784d3ee8a 100644 --- a/esphome/components/mitsubishi/climate.py +++ b/esphome/components/mitsubishi/climate.py @@ -1,7 +1,6 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID CODEOWNERS = ["@RubyBailey"] AUTO_LOAD = ["climate_ir"] @@ -44,9 +43,8 @@ VERTICAL_DIRECTIONS = { } -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(MitsubishiClimate).extend( { - cv.GenerateID(): cv.declare_id(MitsubishiClimate), cv.Optional(CONF_SET_FAN_MODE, default="3levels"): cv.enum(SETFANMODE), cv.Optional(CONF_SUPPORTS_DRY, default=False): cv.boolean, cv.Optional(CONF_SUPPORTS_FAN_ONLY, default=False): cv.boolean, @@ -61,8 +59,7 @@ CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_fan_mode(config[CONF_SET_FAN_MODE])) cg.add(var.set_supports_dry(config[CONF_SUPPORTS_DRY])) diff --git a/esphome/components/noblex/climate.py b/esphome/components/noblex/climate.py index 7f4e8e6488..d619265d01 100644 --- a/esphome/components/noblex/climate.py +++ b/esphome/components/noblex/climate.py @@ -1,20 +1,13 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] noblex_ns = cg.esphome_ns.namespace("noblex") NoblexClimate = noblex_ns.class_("NoblexClimate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(NoblexClimate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(NoblexClimate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/pid/climate.py b/esphome/components/pid/climate.py index aab7ee5c00..5919d2cac8 100644 --- a/esphome/components/pid/climate.py +++ b/esphome/components/pid/climate.py @@ -41,9 +41,8 @@ CONF_KI_MULTIPLIER = "ki_multiplier" CONF_KD_MULTIPLIER = "kd_multiplier" CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(PIDClimate).extend( { - cv.GenerateID(): cv.declare_id(PIDClimate), cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor), cv.Optional(CONF_HUMIDITY_SENSOR): cv.use_id(sensor.Sensor), cv.Required(CONF_DEFAULT_TARGET_TEMPERATURE): cv.temperature, @@ -80,9 +79,8 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) sens = await cg.get_variable(config[CONF_SENSOR]) cg.add(var.set_sensor(sens)) diff --git a/esphome/components/tcl112/climate.py b/esphome/components/tcl112/climate.py index 9cd193f5c7..9864113a52 100644 --- a/esphome/components/tcl112/climate.py +++ b/esphome/components/tcl112/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@glmnet"] @@ -9,13 +7,8 @@ CODEOWNERS = ["@glmnet"] tcl112_ns = cg.esphome_ns.namespace("tcl112") Tcl112Climate = tcl112_ns.class_("Tcl112Climate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(Tcl112Climate), - } -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(Tcl112Climate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config) diff --git a/esphome/components/thermostat/climate.py b/esphome/components/thermostat/climate.py index 638aad7c06..0314d877a3 100644 --- a/esphome/components/thermostat/climate.py +++ b/esphome/components/thermostat/climate.py @@ -516,9 +516,9 @@ def validate_thermostat(config): CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(ThermostatClimate) + .extend( { - cv.GenerateID(): cv.declare_id(ThermostatClimate), cv.Required(CONF_SENSOR): cv.use_id(sensor.Sensor), cv.Optional(CONF_HUMIDITY_SENSOR): cv.use_id(sensor.Sensor), cv.Required(CONF_IDLE_ACTION): automation.validate_automation(single=True), @@ -631,7 +631,8 @@ CONFIG_SCHEMA = cv.All( single=True ), } - ).extend(cv.COMPONENT_SCHEMA), + ) + .extend(cv.COMPONENT_SCHEMA), cv.has_at_least_one_key( CONF_COOL_ACTION, CONF_DRY_ACTION, CONF_FAN_ONLY_ACTION, CONF_HEAT_ACTION ), @@ -640,9 +641,8 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) heat_cool_mode_available = CONF_HEAT_ACTION in config and CONF_COOL_ACTION in config two_points_available = CONF_HEAT_ACTION in config and ( diff --git a/esphome/components/toshiba/climate.py b/esphome/components/toshiba/climate.py index 54582b78a9..40112fc460 100644 --- a/esphome/components/toshiba/climate.py +++ b/esphome/components/toshiba/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_MODEL +from esphome.const import CONF_MODEL AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@kbx81"] @@ -16,15 +16,13 @@ MODELS = { "RAC-PT1411HWRU-F": Model.MODEL_RAC_PT1411HWRU_F, } -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(ToshibaClimate).extend( { - cv.GenerateID(): cv.declare_id(ToshibaClimate), cv.Optional(CONF_MODEL, default="generic"): cv.enum(MODELS, upper=True), } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_model(config[CONF_MODEL])) diff --git a/esphome/components/tuya/climate/__init__.py b/esphome/components/tuya/climate/__init__.py index 371c599ef7..4dbdf07651 100644 --- a/esphome/components/tuya/climate/__init__.py +++ b/esphome/components/tuya/climate/__init__.py @@ -4,7 +4,6 @@ from esphome.components import climate import esphome.config_validation as cv from esphome.const import ( CONF_FAN_MODE, - CONF_ID, CONF_PRESET, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT, @@ -151,9 +150,9 @@ SWING_MODES = cv.Schema( ) CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(TuyaClimate) + .extend( { - cv.GenerateID(): cv.declare_id(TuyaClimate), cv.GenerateID(CONF_TUYA_ID): cv.use_id(Tuya), cv.Optional(CONF_SUPPORTS_HEAT, default=True): cv.boolean, cv.Optional(CONF_SUPPORTS_COOL, default=False): cv.boolean, @@ -186,7 +185,8 @@ CONFIG_SCHEMA = cv.All( "'eco_temperature' has been moved inside of the 'eco' config block under 'preset' as 'temperature'" ), } - ).extend(cv.COMPONENT_SCHEMA), + ) + .extend(cv.COMPONENT_SCHEMA), cv.has_at_least_one_key(CONF_TARGET_TEMPERATURE_DATAPOINT, CONF_SWITCH_DATAPOINT), validate_temperature_multipliers, validate_cooling_values, @@ -194,9 +194,8 @@ CONFIG_SCHEMA = cv.All( async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_TUYA_ID]) cg.add(var.set_tuya_parent(paren)) diff --git a/esphome/components/uponor_smatrix/climate/__init__.py b/esphome/components/uponor_smatrix/climate/__init__.py index 5aeb521fb1..47495fde9a 100644 --- a/esphome/components/uponor_smatrix/climate/__init__.py +++ b/esphome/components/uponor_smatrix/climate/__init__.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate -import esphome.config_validation as cv -from esphome.const import CONF_ID from .. import ( UPONOR_SMATRIX_DEVICE_SCHEMA, @@ -19,15 +17,12 @@ UponorSmatrixClimate = uponor_smatrix_ns.class_( UponorSmatrixDevice, ) -CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(UponorSmatrixClimate), - } -).extend(UPONOR_SMATRIX_DEVICE_SCHEMA) +CONFIG_SCHEMA = climate.climate_schema(UponorSmatrixClimate).extend( + UPONOR_SMATRIX_DEVICE_SCHEMA +) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) await cg.register_component(var, config) - await climate.register_climate(var, config) await register_uponor_smatrix_device(var, config) diff --git a/esphome/components/whirlpool/climate.py b/esphome/components/whirlpool/climate.py index 40c6053349..daee9e7fb7 100644 --- a/esphome/components/whirlpool/climate.py +++ b/esphome/components/whirlpool/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_MODEL +from esphome.const import CONF_MODEL AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@glmnet"] @@ -15,15 +15,13 @@ MODELS = { "DG11J1-91": Model.MODEL_DG11J1_91, } -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(WhirlpoolClimate).extend( { - cv.GenerateID(): cv.declare_id(WhirlpoolClimate), cv.Optional(CONF_MODEL, default="DG11J1-3A"): cv.enum(MODELS, upper=True), } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_model(config[CONF_MODEL])) diff --git a/esphome/components/whynter/climate.py b/esphome/components/whynter/climate.py index ae21c64e9b..4a01c014c7 100644 --- a/esphome/components/whynter/climate.py +++ b/esphome/components/whynter/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg from esphome.components import climate_ir import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT +from esphome.const import CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir"] @@ -9,15 +9,13 @@ whynter_ns = cg.esphome_ns.namespace("whynter") Whynter = whynter_ns.class_("Whynter", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(Whynter).extend( { - cv.GenerateID(): cv.declare_id(Whynter), cv.Optional(CONF_USE_FAHRENHEIT, default=False): cv.boolean, } ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + var = await climate_ir.new_climate_ir(config) cg.add(var.set_fahrenheit(config[CONF_USE_FAHRENHEIT])) diff --git a/esphome/components/yashima/climate.py b/esphome/components/yashima/climate.py index eb68d3b6e7..d7386eb6a3 100644 --- a/esphome/components/yashima/climate.py +++ b/esphome/components/yashima/climate.py @@ -2,7 +2,7 @@ import esphome.codegen as cg from esphome.components import climate, remote_transmitter, sensor from esphome.components.remote_base import CONF_TRANSMITTER_ID import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT +from esphome.const import CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT AUTO_LOAD = ["sensor"] @@ -10,9 +10,9 @@ yashima_ns = cg.esphome_ns.namespace("yashima") YashimaClimate = yashima_ns.class_("YashimaClimate", climate.Climate, cg.Component) CONFIG_SCHEMA = cv.All( - climate.CLIMATE_SCHEMA.extend( + climate.climate_schema(YashimaClimate) + .extend( { - cv.GenerateID(): cv.declare_id(YashimaClimate), cv.GenerateID(CONF_TRANSMITTER_ID): cv.use_id( remote_transmitter.RemoteTransmitterComponent ), @@ -20,14 +20,14 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_SUPPORTS_HEAT, default=True): cv.boolean, cv.Optional(CONF_SENSOR): cv.use_id(sensor.Sensor), } - ).extend(cv.COMPONENT_SCHEMA) + ) + .extend(cv.COMPONENT_SCHEMA) ) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) + var = await climate.new_climate(config) 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])) diff --git a/esphome/components/zhlt01/climate.py b/esphome/components/zhlt01/climate.py index fc01107e1d..d5098ab42c 100644 --- a/esphome/components/zhlt01/climate.py +++ b/esphome/components/zhlt01/climate.py @@ -1,7 +1,5 @@ import esphome.codegen as cg from esphome.components import climate_ir -import esphome.config_validation as cv -from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] CODEOWNERS = ["@cfeenstra1024"] @@ -9,11 +7,8 @@ CODEOWNERS = ["@cfeenstra1024"] zhlt01_ns = cg.esphome_ns.namespace("zhlt01") ZHLT01Climate = zhlt01_ns.class_("ZHLT01Climate", climate_ir.ClimateIR) -CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( - {cv.GenerateID(): cv.declare_id(ZHLT01Climate)} -) +CONFIG_SCHEMA = climate_ir.climare_ir_with_receiver_schema(ZHLT01Climate) async def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - await climate_ir.register_climate_ir(var, config) + await climate_ir.new_climate_ir(config)