From f55885aec7cd2bc7096dbdcd5d8cdbf3084bc338 Mon Sep 17 00:00:00 2001 From: paveldn Date: Wed, 11 Sep 2024 14:14:51 +0200 Subject: [PATCH] Code formated according to ESPHome requirements --- components/haier/switch/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/haier/switch/__init__.py b/components/haier/switch/__init__.py index 7016649..6076cb0 100644 --- a/components/haier/switch/__init__.py +++ b/components/haier/switch/__init__.py @@ -62,6 +62,7 @@ } ) + def _final_validate(config): full_config = fv.full_config.get() for switch_type in [CONF_BEEPER, CONF_QUIET_MODE]: @@ -69,15 +70,17 @@ def _final_validate(config): if config.get(switch_type): climate_path = full_config.get_path_for_id(config[CONF_HAIER_ID])[:-1] climate_conf = full_config.get_config_for_path(climate_path) - protocol_type= climate_conf.get(CONF_PROTOCOL) + protocol_type = climate_conf.get(CONF_PROTOCOL) if protocol_type.casefold() != PROTOCOL_HON.casefold(): raise cv.Invalid( f"{switch_type} switch is only supported for hon climate" ) return config + FINAL_VALIDATE_SCHEMA = _final_validate + async def to_code(config): parent = await cg.get_variable(config[CONF_HAIER_ID]) @@ -86,4 +89,3 @@ async def to_code(config): sw_var = await switch.new_switch(conf) await cg.register_parented(sw_var, parent) cg.add(getattr(parent, f"set_{switch_type}_switch")(sw_var)) -