diff --git a/components/panasonic_heatpump/__init__.py b/components/panasonic_heatpump/__init__.py index 0c18bd6..0eedacc 100644 --- a/components/panasonic_heatpump/__init__.py +++ b/components/panasonic_heatpump/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import uart -from esphome.const import CONF_ID, CONF_ADDRESS +from esphome.const import CONF_ID CODEOWNERS = ['@elvit'] MULTICONF = True diff --git a/components/panasonic_heatpump/binary_sensor.py b/components/panasonic_heatpump/binary_sensor.py old mode 100755 new mode 100644 index 015e292..837ecfe --- a/components/panasonic_heatpump/binary_sensor.py +++ b/components/panasonic_heatpump/binary_sensor.py @@ -85,12 +85,12 @@ CONFIG_SCHEMA = cv.All( ).extend(cv.COMPONENT_SCHEMA) ) -async def setup_conf(config, key, hub): - if sensor_config := config.get(key): - var = await binary_sensor.new_binary_sensor(sensor_config) - cg.add(getattr(hub, f"set_{key}_binary_sensor")(var)) - async def to_code(config): - hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) - for key in TYPES: - await setup_conf(config, key, hub) + hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) + for key in TYPES: + await setup_conf(config, key, hub) + +async def setup_conf(parent_config, key, hub): + if child_config := parent_config.get(key): + var = await binary_sensor.new_binary_sensor(child_config) + cg.add(getattr(hub, f"set_{key}_binary_sensor")(var)) diff --git a/components/panasonic_heatpump/decode.cpp b/components/panasonic_heatpump/decode.cpp old mode 100755 new mode 100644 diff --git a/components/panasonic_heatpump/decode.h b/components/panasonic_heatpump/decode.h old mode 100755 new mode 100644 diff --git a/components/panasonic_heatpump/panasonic_heatpump.h b/components/panasonic_heatpump/panasonic_heatpump.h old mode 100755 new mode 100644 diff --git a/components/panasonic_heatpump/sensor.py b/components/panasonic_heatpump/sensor.py old mode 100755 new mode 100644 index 012f553..37c16d7 --- a/components/panasonic_heatpump/sensor.py +++ b/components/panasonic_heatpump/sensor.py @@ -686,12 +686,12 @@ CONFIG_SCHEMA = cv.All( ).extend(cv.COMPONENT_SCHEMA) ) -async def setup_conf(config, key, hub): - if sensor_config := config.get(key): - sens = await sensor.new_sensor(sensor_config) - cg.add(getattr(hub, f"set_{key}_sensor")(sens)) - async def to_code(config): - hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) - for key in TYPES: - await setup_conf(config, key, hub) + hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) + for key in TYPES: + await setup_conf(config, key, hub) + +async def setup_conf(parent_config, key, hub): + if child_config := parent_config.get(key): + var = await sensor.new_sensor(child_config) + cg.add(getattr(hub, f"set_{key}_sensor")(var)) diff --git a/components/panasonic_heatpump/text_sensor.py b/components/panasonic_heatpump/text_sensor.py old mode 100755 new mode 100644 index 949516a..f40d93a --- a/components/panasonic_heatpump/text_sensor.py +++ b/components/panasonic_heatpump/text_sensor.py @@ -124,12 +124,12 @@ CONFIG_SCHEMA = cv.All( ).extend(cv.COMPONENT_SCHEMA) ) -async def setup_conf(config, key, hub): - if sensor_config := config.get(key): - sens = await text_sensor.new_text_sensor(sensor_config) - cg.add(getattr(hub, f"set_{key}_text_sensor")(sens)) - async def to_code(config): - hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) - for key in TYPES: - await setup_conf(config, key, hub) + hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) + for key in TYPES: + await setup_conf(config, key, hub) + +async def setup_conf(parent_config, key, hub): + if child_config := parent_config.get(key): + var = await text_sensor.new_text_sensor(child_config) + cg.add(getattr(hub, f"set_{key}_text_sensor")(var)) \ No newline at end of file diff --git a/example_panasonic_heatpump.yaml b/example_panasonic_heatpump.yaml old mode 100755 new mode 100644