diff --git a/components/panasonic_heatpump/number/__init__.py b/components/panasonic_heatpump/number/__init__.py index 548c478..1c58739 100644 --- a/components/panasonic_heatpump/number/__init__.py +++ b/components/panasonic_heatpump/number/__init__.py @@ -286,3 +286,4 @@ async def to_code(config): await cg.register_component(var, child_config) await cg.register_parented(var, config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_number")(var)) + cg.add(var.set_id(index)) diff --git a/components/panasonic_heatpump/number/panasonic_heatpump_number.h b/components/panasonic_heatpump/number/panasonic_heatpump_number.h index bb3513c..5b535fd 100644 --- a/components/panasonic_heatpump/number/panasonic_heatpump_number.h +++ b/components/panasonic_heatpump/number/panasonic_heatpump_number.h @@ -13,9 +13,11 @@ namespace esphome public: PanasonicHeatpumpNumber() = default; void dump_config() override; + void set_id(int id) { this->id_ = id; } protected: void control(float value) override; + int id_; }; } // namespace panasonic_heatpump } // namespace esphome diff --git a/components/panasonic_heatpump/select/__init__.py b/components/panasonic_heatpump/select/__init__.py index 4fa60dd..28e635f 100644 --- a/components/panasonic_heatpump/select/__init__.py +++ b/components/panasonic_heatpump/select/__init__.py @@ -73,3 +73,4 @@ async def to_code(config): await cg.register_component(var, child_config) await cg.register_parented(var, config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_select")(var)) + cg.add(var.set_id(index)) diff --git a/components/panasonic_heatpump/select/panasonic_heatpump_select.h b/components/panasonic_heatpump/select/panasonic_heatpump_select.h index 85267ac..8f7ebe5 100644 --- a/components/panasonic_heatpump/select/panasonic_heatpump_select.h +++ b/components/panasonic_heatpump/select/panasonic_heatpump_select.h @@ -13,9 +13,11 @@ namespace esphome public: PanasonicHeatpumpSelect() = default; void dump_config() override; + void set_id(int id) { this->id_ = id; } protected: void control(const std::string &value) override; + int id_; }; } // namespace panasonic_heatpump } // namespace esphome diff --git a/components/panasonic_heatpump/switch/__init__.py b/components/panasonic_heatpump/switch/__init__.py index 0f3cd60..b718eab 100644 --- a/components/panasonic_heatpump/switch/__init__.py +++ b/components/panasonic_heatpump/switch/__init__.py @@ -86,9 +86,10 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): hub = await cg.get_variable(config[CONF_PANASONIC_HEATPUMP_ID]) - for key in TYPES: + for index, key in enumerate(TYPES): if child_config := config.get(key): var = await switch.new_switch(child_config) await cg.register_component(var, child_config) await cg.register_parented(var, config[CONF_PANASONIC_HEATPUMP_ID]) cg.add(getattr(hub, f"set_{key}_switch")(var)) + cg.add(var.set_id(index)) diff --git a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h index 7fd5264..de9f4f7 100644 --- a/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h +++ b/components/panasonic_heatpump/switch/panasonic_heatpump_switch.h @@ -13,9 +13,11 @@ namespace esphome public: PanasonicHeatpumpSwitch() = default; void dump_config() override; + void set_id(int id) { this->id_ = id; } protected: void write_state(bool state) override; + int id_; }; } // namespace panasonic_heatpump } // namespace esphome