From 57cc2abd7a20d44afa9f81cb7cbf7d4c02ed29e4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:03:12 +0100 Subject: [PATCH] Set parent --- components/BalboaGL/ESPBalboaGL.h | 4 ++++ components/BalboaGL/climate/BalboaGLClimate.h | 9 ++++++--- components/BalboaGL/climate/__init__.py | 9 ++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 98f9732..438e645 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -66,6 +66,10 @@ class BalboaGL : public PollingComponent { float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } + balboaGL* get_spa() { + return spa; + } + protected: //Accessor method for the HardwareSerial pointer diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index e081117..e94d033 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -3,8 +3,6 @@ #include "esphome.h" #include "esphome/core/preferences.h" -// #include "esphome/components/sensor/sensor.h" -#include "esphome/components/text_sensor/text_sensor.h" #include "esphome/components/climate/climate.h" #include "esphome/core/log.h" #include "esp_log.h" @@ -31,7 +29,12 @@ using namespace esphome; class BalboaGLClimate : public PollingComponent, public climate::Climate { public: - + void set_balboa_parent(BalboaGL* balboaGL) { + this->spa = balboaGL->get_spa(); + } + void setSpa(balboaGL* spa) { + this->spa = spa; + } // print the current configuration void dump_config() override; diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 25fbed4..a58ad46 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -11,6 +11,7 @@ CONF_SWING_MODE, ) from esphome.core import CORE, coroutine +from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL AUTO_LOAD = ["climate"] @@ -23,7 +24,7 @@ DEFAULT_SWING_MODES = ["OFF"] BalboaGL = cg.global_ns.class_( - "BalboaGL", climate.Climate, cg.PollingComponent + "BalboaGLClimate", climate.Climate, cg.PollingComponent ) @@ -60,8 +61,7 @@ def valid_uart(uart): ).extend(cv.COMPONENT_SCHEMA) -@coroutine -def to_code(config): +async def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) @@ -85,3 +85,6 @@ def to_code(config): yield cg.register_component(var, config) yield climate.register_climate(var, config) + + paren = await cg.get_variable(config[CONF_BALBOA_ID]) + cg.add(var.set_balboa_parent(paren)) \ No newline at end of file