Skip to content

Commit

Permalink
Set parent
Browse files Browse the repository at this point in the history
  • Loading branch information
netmindz committed Oct 19, 2023
1 parent 24216e7 commit 57cc2ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions components/BalboaGL/ESPBalboaGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions components/BalboaGL/climate/BalboaGLClimate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;

Expand Down
9 changes: 6 additions & 3 deletions components/BalboaGL/climate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
CONF_SWING_MODE,
)
from esphome.core import CORE, coroutine
from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL

AUTO_LOAD = ["climate"]

Expand All @@ -23,7 +24,7 @@
DEFAULT_SWING_MODES = ["OFF"]

BalboaGL = cg.global_ns.class_(
"BalboaGL", climate.Climate, cg.PollingComponent
"BalboaGLClimate", climate.Climate, cg.PollingComponent
)


Expand Down Expand Up @@ -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}"))

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

0 comments on commit 57cc2ab

Please sign in to comment.