Skip to content

Commit

Permalink
Code formated according to ESPHome requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldn committed Sep 11, 2024
1 parent 4acfbd6 commit f55885a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/haier/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,25 @@
}
)


def _final_validate(config):
full_config = fv.full_config.get()
for switch_type in [CONF_BEEPER, CONF_QUIET_MODE]:
# Check switches that are only supported for HonClimate
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])

Expand All @@ -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))

0 comments on commit f55885a

Please sign in to comment.