From 51c405b543486f8f3f39824775a3cccad188eb29 Mon Sep 17 00:00:00 2001 From: ElVit Date: Sun, 20 Jul 2025 20:13:05 +0200 Subject: [PATCH] Added support for extra query (fixes #11) --- .../panasonic_heatpump/panasonic_heatpump.cpp | 3 ++- components/panasonic_heatpump/sensor/__init__.py | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/components/panasonic_heatpump/panasonic_heatpump.cpp b/components/panasonic_heatpump/panasonic_heatpump.cpp index d1d72a3..14cf300 100644 --- a/components/panasonic_heatpump/panasonic_heatpump.cpp +++ b/components/panasonic_heatpump/panasonic_heatpump.cpp @@ -10,7 +10,8 @@ namespace esphome void PanasonicHeatpumpComponent::dump_config() { - ESP_LOGCONFIG(TAG, "*** Panasonic Heatpump *** v0.0.4-dev1 ***"); + ESP_LOGCONFIG(TAG, "Panasonic Heatpump Component"); + ESP_LOGW(TAG, "*** v0.0.4-dev2 ***"); delay(10); // NOLINT } diff --git a/components/panasonic_heatpump/sensor/__init__.py b/components/panasonic_heatpump/sensor/__init__.py index 904ec57..5298138 100644 --- a/components/panasonic_heatpump/sensor/__init__.py +++ b/components/panasonic_heatpump/sensor/__init__.py @@ -231,9 +231,7 @@ TYPES = [ CONF_TOP136, CONF_TOP137, CONF_TOP138, -] -EXTRA_TYPES = [ CONF_XTOP0, CONF_XTOP1, CONF_XTOP2, @@ -964,11 +962,7 @@ async def to_code(config): await cg.register_component(var, child_config) cg.add(var.set_parent(parent)) cg.add(var.set_id(index)) - cg.add(parent.add_sensor(var)) - for index, key in enumerate(EXTRA_TYPES): - if child_config := config.get(key): - var = await sensor.new_sensor(child_config) - await cg.register_component(var, child_config) - cg.add(var.set_parent(parent)) - cg.add(var.set_id(index)) - cg.add(parent.add_extra_sensor(var)) + if key.startswith("xtop"): + cg.add(parent.add_extra_sensor(var)) + else: + cg.add(parent.add_sensor(var))