From 562c3e090a638f7b9d66b1114c99b16ecd61b266 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 12:55:34 +0100 Subject: [PATCH 001/378] Add ESPHome compontent --- sensor/components/BalboaGL/ESPBalboaGL.h | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 sensor/components/BalboaGL/ESPBalboaGL.h diff --git a/sensor/components/BalboaGL/ESPBalboaGL.h b/sensor/components/BalboaGL/ESPBalboaGL.h new file mode 100644 index 0000000..8caf598 --- /dev/null +++ b/sensor/components/BalboaGL/ESPBalboaGL.h @@ -0,0 +1,4 @@ +#include "esphome.h" + +class BalboaGL : public PollingComponent, public climate::Climate { +} From 966fe7a08a92b17a699fd1b14386f941ea098665 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:06:52 +0100 Subject: [PATCH 002/378] Fix components dir --- README-ESPHome.md | 2 ++ {sensor/components => components}/BalboaGL/ESPBalboaGL.h | 0 2 files changed, 2 insertions(+) create mode 100644 README-ESPHome.md rename {sensor/components => components}/BalboaGL/ESPBalboaGL.h (100%) diff --git a/README-ESPHome.md b/README-ESPHome.md new file mode 100644 index 0000000..586554d --- /dev/null +++ b/README-ESPHome.md @@ -0,0 +1,2 @@ +external_components: + - source: github://netmindz/balboa_GL_ML_spa_control#ESPHome diff --git a/sensor/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h similarity index 100% rename from sensor/components/BalboaGL/ESPBalboaGL.h rename to components/BalboaGL/ESPBalboaGL.h From 58046069dd814c07a7fd1e423998e4ef5d4d59cc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:10:40 +0100 Subject: [PATCH 003/378] Update readme --- README-ESPHome.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README-ESPHome.md b/README-ESPHome.md index 586554d..101cde6 100644 --- a/README-ESPHome.md +++ b/README-ESPHome.md @@ -1,2 +1,5 @@ external_components: - - source: github://netmindz/balboa_GL_ML_spa_control#ESPHome + - source: + type: git + url: https://github.com/netmindz/balboa_GL_ML_spa_control + ref: ESPHome From 71893b7aa176a0a65ad9dddf4a86cbce216f063e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:22:18 +0100 Subject: [PATCH 004/378] Register as component plaform --- README-ESPHome.md => component.yaml | 0 components/BalboaGL/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename README-ESPHome.md => component.yaml (100%) create mode 100644 components/BalboaGL/__init__.py diff --git a/README-ESPHome.md b/component.yaml similarity index 100% rename from README-ESPHome.md rename to component.yaml diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py new file mode 100644 index 0000000..e69de29 From 4ec5dff65b01a2c73b1c9bfe38d66fecb640eeb7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:25:19 +0100 Subject: [PATCH 005/378] Remove python init --- components/BalboaGL/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 components/BalboaGL/__init__.py diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py deleted file mode 100644 index e69de29..0000000 From 9380b99949e97e3bfb8c19d149ae6eab4659b160 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:38:18 +0100 Subject: [PATCH 006/378] Revert "Remove python init" This reverts commit 4ec5dff65b01a2c73b1c9bfe38d66fecb640eeb7. --- components/BalboaGL/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 components/BalboaGL/__init__.py diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py new file mode 100644 index 0000000..e69de29 From c21db726f734de80b4eaf28d698ca67cbc73ea4f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:39:19 +0100 Subject: [PATCH 007/378] Add climate.py --- components/BalboaGL/climate.py | 94 ++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 components/BalboaGL/climate.py diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py new file mode 100644 index 0000000..93c4e5f --- /dev/null +++ b/components/BalboaGL/climate.py @@ -0,0 +1,94 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import climate +from esphome.components.logger import HARDWARE_UART_TO_SERIAL +from esphome.const import ( + CONF_ID, + CONF_HARDWARE_UART, + CONF_BAUD_RATE, + CONF_UPDATE_INTERVAL, + CONF_MODE, + CONF_FAN_MODE, + CONF_SWING_MODE, +) +from esphome.core import CORE, coroutine + +AUTO_LOAD = ["climate"] + +CONF_SUPPORTS = "supports" +DEFAULT_CLIMATE_MODES = ["HEAT_COOL", "COOL", "HEAT", "DRY", "FAN_ONLY"] +DEFAULT_FAN_MODES = ["AUTO", "DIFFUSE", "LOW", "MEDIUM", "MIDDLE", "HIGH"] +DEFAULT_SWING_MODES = ["OFF", "VERTICAL"] + +MitsubishiHeatPump = cg.global_ns.class_( + "MitsubishiHeatPump", climate.Climate, cg.PollingComponent +) + + +def valid_uart(uart): + if CORE.is_esp8266: + uarts = ["UART0"] # UART1 is tx-only + elif CORE.is_esp32: + uarts = ["UART0", "UART1", "UART2"] + else: + raise NotImplementedError + + return cv.one_of(*uarts, upper=True)(uart) + + +CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(MitsubishiHeatPump), + cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, + cv.Optional(CONF_BAUD_RATE): cv.positive_int, + # If polling interval is greater than 9 seconds, the HeatPump library + # reconnects, but doesn't then follow up with our data request. + cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( + cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) + ), + # Optionally override the supported ClimateTraits. + cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( + { + cv.Optional(CONF_MODE, default=DEFAULT_CLIMATE_MODES): + cv.ensure_list(climate.validate_climate_mode), + cv.Optional(CONF_FAN_MODE, default=DEFAULT_FAN_MODES): + cv.ensure_list(climate.validate_climate_fan_mode), + cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): + cv.ensure_list(climate.validate_climate_swing_mode), + } + ), + } +).extend(cv.COMPONENT_SCHEMA) + + +@coroutine +def to_code(config): + serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] + var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) + + if CONF_BAUD_RATE in config: + cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) + + supports = config[CONF_SUPPORTS] + traits = var.config_traits() + + for mode in supports[CONF_MODE]: + if mode == "OFF": + continue + cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) + + for mode in supports[CONF_FAN_MODE]: + cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) + + for mode in supports[CONF_SWING_MODE]: + cg.add(traits.add_supported_swing_mode( + climate.CLIMATE_SWING_MODES[mode] + )) + + yield cg.register_component(var, config) + yield climate.register_climate(var, config) + cg.add_library( + name="HeatPump", + repository="https://github.com/SwiCago/HeatPump", + version="d6a29134401d7caae1b8fca9c452c8eb92af60c5", + ) From 71a5be7b027e5398344edbf3a4adc9ae35ba6219 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:44:54 +0100 Subject: [PATCH 008/378] Start tweaking climate.py --- components/BalboaGL/climate.py | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 93c4e5f..732c4fd 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -16,20 +16,18 @@ AUTO_LOAD = ["climate"] CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ["HEAT_COOL", "COOL", "HEAT", "DRY", "FAN_ONLY"] -DEFAULT_FAN_MODES = ["AUTO", "DIFFUSE", "LOW", "MEDIUM", "MIDDLE", "HIGH"] -DEFAULT_SWING_MODES = ["OFF", "VERTICAL"] +DEFAULT_CLIMATE_MODES = ["HEAT"] +DEFAULT_FAN_MODES = ["AUTO"] +DEFAULT_SWING_MODES = ["OFF"] -MitsubishiHeatPump = cg.global_ns.class_( - "MitsubishiHeatPump", climate.Climate, cg.PollingComponent +BalboaGL = cg.global_ns.class_( + "BalboaGL", climate.Climate, cg.PollingComponent ) def valid_uart(uart): - if CORE.is_esp8266: - uarts = ["UART0"] # UART1 is tx-only - elif CORE.is_esp32: - uarts = ["UART0", "UART1", "UART2"] + if CORE.is_esp32: + uarts = [ "UART1", "UART2"] else: raise NotImplementedError @@ -38,7 +36,7 @@ def valid_uart(uart): CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { - cv.GenerateID(): cv.declare_id(MitsubishiHeatPump), + cv.GenerateID(): cv.declare_id(BalboaGL), cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, cv.Optional(CONF_BAUD_RATE): cv.positive_int, # If polling interval is greater than 9 seconds, the HeatPump library @@ -87,8 +85,8 @@ def to_code(config): yield cg.register_component(var, config) yield climate.register_climate(var, config) - cg.add_library( - name="HeatPump", - repository="https://github.com/SwiCago/HeatPump", - version="d6a29134401d7caae1b8fca9c452c8eb92af60c5", - ) +# cg.add_library( +# name="HeatPump", +# repository="https://github.com/SwiCago/HeatPump", +# version="d6a29134401d7caae1b8fca9c452c8eb92af60c5", +# ) From df35531c74bda08e222caa002aa535e78a08fe4f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:47:29 +0100 Subject: [PATCH 009/378] Start tweaking climate.py --- component.yaml | 1 + components/BalboaGL/climate.py | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/component.yaml b/component.yaml index 101cde6..02717f3 100644 --- a/component.yaml +++ b/component.yaml @@ -3,3 +3,4 @@ external_components: type: git url: https://github.com/netmindz/balboa_GL_ML_spa_control ref: ESPHome + refresh: 0s diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 732c4fd..c0df60e 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -25,25 +25,25 @@ ) -def valid_uart(uart): - if CORE.is_esp32: - uarts = [ "UART1", "UART2"] - else: - raise NotImplementedError - - return cv.one_of(*uarts, upper=True)(uart) +#def valid_uart(uart): +# if CORE.is_esp32: +# uarts = [ "UART1", "UART2"] +# else: +# raise NotImplementedError +# +# return cv.one_of(*uarts, upper=True)(uart) CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(BalboaGL), - cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, - cv.Optional(CONF_BAUD_RATE): cv.positive_int, +# cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, +# cv.Optional(CONF_BAUD_RATE): cv.positive_int, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. - cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( - cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) - ), +# cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( +# cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) +# ), # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { @@ -61,11 +61,11 @@ def valid_uart(uart): @coroutine def to_code(config): - serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] +# serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) - if CONF_BAUD_RATE in config: - cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) +# if CONF_BAUD_RATE in config: +# cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) supports = config[CONF_SUPPORTS] traits = var.config_traits() From 8b2dcd0bf4db69933a777706c08139a2b2bb4909 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:47:56 +0100 Subject: [PATCH 010/378] Start tweaking climate.py --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index c0df60e..7431455 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -62,7 +62,7 @@ @coroutine def to_code(config): # serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] - var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) +# var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) # if CONF_BAUD_RATE in config: # cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) From 08f3d23d8e2dce03ebd59c23bdcf55912899916a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:49:22 +0100 Subject: [PATCH 011/378] Start tweaking climate.py --- components/BalboaGL/climate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 7431455..7118c24 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -61,8 +61,8 @@ @coroutine def to_code(config): -# serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] -# var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) + serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] + var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) # if CONF_BAUD_RATE in config: # cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) From c61d129574b59bbb3126438c5578aae851cef4db Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:49:53 +0100 Subject: [PATCH 012/378] Start tweaking climate.py --- components/BalboaGL/climate.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 7118c24..0f465da 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -25,13 +25,13 @@ ) -#def valid_uart(uart): -# if CORE.is_esp32: -# uarts = [ "UART1", "UART2"] -# else: -# raise NotImplementedError -# -# return cv.one_of(*uarts, upper=True)(uart) +def valid_uart(uart): + if CORE.is_esp32: + uarts = [ "UART1", "UART2"] + else: + raise NotImplementedError + + return cv.one_of(*uarts, upper=True)(uart) CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( From 6cdb4c7160e76d5e3cb8ba6929124665f67dac80 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:50:27 +0100 Subject: [PATCH 013/378] Start tweaking climate.py --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 0f465da..fa82e64 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -37,7 +37,7 @@ def valid_uart(uart): CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(BalboaGL), -# cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, + cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # cv.Optional(CONF_BAUD_RATE): cv.positive_int, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. From 9df16cb02fd6e82b72dfa820238c48df3cff1da1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:58:18 +0100 Subject: [PATCH 014/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 8caf598..cbe6e6b 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,4 +1,5 @@ #include "esphome.h" +using namespace esphome; class BalboaGL : public PollingComponent, public climate::Climate { } From 8184dbfcf899a69e4ef90b5d095313ce7a6a6d0a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 13:59:41 +0100 Subject: [PATCH 015/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index cbe6e6b..463dad1 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,5 @@ #include "esphome.h" -using namespace esphome; +// using namespace esphome; -class BalboaGL : public PollingComponent, public climate::Climate { +class BalboaGL : public PollingComponent, public Climate { } From f892f47e4fb01b9e6a23ade17c366b6da74aa44f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:02:53 +0100 Subject: [PATCH 016/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 463dad1..de543b5 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -2,4 +2,33 @@ // using namespace esphome; class BalboaGL : public PollingComponent, public Climate { + public: + void setup() override { + // This will be called by App.setup() + } + void control(const ClimateCall &call) override { + if (call.get_mode().has_value()) { + // User requested mode change + ClimateMode mode = *call.get_mode(); + // Send mode to hardware + // ... + + // Publish updated state + this->mode = mode; + this->publish_state(); + } + if (call.get_target_temperature().has_value()) { + // User requested target temperature change + float temp = *call.get_target_temperature(); + // Send target temp to climate + // ... + } + } + ClimateTraits traits() override { + // The capabilities of the climate device + auto traits = climate::ClimateTraits(); + traits.set_supports_current_temperature(true); + traits.set_supported_modes({climate::CLIMATE_MODE_HEAT_COOL}); + return traits; + } } From 3a61859bb11ee3cf1c5893cab3f88b475dba22ee Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:05:06 +0100 Subject: [PATCH 017/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index de543b5..c2db97b 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,7 +1,7 @@ #include "esphome.h" // using namespace esphome; -class BalboaGL : public PollingComponent, public Climate { +class BalboaGL : public Component, public Climate { public: void setup() override { // This will be called by App.setup() From 16bd0b0e3d8c725b9204ea8af3f3d6e3391fa0d2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:08:55 +0100 Subject: [PATCH 018/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index c2db97b..806b5b7 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,4 +1,6 @@ #include "esphome.h" +#include "../../sensor/src/balboaGL.h" + // using namespace esphome; class BalboaGL : public Component, public Climate { From 3e2e2bff83af2dec34859f600751ed155a8d5959 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:10:46 +0100 Subject: [PATCH 019/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 2 +- components/BalboaGL/climate.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 806b5b7..112da4c 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,5 @@ #include "esphome.h" -#include "../../sensor/src/balboaGL.h" +#include "./sensor/src/balboaGL.h" // using namespace esphome; diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index fa82e64..7f6a5ae 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -85,8 +85,8 @@ def to_code(config): yield cg.register_component(var, config) yield climate.register_climate(var, config) -# cg.add_library( -# name="HeatPump", -# repository="https://github.com/SwiCago/HeatPump", -# version="d6a29134401d7caae1b8fca9c452c8eb92af60c5", -# ) + cg.add_library( + name="balboa_GL_ML_spa_control", + repository="https://github.com/netmindz/balboa_GL_ML_spa_control", + version="library", + ) From 46b0cc45fd235c1128e363194f093c07143bd7da Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:14:50 +0100 Subject: [PATCH 020/378] Trying to build basic compontent --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 112da4c..d3da2af 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,5 @@ #include "esphome.h" -#include "./sensor/src/balboaGL.h" +#include "balboaGL.h" // using namespace esphome; From aee45ce09217a0e16709e2537cf45510d984180f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 23 Jul 2023 14:17:04 +0100 Subject: [PATCH 021/378] Trying to build basic compontent --- component.yaml | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/component.yaml b/component.yaml index 02717f3..76af3e9 100644 --- a/component.yaml +++ b/component.yaml @@ -1,6 +1,68 @@ +esphome: + name: hottub + friendly_name: Hottub + +esp32: + board: esp32dev + framework: + type: arduino + external_components: - source: type: git - url: https://github.com/netmindz/balboa_GL_ML_spa_control + url: https://github.com/netmindz/balboa_GL_ML_spa_control.git ref: ESPHome refresh: 0s + components: [BalboaGL] + + +# Enable logging +logger: + +# Enable Home Assistant API +api: + encryption: + key: "sUhVA1uqxqWBmBu6BGISQHfi7+9a0HXf+1WIcBYrnz0=" + +ota: + password: "e82fe9bada398051d779151a591a1e2e" + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password + + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Hottub Fallback Hotspot" + password: "tHV1HzrYNvGo" + +captive_portal: + +# Text sensors with general information. +text_sensor: + # Expose ESPHome version as sensor. + - platform: version + name: ${name} ESPHome Version + # Expose WiFi information as sensors. + - platform: wifi_info + ip_address: + name: ${name} IP + ssid: + name: ${name} SSID + bssid: + name: ${name} BSSID + +# Sensors with general information. +sensor: + # Uptime sensor. + - platform: uptime + name: ${name} Uptime + + # WiFi Signal sensor. + - platform: wifi_signal + name: ${name} WiFi Signal + update_interval: 60s + +climate: + - platform: BalboaGL + name: ${friendly_name} From 0e6f854fdac21033fb441bebff08ac8c72617e1a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 12:51:49 +0100 Subject: [PATCH 022/378] Update component example --- component.yaml | 116 +++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/component.yaml b/component.yaml index 76af3e9..84c4074 100644 --- a/component.yaml +++ b/component.yaml @@ -1,68 +1,72 @@ -esphome: - name: hottub - friendly_name: Hottub + esphome: + name: hottub + friendly_name: Hottub + libraries: + - balboa=https://github.com/netmindz/balboa_GL_ML_spa_control.git#library + - ArduinoQueue=https://github.com/EinarArnason/ArduinoQueue.git@^1.2.5 + -esp32: - board: esp32dev - framework: - type: arduino + esp32: + board: esp32dev + framework: + type: arduino -external_components: - - source: - type: git - url: https://github.com/netmindz/balboa_GL_ML_spa_control.git - ref: ESPHome - refresh: 0s - components: [BalboaGL] + external_components: + - source: + type: git + url: https://github.com/netmindz/balboa_GL_ML_spa_control.git + ref: ESPHome + refresh: 0s + components: [BalboaGL] -# Enable logging -logger: + # Enable logging + logger: -# Enable Home Assistant API -api: - encryption: - key: "sUhVA1uqxqWBmBu6BGISQHfi7+9a0HXf+1WIcBYrnz0=" + # Enable Home Assistant API + api: + encryption: + key: "sUhVA1uqxqWBmBu6BGISQHfi7+9a0HXf+1WIcBYrnz0=" -ota: - password: "e82fe9bada398051d779151a591a1e2e" + ota: + password: "e82fe9bada398051d779151a591a1e2e" -wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password + wifi: + ssid: !secret wifi_ssid + password: !secret wifi_password - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Hottub Fallback Hotspot" - password: "tHV1HzrYNvGo" + # Enable fallback hotspot (captive portal) in case wifi connection fails + ap: + ssid: "Hottub Fallback Hotspot" + password: "tHV1HzrYNvGo" -captive_portal: - -# Text sensors with general information. -text_sensor: - # Expose ESPHome version as sensor. - - platform: version - name: ${name} ESPHome Version - # Expose WiFi information as sensors. - - platform: wifi_info - ip_address: - name: ${name} IP - ssid: - name: ${name} SSID - bssid: - name: ${name} BSSID + captive_portal: + + # Text sensors with general information. + text_sensor: + # Expose ESPHome version as sensor. + - platform: version + name: ${name} ESPHome Version + # Expose WiFi information as sensors. + - platform: wifi_info + ip_address: + name: ${name} IP + ssid: + name: ${name} SSID + bssid: + name: ${name} BSSID -# Sensors with general information. -sensor: - # Uptime sensor. - - platform: uptime - name: ${name} Uptime + # Sensors with general information. + sensor: + # Uptime sensor. + - platform: uptime + name: ${name} Uptime - # WiFi Signal sensor. - - platform: wifi_signal - name: ${name} WiFi Signal - update_interval: 60s + # WiFi Signal sensor. + - platform: wifi_signal + name: ${name} WiFi Signal + update_interval: 60s -climate: - - platform: BalboaGL - name: ${friendly_name} + climate: + - platform: BalboaGL + name: ${friendly_name} From a721d42f9b25e968e0fc5d45f85ef6adf992cf49 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 12:54:25 +0100 Subject: [PATCH 023/378] Add constants.h --- components/BalboaGL/ESPBalboaGL.h | 1 + components/BalboaGL/constants.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 components/BalboaGL/constants.h diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index d3da2af..b9ce379 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,6 @@ #include "esphome.h" #include "balboaGL.h" +#include "constants.h" // using namespace esphome; diff --git a/components/BalboaGL/constants.h b/components/BalboaGL/constants.h new file mode 100644 index 0000000..43d0731 --- /dev/null +++ b/components/BalboaGL/constants.h @@ -0,0 +1,29 @@ +// https://godbolt.org/z/TEqhrhvPc + +#define COMMAND_UP "fb0603450e0001fe66" +#define COMMAND_DOWN "fb0603450e0002fd50" +//#define COMMAND_TOGGLE "fb066666666609f6c2" +// #define COMMAND_TIME "fb066666666603fc76" +#define COMMAND_CHANGE_MODE "fb0603450e0004fb3c" +// #define COMMAND_BLOWER "fb06666666660af5f4" +#define COMMAND_JET1 "fb060343060006f9a2" // TODO: fix me - swapped to tmjo's panel as mine was one char short in my notes +#define COMMAND_JET2 "fb060343060007f8b0" // TODO: fix me - swapped to tmjo's panel as mine was one char short in my notes +#define COMMAND_EMPTY "fb0603450e0000ff74" +#define COMMAND_LIGHT "fb0603450e0009f6f6" + +// Std;Eco;Sleep +#define MODE_IDX_STD 0 +#define MODE_IDX_ECO 1 +#define MODE_IDX_SLP 2 + +#ifdef PUMP1_DUAL_SPEED +#define PUMP1_STATE_HIGH 2 +#else +#define PUMP1_STATE_HIGH 1 +#endif + +#ifdef PUMP2_DUAL_SPEED +#define PUMP2_STATE_HIGH 2 +#else +#define PUMP2_STATE_HIGH 1 +#endif From 84a4c540d6df8dc3fb56a8e96147e5a84052f9a2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 12:55:04 +0100 Subject: [PATCH 024/378] Add constants.h --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index b9ce379..f40d7fc 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,6 +1,6 @@ #include "esphome.h" -#include "balboaGL.h" #include "constants.h" +#include "balboaGL.h" // using namespace esphome; From 9d11296b880befb138dbf7958b68eed7460c0eb5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 12:57:27 +0100 Subject: [PATCH 025/378] Add power usage values --- components/BalboaGL/ESPBalboaGL.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index f40d7fc..7fb9bb1 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -2,6 +2,20 @@ #include "constants.h" #include "balboaGL.h" + +// Perform measurements or read nameplate values on your tub to define the power [kW] +// for each device in order to calculate tub power usage +const float POWER_HEATER = 2.8; +const float POWER_PUMP_CIRCULATION = 0.3; +const float POWER_PUMP1_LOW = 0.31; +const float POWER_PUMP1_HIGH = 1.3; +const float POWER_PUMP2_LOW = 0.3; +const float POWER_PUMP2_HIGH = 0.6; + +// Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc +const int MINUTES_PER_DEGC = 45; + + // using namespace esphome; class BalboaGL : public Component, public Climate { From bc674081e5cf47da3bdae526ff222e60320beb3b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 12:58:47 +0100 Subject: [PATCH 026/378] Add power usage values --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 7fb9bb1..80437bb 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,6 +1,5 @@ #include "esphome.h" #include "constants.h" -#include "balboaGL.h" // Perform measurements or read nameplate values on your tub to define the power [kW] @@ -15,6 +14,7 @@ const float POWER_PUMP2_HIGH = 0.6; // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc const int MINUTES_PER_DEGC = 45; +#include "balboaGL.h" // using namespace esphome; From 4e035d9fcfd7c666753752ecb9611d4c4dd8775a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:00:35 +0100 Subject: [PATCH 027/378] Add hard coded pin setup --- components/BalboaGL/ESPBalboaGL.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 80437bb..f71b488 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -14,6 +14,14 @@ const float POWER_PUMP2_HIGH = 0.6; // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc const int MINUTES_PER_DEGC = 45; + +#define tub Serial2 +#define RX_PIN 19 +#define TX_PIN 23 +#define RTS_PIN 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. +#define PIN_5_PIN 18 + + #include "balboaGL.h" // using namespace esphome; From 8b5f527ff4e420f6bd52d1d2191ea995a88fd7da Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:05:52 +0100 Subject: [PATCH 028/378] Add LED --- components/BalboaGL/ESPBalboaGL.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index f71b488..88962bd 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -20,11 +20,12 @@ const int MINUTES_PER_DEGC = 45; #define TX_PIN 23 #define RTS_PIN 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. #define PIN_5_PIN 18 +#define LED_BUILTIN 2 #include "balboaGL.h" -// using namespace esphome; +using namespace esphome; class BalboaGL : public Component, public Climate { public: From af528db03a6815fcd5d429550ecd62aa53a07aa8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:12:26 +0100 Subject: [PATCH 029/378] Trying to fix missing class --- components/BalboaGL/ESPBalboaGL.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 88962bd..4f76696 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,4 +1,6 @@ #include "esphome.h" +#include "esphome/core/preferences.h" + #include "constants.h" @@ -27,7 +29,7 @@ const int MINUTES_PER_DEGC = 45; using namespace esphome; -class BalboaGL : public Component, public Climate { +class BalboaGL : public Component, public climate::Climate { public: void setup() override { // This will be called by App.setup() From bea7e0e04fe5f12a0059abd3859ae81bab1f8ff5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:16:38 +0100 Subject: [PATCH 030/378] Trying to fix missing class --- components/BalboaGL/ESPBalboaGL.h | 52 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 4f76696..9ed4f57 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -29,34 +29,34 @@ const int MINUTES_PER_DEGC = 45; using namespace esphome; -class BalboaGL : public Component, public climate::Climate { +class BalboaGL : public Component { // }, public climate::Climate { public: void setup() override { // This will be called by App.setup() } - void control(const ClimateCall &call) override { - if (call.get_mode().has_value()) { - // User requested mode change - ClimateMode mode = *call.get_mode(); - // Send mode to hardware - // ... - - // Publish updated state - this->mode = mode; - this->publish_state(); - } - if (call.get_target_temperature().has_value()) { - // User requested target temperature change - float temp = *call.get_target_temperature(); - // Send target temp to climate - // ... - } - } - ClimateTraits traits() override { - // The capabilities of the climate device - auto traits = climate::ClimateTraits(); - traits.set_supports_current_temperature(true); - traits.set_supported_modes({climate::CLIMATE_MODE_HEAT_COOL}); - return traits; - } + // void control(const ClimateCall &call) override { + // if (call.get_mode().has_value()) { + // // User requested mode change + // ClimateMode mode = *call.get_mode(); + // // Send mode to hardware + // // ... + + // // Publish updated state + // this->mode = mode; + // this->publish_state(); + // } + // if (call.get_target_temperature().has_value()) { + // // User requested target temperature change + // float temp = *call.get_target_temperature(); + // // Send target temp to climate + // // ... + // } + // } + // ClimateTraits traits() override { + // // The capabilities of the climate device + // auto traits = climate::ClimateTraits(); + // traits.set_supports_current_temperature(true); + // traits.set_supported_modes({climate::CLIMATE_MODE_HEAT_COOL}); + // return traits; + // } } From 53b379d53486ff578a968ccb5ae4bd44a457236c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:20:52 +0100 Subject: [PATCH 031/378] Add constructor --- components/BalboaGL/ESPBalboaGL.h | 35 +++++++------------------------ 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 9ed4f57..54eed05 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -31,32 +31,11 @@ using namespace esphome; class BalboaGL : public Component { // }, public climate::Climate { public: - void setup() override { - // This will be called by App.setup() - } - // void control(const ClimateCall &call) override { - // if (call.get_mode().has_value()) { - // // User requested mode change - // ClimateMode mode = *call.get_mode(); - // // Send mode to hardware - // // ... - - // // Publish updated state - // this->mode = mode; - // this->publish_state(); - // } - // if (call.get_target_temperature().has_value()) { - // // User requested target temperature change - // float temp = *call.get_target_temperature(); - // // Send target temp to climate - // // ... - // } - // } - // ClimateTraits traits() override { - // // The capabilities of the climate device - // auto traits = climate::ClimateTraits(); - // traits.set_supports_current_temperature(true); - // traits.set_supported_modes({climate::CLIMATE_MODE_HEAT_COOL}); - // return traits; - // } + BalboaGL( + HardwareSerial* hw_serial, + uint32_t poll_interval=ESPMHP_POLL_INTERVAL_DEFAULT + ); + private: + // Retrieve the HardwareSerial pointer from friend and subclasses. + HardwareSerial *hw_serial_; } From d5027dcde72daa6d65ea64f0b21b840ef087cbc4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:22:06 +0100 Subject: [PATCH 032/378] Trying to fix missing class --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 54eed05..f7d6943 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -29,7 +29,7 @@ const int MINUTES_PER_DEGC = 45; using namespace esphome; -class BalboaGL : public Component { // }, public climate::Climate { +class BalboaGL : public Component, public climate::Climate { public: BalboaGL( HardwareSerial* hw_serial, From 718dd5f7eb1bebe25ecf0c7dc1972be9ad73490e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:30:21 +0100 Subject: [PATCH 033/378] Trying to fix missing class --- components/BalboaGL/ESPBalboaGL.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index f7d6943..8883cfc 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,6 @@ #include "esphome.h" #include "esphome/core/preferences.h" +#include "esphome/components/climate/climate.h" #include "constants.h" @@ -33,7 +34,7 @@ class BalboaGL : public Component, public climate::Climate { public: BalboaGL( HardwareSerial* hw_serial, - uint32_t poll_interval=ESPMHP_POLL_INTERVAL_DEFAULT + uint32_t poll_interval=0 ); private: // Retrieve the HardwareSerial pointer from friend and subclasses. From cac87e937a5bef380cc33f3ca40e07d4a3bda688 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:32:14 +0100 Subject: [PATCH 034/378] Trying to fix missing class --- components/BalboaGL/ESPBalboaGL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 8883cfc..1585d38 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -34,9 +34,9 @@ class BalboaGL : public Component, public climate::Climate { public: BalboaGL( HardwareSerial* hw_serial, - uint32_t poll_interval=0 + // uint32_t poll_interval=0 ); private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; -} +}; From 5062a191b4c86fe55d2e905c572c22c47671f031 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:34:48 +0100 Subject: [PATCH 035/378] Add missing method signature --- components/BalboaGL/ESPBalboaGL.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 1585d38..da33bdb 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -33,9 +33,16 @@ using namespace esphome; class BalboaGL : public Component, public climate::Climate { public: BalboaGL( - HardwareSerial* hw_serial, + HardwareSerial* hw_serial // uint32_t poll_interval=0 ); + + // Configure the climate object with traits that we support. + climate::ClimateTraits traits() override; + + // Get a mutable reference to the traits that we support. + climate::ClimateTraits& config_traits(); + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From c61c0339d4b8f81154ddd26948a1ac6a9640f6d0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:39:11 +0100 Subject: [PATCH 036/378] Add missing methods --- components/BalboaGL/ESPBalboaGL.cpp | 495 ++++++++++++++++++++++++++++ components/BalboaGL/ESPBalboaGL.h | 6 +- 2 files changed, 500 insertions(+), 1 deletion(-) create mode 100644 components/BalboaGL/ESPBalboaGL.cpp diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp new file mode 100644 index 0000000..e241dfa --- /dev/null +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -0,0 +1,495 @@ +#include "ESPBalboaGL.h" +using namespace esphome; + +/** + * Create a new BalboaGL object + * + * Args: + * hw_serial: pointer to an Arduino HardwareSerial instance + * poll_interval: polling interval in milliseconds + */ +BalboaGL::BalboaGL( + HardwareSerial* hw_serial +) : + PollingComponent{poll_interval}, // member initializers list + hw_serial_{hw_serial} +{ + this->traits_.set_supports_action(true); + this->traits_.set_supports_current_temperature(true); + this->traits_.set_supports_two_point_target_temperature(false); + this->traits_.set_visual_min_temperature(ESPMHP_MIN_TEMPERATURE); + this->traits_.set_visual_max_temperature(ESPMHP_MAX_TEMPERATURE); + this->traits_.set_visual_temperature_step(ESPMHP_TEMPERATURE_STEP); +} + +// void BalboaGL::check_logger_conflict_() { +// #ifdef USE_LOGGER +// if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) { +// ESP_LOGW(TAG, " You're using the same serial port for logging" +// " and the BalboaGL component. Please disable" +// " logging over the serial port by setting" +// " logger:baud_rate to 0."); +// } +// #endif +// } + +// void BalboaGL::update() { +// // This will be called every "update_interval" milliseconds. +// //this->dump_config(); +// this->hp->sync(); +// #ifndef USE_CALLBACKS +// this->hpSettingsChanged(); +// heatpumpStatus currentStatus = hp->getStatus(); +// this->hpStatusChanged(currentStatus); +// #endif +// } + +// void BalboaGL::set_baud_rate(int baud) { +// this->baud_ = baud; +// } + +// /** +// * Get our supported traits. +// * +// * Note: +// * Many of the following traits are only available in the 1.5.0 dev train of +// * ESPHome, particularly the Dry operation mode, and several of the fan modes. +// * +// * Returns: +// * This class' supported climate::ClimateTraits. +// */ +// climate::ClimateTraits BalboaGL::traits() { +// return traits_; +// } + +// /** +// * Modify our supported traits. +// * +// * Returns: +// * A reference to this class' supported climate::ClimateTraits. +// */ +climate::ClimateTraits& BalboaGL::config_traits() { + return traits_; +} + +// /** +// * Implement control of a BalboaGL. +// * +// * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. +// */ +// void BalboaGL::control(const climate::ClimateCall &call) { +// ESP_LOGV(TAG, "Control called."); + +// bool updated = false; +// bool has_mode = call.get_mode().has_value(); +// bool has_temp = call.get_target_temperature().has_value(); +// if (has_mode){ +// this->mode = *call.get_mode(); +// } +// switch (this->mode) { +// case climate::CLIMATE_MODE_COOL: +// hp->setModeSetting("COOL"); +// hp->setPowerSetting("ON"); + +// if (has_mode){ +// if (cool_setpoint.has_value() && !has_temp) { +// hp->setTemperature(cool_setpoint.value()); +// this->target_temperature = cool_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_HEAT: +// hp->setModeSetting("HEAT"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// if (heat_setpoint.has_value() && !has_temp) { +// hp->setTemperature(heat_setpoint.value()); +// this->target_temperature = heat_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_DRY: +// hp->setModeSetting("DRY"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// this->action = climate::CLIMATE_ACTION_DRYING; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_HEAT_COOL: +// hp->setModeSetting("AUTO"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// if (auto_setpoint.has_value() && !has_temp) { +// hp->setTemperature(auto_setpoint.value()); +// this->target_temperature = auto_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// updated = true; +// break; +// case climate::CLIMATE_MODE_FAN_ONLY: +// hp->setModeSetting("FAN"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// this->action = climate::CLIMATE_ACTION_FAN; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_OFF: +// default: +// if (has_mode){ +// hp->setPowerSetting("OFF"); +// this->action = climate::CLIMATE_ACTION_OFF; +// updated = true; +// } +// break; +// } + +// if (has_temp){ +// ESP_LOGV( +// "control", "Sending target temp: %.1f", +// *call.get_target_temperature() +// ); +// hp->setTemperature(*call.get_target_temperature()); +// this->target_temperature = *call.get_target_temperature(); +// updated = true; +// } + +// //const char* FAN_MAP[6] = {"AUTO", "QUIET", "1", "2", "3", "4"}; +// if (call.get_fan_mode().has_value()) { +// ESP_LOGV("control", "Requested fan mode is %s", *call.get_fan_mode()); +// this->fan_mode = *call.get_fan_mode(); +// switch(*call.get_fan_mode()) { +// case climate::CLIMATE_FAN_OFF: +// hp->setPowerSetting("OFF"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_DIFFUSE: +// hp->setFanSpeed("QUIET"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_LOW: +// hp->setFanSpeed("1"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_MEDIUM: +// hp->setFanSpeed("2"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_MIDDLE: +// hp->setFanSpeed("3"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_HIGH: +// hp->setFanSpeed("4"); +// updated = true; +// break; +// case climate::CLIMATE_FAN_ON: +// case climate::CLIMATE_FAN_AUTO: +// default: +// hp->setFanSpeed("AUTO"); +// updated = true; +// break; +// } +// } + +// //const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; +// if (call.get_swing_mode().has_value()) { +// ESP_LOGV(TAG, "control - requested swing mode is %s", +// *call.get_swing_mode()); + +// this->swing_mode = *call.get_swing_mode(); +// switch(*call.get_swing_mode()) { +// case climate::CLIMATE_SWING_OFF: +// hp->setVaneSetting("AUTO"); +// updated = true; +// break; +// case climate::CLIMATE_SWING_VERTICAL: +// hp->setVaneSetting("SWING"); +// updated = true; +// break; +// default: +// ESP_LOGW(TAG, "control - received unsupported swing mode request."); + +// } +// } +// ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); + +// // send the update back to esphome: +// this->publish_state(); +// // and the heat pump: +// hp->update(); +// } + +// void BalboaGL::hpSettingsChanged() { +// heatpumpSettings currentSettings = hp->getSettings(); + +// if (currentSettings.power == NULL) { +// /* +// * We should always get a valid pointer here once the HeatPump +// * component fully initializes. If HeatPump hasn't read the settings +// * from the unit yet (hp->connect() doesn't do this, sadly), we'll need +// * to punt on the update. Likely not an issue when run in callback +// * mode, but that isn't working right yet. +// */ +// ESP_LOGW(TAG, "Waiting for HeatPump to read the settings the first time."); +// esphome::delay(10); +// return; +// } + +// /* +// * ************ HANDLE POWER AND MODE CHANGES *********** +// * https://github.com/geoffdavis/HeatPump/blob/stream/src/HeatPump.h#L125 +// * const char* POWER_MAP[2] = {"OFF", "ON"}; +// * const char* MODE_MAP[5] = {"HEAT", "DRY", "COOL", "FAN", "AUTO"}; +// */ +// if (strcmp(currentSettings.power, "ON") == 0) { +// if (strcmp(currentSettings.mode, "HEAT") == 0) { +// this->mode = climate::CLIMATE_MODE_HEAT; +// if (heat_setpoint != currentSettings.temperature) { +// heat_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, heat_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else if (strcmp(currentSettings.mode, "DRY") == 0) { +// this->mode = climate::CLIMATE_MODE_DRY; +// this->action = climate::CLIMATE_ACTION_DRYING; +// } else if (strcmp(currentSettings.mode, "COOL") == 0) { +// this->mode = climate::CLIMATE_MODE_COOL; +// if (cool_setpoint != currentSettings.temperature) { +// cool_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, cool_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else if (strcmp(currentSettings.mode, "FAN") == 0) { +// this->mode = climate::CLIMATE_MODE_FAN_ONLY; +// this->action = climate::CLIMATE_ACTION_FAN; +// } else if (strcmp(currentSettings.mode, "AUTO") == 0) { +// this->mode = climate::CLIMATE_MODE_HEAT_COOL; +// if (auto_setpoint != currentSettings.temperature) { +// auto_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, auto_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else { +// ESP_LOGW( +// TAG, +// "Unknown climate mode value %s received from HeatPump", +// currentSettings.mode +// ); +// } +// } else { +// this->mode = climate::CLIMATE_MODE_OFF; +// this->action = climate::CLIMATE_ACTION_OFF; +// } + +// ESP_LOGI(TAG, "Climate mode is: %i", this->mode); + +// /* +// * ******* HANDLE FAN CHANGES ******** +// * +// * const char* FAN_MAP[6] = {"AUTO", "QUIET", "1", "2", "3", "4"}; +// */ +// if (strcmp(currentSettings.fan, "QUIET") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_DIFFUSE; +// } else if (strcmp(currentSettings.fan, "1") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_LOW; +// } else if (strcmp(currentSettings.fan, "2") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_MEDIUM; +// } else if (strcmp(currentSettings.fan, "3") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_MIDDLE; +// } else if (strcmp(currentSettings.fan, "4") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_HIGH; +// } else { //case "AUTO" or default: +// this->fan_mode = climate::CLIMATE_FAN_AUTO; +// } +// ESP_LOGI(TAG, "Fan mode is: %i", this->fan_mode); + +// /* ******** HANDLE MITSUBISHI VANE CHANGES ******** +// * const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; +// */ +// if (strcmp(currentSettings.vane, "SWING") == 0) { +// this->swing_mode = climate::CLIMATE_SWING_VERTICAL; +// } +// else { +// this->swing_mode = climate::CLIMATE_SWING_OFF; +// } +// ESP_LOGI(TAG, "Swing mode is: %i", this->swing_mode); + + + +// /* +// * ******** HANDLE TARGET TEMPERATURE CHANGES ******** +// */ +// this->target_temperature = currentSettings.temperature; +// ESP_LOGI(TAG, "Target temp is: %f", this->target_temperature); + +// /* +// * ******** Publish state back to ESPHome. ******** +// */ +// this->publish_state(); +// } + +// /** +// * Report changes in the current temperature sensed by the HeatPump. +// */ +// void BalboaGL::hpStatusChanged(heatpumpStatus currentStatus) { +// this->current_temperature = currentStatus.roomTemperature; +// switch (this->mode) { +// case climate::CLIMATE_MODE_HEAT: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_HEATING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_COOL: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_COOLING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_HEAT_COOL: +// this->action = climate::CLIMATE_ACTION_IDLE; +// if (currentStatus.operating) { +// if (this->current_temperature > this->target_temperature) { +// this->action = climate::CLIMATE_ACTION_COOLING; +// } else if (this->current_temperature < this->target_temperature) { +// this->action = climate::CLIMATE_ACTION_HEATING; +// } +// } +// break; +// case climate::CLIMATE_MODE_DRY: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_DRYING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_FAN_ONLY: +// this->action = climate::CLIMATE_ACTION_FAN; +// break; +// default: +// this->action = climate::CLIMATE_ACTION_OFF; +// } + +// this->publish_state(); +// } + +// void BalboaGL::set_remote_temperature(float temp) { +// ESP_LOGD(TAG, "Setting remote temp: %.1f", temp); +// this->hp->setRemoteTemperature(temp); +// } + +// void BalboaGL::setup() { +// // This will be called by App.setup() +// this->banner(); +// ESP_LOGCONFIG(TAG, "Setting up UART..."); +// if (!this->get_hw_serial_()) { +// ESP_LOGCONFIG( +// TAG, +// "No HardwareSerial was provided. " +// "Software serial ports are unsupported by this component." +// ); +// this->mark_failed(); +// return; +// } +// this->check_logger_conflict_(); + +// ESP_LOGCONFIG(TAG, "Intializing new HeatPump object."); +// this->hp = new HeatPump(); +// this->current_temperature = NAN; +// this->target_temperature = NAN; +// this->fan_mode = climate::CLIMATE_FAN_OFF; +// this->swing_mode = climate::CLIMATE_SWING_OFF; + +// #ifdef USE_CALLBACKS +// hp->setSettingsChangedCallback( +// [this]() { +// this->hpSettingsChanged(); +// } +// ); + +// hp->setStatusChangedCallback( +// [this](heatpumpStatus currentStatus) { +// this->hpStatusChanged(currentStatus); +// } +// ); +// #endif + +// ESP_LOGCONFIG( +// TAG, +// "hw_serial(%p) is &Serial(%p)? %s", +// this->get_hw_serial_(), +// &Serial, +// YESNO(this->get_hw_serial_() == &Serial) +// ); + +// ESP_LOGCONFIG(TAG, "Calling hp->connect(%p)", this->get_hw_serial_()); + +// if (hp->connect(this->get_hw_serial_(), this->baud_, -1, -1)) { +// hp->sync(); +// } +// else { +// ESP_LOGCONFIG( +// TAG, +// "Connection to HeatPump failed." +// " Marking BalboaGL component as failed." +// ); +// this->mark_failed(); +// } + +// // create various setpoint persistence: +// cool_storage = global_preferences->make_preference(this->get_object_id_hash() + 1); +// heat_storage = global_preferences->make_preference(this->get_object_id_hash() + 2); +// auto_storage = global_preferences->make_preference(this->get_object_id_hash() + 3); + +// // load values from storage: +// cool_setpoint = load(cool_storage); +// heat_setpoint = load(heat_storage); +// auto_setpoint = load(auto_storage); + +// this->dump_config(); +// } + +// /** +// * The ESP only has a few bytes of rtc storage, so instead +// * of storing floats directly, we'll store the number of +// * TEMPERATURE_STEPs from MIN_TEMPERATURE. +// **/ +// void BalboaGL::save(float value, ESPPreferenceObject& storage) { +// uint8_t steps = (value - ESPMHP_MIN_TEMPERATURE) / ESPMHP_TEMPERATURE_STEP; +// storage.save(&steps); +// } + +// optional BalboaGL::load(ESPPreferenceObject& storage) { +// uint8_t steps = 0; +// if (!storage.load(&steps)) { +// return {}; +// } +// return ESPMHP_MIN_TEMPERATURE + (steps * ESPMHP_TEMPERATURE_STEP); +// } + +// void BalboaGL::dump_config() { +// this->banner(); +// ESP_LOGI(TAG, " Supports HEAT: %s", YESNO(true)); +// ESP_LOGI(TAG, " Supports COOL: %s", YESNO(true)); +// ESP_LOGI(TAG, " Supports AWAY mode: %s", YESNO(false)); +// ESP_LOGI(TAG, " Saved heat: %.1f", heat_setpoint.value_or(-1)); +// ESP_LOGI(TAG, " Saved cool: %.1f", cool_setpoint.value_or(-1)); +// ESP_LOGI(TAG, " Saved auto: %.1f", auto_setpoint.value_or(-1)); +// } + +// void BalboaGL::dump_state() { +// LOG_CLIMATE("", "BalboaGL Climate", this); +// ESP_LOGI(TAG, "HELLO"); +// } \ No newline at end of file diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index da33bdb..5d10053 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -42,7 +42,11 @@ class BalboaGL : public Component, public climate::Climate { // Get a mutable reference to the traits that we support. climate::ClimateTraits& config_traits(); - + + protected: + // The ClimateTraits supported by this HeatPump. + climate::ClimateTraits traits_; + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From 47b0b6a31e1d456159baea3f80e61a87cb41f526 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:42:12 +0100 Subject: [PATCH 037/378] Add missing methods --- components/BalboaGL/ESPBalboaGL.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 5d10053..0d49645 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -2,6 +2,10 @@ #include "esphome/core/preferences.h" #include "esphome/components/climate/climate.h" + +#ifndef ESPMHP_H +#define ESPMHP_H + #include "constants.h" @@ -51,3 +55,4 @@ class BalboaGL : public Component, public climate::Climate { // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; }; +#endif \ No newline at end of file From 83cc2d6c72b820960b52daa1c48112f772837bc0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:43:55 +0100 Subject: [PATCH 038/378] Set temp range --- components/BalboaGL/ESPBalboaGL.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index e241dfa..11fa66f 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -17,9 +17,9 @@ BalboaGL::BalboaGL( this->traits_.set_supports_action(true); this->traits_.set_supports_current_temperature(true); this->traits_.set_supports_two_point_target_temperature(false); - this->traits_.set_visual_min_temperature(ESPMHP_MIN_TEMPERATURE); - this->traits_.set_visual_max_temperature(ESPMHP_MAX_TEMPERATURE); - this->traits_.set_visual_temperature_step(ESPMHP_TEMPERATURE_STEP); + this->traits_.set_visual_min_temperature(26); + this->traits_.set_visual_max_temperature(40); + this->traits_.set_visual_temperature_step(0.5); } // void BalboaGL::check_logger_conflict_() { @@ -58,9 +58,9 @@ BalboaGL::BalboaGL( // * Returns: // * This class' supported climate::ClimateTraits. // */ -// climate::ClimateTraits BalboaGL::traits() { -// return traits_; -// } +climate::ClimateTraits BalboaGL::traits() { + return traits_; +} // /** // * Modify our supported traits. From 6360f3361bfc6d9bb4d54c46276c6115fd683efc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:45:15 +0100 Subject: [PATCH 039/378] Polling --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 0d49645..8bee333 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -34,7 +34,7 @@ const int MINUTES_PER_DEGC = 45; using namespace esphome; -class BalboaGL : public Component, public climate::Climate { +class BalboaGL : public PollingComponent, public climate::Climate { public: BalboaGL( HardwareSerial* hw_serial From dd3bca623bf83fbcba6865e6439d9fe6a83de7e3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:48:23 +0100 Subject: [PATCH 040/378] Polling --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- components/BalboaGL/ESPBalboaGL.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 11fa66f..df72037 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -9,7 +9,8 @@ using namespace esphome; * poll_interval: polling interval in milliseconds */ BalboaGL::BalboaGL( - HardwareSerial* hw_serial + HardwareSerial* hw_serial, + uint32_t poll_interval ) : PollingComponent{poll_interval}, // member initializers list hw_serial_{hw_serial} diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 8bee333..8a55d7c 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -21,6 +21,7 @@ const float POWER_PUMP2_HIGH = 0.6; // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc const int MINUTES_PER_DEGC = 45; +const uint32_t POLL_INTERVAL_DEFAULT = 10000; #define tub Serial2 #define RX_PIN 19 @@ -38,7 +39,7 @@ class BalboaGL : public PollingComponent, public climate::Climate { public: BalboaGL( HardwareSerial* hw_serial - // uint32_t poll_interval=0 + uint32_t poll_interval=POLL_INTERVAL_DEFAULT ); // Configure the climate object with traits that we support. From f6decea16b089476b84cbb2cb1dbee9b1c5d14cf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:49:16 +0100 Subject: [PATCH 041/378] Polling --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 8a55d7c..ed8bcda 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -38,7 +38,7 @@ using namespace esphome; class BalboaGL : public PollingComponent, public climate::Climate { public: BalboaGL( - HardwareSerial* hw_serial + HardwareSerial* hw_serial, uint32_t poll_interval=POLL_INTERVAL_DEFAULT ); From b471f913e1988b5abb48ddee620aad7f10d1df1c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:50:25 +0100 Subject: [PATCH 042/378] Polling --- components/BalboaGL/ESPBalboaGL.cpp | 12 ++++++++++++ components/BalboaGL/ESPBalboaGL.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index df72037..e5ec524 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -22,6 +22,18 @@ BalboaGL::BalboaGL( this->traits_.set_visual_max_temperature(40); this->traits_.set_visual_temperature_step(0.5); } +BalboaGL::BalboaGL( + HardwareSerial* hw_serial +) : + hw_serial_{hw_serial} +{ + this->traits_.set_supports_action(true); + this->traits_.set_supports_current_temperature(true); + this->traits_.set_supports_two_point_target_temperature(false); + this->traits_.set_visual_min_temperature(26); + this->traits_.set_visual_max_temperature(40); + this->traits_.set_visual_temperature_step(0.5); +} // void BalboaGL::check_logger_conflict_() { // #ifdef USE_LOGGER diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index ed8bcda..8b6ed4b 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -41,6 +41,9 @@ class BalboaGL : public PollingComponent, public climate::Climate { HardwareSerial* hw_serial, uint32_t poll_interval=POLL_INTERVAL_DEFAULT ); + BalboaGL( + HardwareSerial* hw_serial + ); // Configure the climate object with traits that we support. climate::ClimateTraits traits() override; From bb27aaf29fa9db00b76513533cd732ecd3ab4e85 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:54:09 +0100 Subject: [PATCH 043/378] update and control --- components/BalboaGL/ESPBalboaGL.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index e5ec524..07c3d11 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -46,7 +46,7 @@ BalboaGL::BalboaGL( // #endif // } -// void BalboaGL::update() { +void BalboaGL::update() { // // This will be called every "update_interval" milliseconds. // //this->dump_config(); // this->hp->sync(); @@ -55,7 +55,7 @@ BalboaGL::BalboaGL( // heatpumpStatus currentStatus = hp->getStatus(); // this->hpStatusChanged(currentStatus); // #endif -// } +} // void BalboaGL::set_baud_rate(int baud) { // this->baud_ = baud; @@ -90,8 +90,8 @@ climate::ClimateTraits& BalboaGL::config_traits() { // * // * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. // */ -// void BalboaGL::control(const climate::ClimateCall &call) { -// ESP_LOGV(TAG, "Control called."); +void BalboaGL::control(const climate::ClimateCall &call) { + ESP_LOGV(TAG, "Control called."); // bool updated = false; // bool has_mode = call.get_mode().has_value(); @@ -237,7 +237,7 @@ climate::ClimateTraits& BalboaGL::config_traits() { // this->publish_state(); // // and the heat pump: // hp->update(); -// } +} // void BalboaGL::hpSettingsChanged() { // heatpumpSettings currentSettings = hp->getSettings(); From 73d76fa4b952baab8cd5b2c331de002470202981 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:57:01 +0100 Subject: [PATCH 044/378] update and control --- components/BalboaGL/ESPBalboaGL.h | 33 +++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 8b6ed4b..ee95112 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -45,12 +45,41 @@ class BalboaGL : public PollingComponent, public climate::Climate { HardwareSerial* hw_serial ); - // Configure the climate object with traits that we support. + // // Set the baud rate. Must be called before setup() to have any effect. + // void set_baud_rate(int); + + // // print the current configuration + // void dump_config() override; + + // // handle a change in settings as detected by the HeatPump library. + // void hpSettingsChanged(); + + // // Handle a change in status as detected by the HeatPump library. + // void hpStatusChanged(heatpumpStatus currentStatus); + + // // Set up the component, initializing the HeatPump object. + // void setup() override; + + // // This is called every poll_interval. + void update() override; + + // // Configure the climate object with traits that we support. climate::ClimateTraits traits() override; - // Get a mutable reference to the traits that we support. + // // Get a mutable reference to the traits that we support. climate::ClimateTraits& config_traits(); + // Debugging function to print the object's state. + // void dump_state(); + + // Handle a request from the user to change settings. + void control(const climate::ClimateCall &call) override; + + // // Use the temperature from an external sensor. Use + // // set_remote_temp(0) to switch back to the internal sensor. + // void set_remote_temperature(float); + + protected: // The ClimateTraits supported by this HeatPump. climate::ClimateTraits traits_; From 0867caaa9b40a8e7dba788b8737e0967a2e500b2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 13:59:01 +0100 Subject: [PATCH 045/378] update and control --- components/BalboaGL/ESPBalboaGL.cpp | 28 ++++++++++++++-------------- components/BalboaGL/ESPBalboaGL.h | 8 ++++---- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 07c3d11..e9a88d2 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -8,20 +8,20 @@ using namespace esphome; * hw_serial: pointer to an Arduino HardwareSerial instance * poll_interval: polling interval in milliseconds */ -BalboaGL::BalboaGL( - HardwareSerial* hw_serial, - uint32_t poll_interval -) : - PollingComponent{poll_interval}, // member initializers list - hw_serial_{hw_serial} -{ - this->traits_.set_supports_action(true); - this->traits_.set_supports_current_temperature(true); - this->traits_.set_supports_two_point_target_temperature(false); - this->traits_.set_visual_min_temperature(26); - this->traits_.set_visual_max_temperature(40); - this->traits_.set_visual_temperature_step(0.5); -} +// BalboaGL::BalboaGL( +// HardwareSerial* hw_serial, +// uint32_t poll_interval +// ) : +// PollingComponent{poll_interval}, // member initializers list +// hw_serial_{hw_serial} +// { +// this->traits_.set_supports_action(true); +// this->traits_.set_supports_current_temperature(true); +// this->traits_.set_supports_two_point_target_temperature(false); +// this->traits_.set_visual_min_temperature(26); +// this->traits_.set_visual_max_temperature(40); +// this->traits_.set_visual_temperature_step(0.5); +// } BalboaGL::BalboaGL( HardwareSerial* hw_serial ) : diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index ee95112..1949bda 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -37,10 +37,10 @@ using namespace esphome; class BalboaGL : public PollingComponent, public climate::Climate { public: - BalboaGL( - HardwareSerial* hw_serial, - uint32_t poll_interval=POLL_INTERVAL_DEFAULT - ); + // BalboaGL( + // HardwareSerial* hw_serial, + // uint32_t poll_interval=POLL_INTERVAL_DEFAULT + // ); BalboaGL( HardwareSerial* hw_serial ); From adf6b9f8ac72e833db1e3adcac4271c0a72cacc9 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 18:45:24 +0100 Subject: [PATCH 046/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 18 ------------------ components/BalboaGL/ESPBalboaGL.h | 10 ++-------- 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index e9a88d2..dcc469f 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -8,20 +8,6 @@ using namespace esphome; * hw_serial: pointer to an Arduino HardwareSerial instance * poll_interval: polling interval in milliseconds */ -// BalboaGL::BalboaGL( -// HardwareSerial* hw_serial, -// uint32_t poll_interval -// ) : -// PollingComponent{poll_interval}, // member initializers list -// hw_serial_{hw_serial} -// { -// this->traits_.set_supports_action(true); -// this->traits_.set_supports_current_temperature(true); -// this->traits_.set_supports_two_point_target_temperature(false); -// this->traits_.set_visual_min_temperature(26); -// this->traits_.set_visual_max_temperature(40); -// this->traits_.set_visual_temperature_step(0.5); -// } BalboaGL::BalboaGL( HardwareSerial* hw_serial ) : @@ -57,10 +43,6 @@ void BalboaGL::update() { // #endif } -// void BalboaGL::set_baud_rate(int baud) { -// this->baud_ = baud; -// } - // /** // * Get our supported traits. // * diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 1949bda..1f0a232 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,6 +8,7 @@ #include "constants.h" +static const char* TAG = "BalboaGL"; // Logging tag // Perform measurements or read nameplate values on your tub to define the power [kW] // for each device in order to calculate tub power usage @@ -37,17 +38,10 @@ using namespace esphome; class BalboaGL : public PollingComponent, public climate::Climate { public: - // BalboaGL( - // HardwareSerial* hw_serial, - // uint32_t poll_interval=POLL_INTERVAL_DEFAULT - // ); - BalboaGL( + BalboaGL( HardwareSerial* hw_serial ); - // // Set the baud rate. Must be called before setup() to have any effect. - // void set_baud_rate(int); - // // print the current configuration // void dump_config() override; From ae45071a187e6279aa5d73707ed0ee8ca22e16fd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 18:53:52 +0100 Subject: [PATCH 047/378] Remove balboaGL.h --- sensor/src/balboaGL.h | 438 ------------------------------------------ 1 file changed, 438 deletions(-) delete mode 100644 sensor/src/balboaGL.h diff --git a/sensor/src/balboaGL.h b/sensor/src/balboaGL.h deleted file mode 100644 index 1ff3b97..0000000 --- a/sensor/src/balboaGL.h +++ /dev/null @@ -1,438 +0,0 @@ -#include - -int delayTime = 40; - -#include "constants.h" - -struct BalboaStatus { - float power; - String rawData; - String rawData2; // TODO: better name - String rawData3; // TODO: better name - String rawData7; // TODO: better name - float targetTemp; - float temp; - float timeToTemp; - int mode; - int pump1; - int pump2; - String time; - boolean heater; - boolean light; - String state; -} status; - - - - -ArduinoQueue sendBuffer(10); // TODO: might be better bigger for large temp changes. Would need testing - -void sendCommand(String command, int count) { - Serial.printf("Sending %s - %u times\n", command.c_str(), count); - for (int i = 0; i < count; i++) { - sendBuffer.enqueue(command.c_str()); - } -} - -void setOption(int currentIndex, int targetIndex, int options, String command = COMMAND_DOWN) { - if (targetIndex > currentIndex) { - sendCommand(command, (targetIndex - currentIndex)); - } else if (currentIndex != targetIndex) { - int presses = (options - currentIndex) + targetIndex; - sendCommand(command, presses); - } -} - - -String result = ""; -int msgLength = 0; - -void handleMessage(); -void sendCommand(); -String HexString2ASCIIString(String hexstring); -void hexCharacterStringToBytes(byte* byteArray, const char* hexString); -String HexString2TimeString(String hexstring); -void telnetSend(String message); - -void handleBytes(size_t len, uint8_t buf[]) { - - for (int i = 0; i < len; i++) { - if (buf[i] < 0x10) { - result += '0'; - } - result += String(buf[i], HEX); - } - if (msgLength == 0 && result.length() == 2) { - String messageType = result.substring(0, 2); - if (messageType == "fa") { - msgLength = 46; - } else if (messageType == "ae") { - msgLength = 32; - } else { - Serial.print("Unknown message length for "); - Serial.println(messageType); - } - } else if (result.length() == msgLength) { - if (result.length() == 46) { - sendCommand(); // send reply *before* we parse the FA string as we don't want to delay the reply by - // say sending MQTT updates - } - handleMessage(); - } -} - -void handleMessage() { - - // Set as static, so only allocating memory once, not per method call - as when was global - static int pump1State = 0; - static int pump2State = 0; - static boolean heaterState = false; - static boolean lightState = false; - static float tubpowerCalc = 0; - static double tubTemp = -1; - static double tubTargetTemp = -1; - static String state = "unknown"; - static String lastRaw = ""; - static String lastRaw2 = ""; - static String lastRaw3 = ""; - static String lastRaw4 = ""; - static String lastRaw5 = ""; - static String lastRaw6 = ""; - static String lastRaw7 = ""; - static String timeString = ""; - - // Serial.print("message = "); - // Serial.println(result); - - if (result.substring(0, 4) == "fa14") { - // Serial.println("FA 14"); - // telnetSend(result); - - // fa1433343043 = header + 340C = 34.0C - - // If messages is temp or ---- for temp, it is status message - if (result.substring(10, 12) == "43" || result.substring(10, 12) == "2d") { - tubpowerCalc = 0; - String pump = result.substring(13, 14); - - if (pump == "0") { // Pump 1 Off - Pump 2 Off - 0b0000 - pump1State = 0; - pump2State = 0; - } else if (pump == "1") { // Pump 1 Low - Pump 2 Off - 0b0001 - pump1State = 1; - pump2State = 0; - tubpowerCalc += POWER_PUMP1_LOW; - } else if (pump == "2") { // Pump 1 High - Pump 2 Off - 0b0010 - pump1State = PUMP1_STATE_HIGH; - pump2State = 0; - tubpowerCalc += POWER_PUMP1_HIGH; - } else if (pump == "4") { // Pump 1 Off - Pump 2 Low - 0b0100 - pump1State = 0; - pump2State = 1; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "5") { // Pump 1 Low - Pump 2 Low - 0b0101 - pump1State = 1; - pump2State = 1; - tubpowerCalc += POWER_PUMP1_LOW; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "6") { // Pump 1 High - Pump 2 Low - 0b0110 - pump1State = PUMP1_STATE_HIGH; - pump2State = 1; - tubpowerCalc += POWER_PUMP1_HIGH; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "8") { // Pump 1 Off - Pump 2 High - 0b1000 - pump1State = 0; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP2_HIGH; - } else if (pump == "9") { // Pump 1 Low - Pump 2 High - 0b1001 - pump1State = 1; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP1_LOW; - tubpowerCalc += POWER_PUMP2_HIGH; - } else if (pump == "a") { // Pump 1 High - Pump 2 HIGH = 0b1010 - pump1State = PUMP1_STATE_HIGH; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP1_HIGH; - tubpowerCalc += POWER_PUMP2_HIGH; - } - - String heater = result.substring(14, 15); - if (heater == "0") { - heaterState = false; - } else if (heater == "1") { - heaterState = true; - tubpowerCalc += POWER_HEATER; - } else if (heater == "2") { - heaterState = true; // heater off, verifying temp change, but creates noisy state if we return false - tubpowerCalc += POWER_HEATER; - } - - status.power = tubpowerCalc; - - String light = result.substring(15, 16); - if (light == "0") { - lightState = false; - } else if (light == "3") { - lightState = true; - } - - // Ignore last 2 bytes as possibly checksum, given we have temp earlier making look more complex than - // perhaps it is - String newRaw = result.substring(17, 44); - if (lastRaw != newRaw) { - lastRaw = newRaw; - status.rawData = lastRaw.c_str(); - - String s = result.substring(17, 18); - if (s == "4") { - state = "Sleep"; - status.mode = MODE_IDX_SLP; - } else if (s == "9") { - state = "Circulation ?"; - status.mode = MODE_IDX_STD; // TODO: confirm - } else if (s == "1") { - state = "Standard"; - status.mode = MODE_IDX_STD; - } else if (s == "2") { - state = "Economy"; - status.mode = MODE_IDX_ECO; - } else if (s == "a") { - state = "Cleaning"; // TODO: can't tell our actual mode here - could be any of the 3 I think - } else if (s == "c") { - state = "Circulation in sleep?"; - status.mode = MODE_IDX_SLP; - } else if (s == "b" || s == "3") { - state = "Std in Eco"; // Was in eco, Swap to STD for 1 hour only - status.mode = MODE_IDX_STD; - } else { - state = "Unknown " + s; - } - - String menu = result.substring(18, 20); - if (menu == "00") { - // idle - } else if (menu == "4c") { - state = "Set Mode"; - } else if (menu == "5a") { - state = "Standby?"; // WT: not tested to confirm if this is the act of setting Standby or just seen - // when in standby - } else { // 46 for set temp, but also other things like filter time - state = "menu " + menu; - } - - // 94600008002ffffff0200000000f5 - - if (result.substring(28, 32) != "ffff") { - timeString = HexString2TimeString(result.substring(28, 32)); - } else { - timeString = "--:--"; - } - status.time = timeString.c_str(); - - // temp up - ff0100000000?? - end varies - - // temp down - ff0200000000?? - end varies - - String cmd = result.substring(34, 44); - if (cmd == "0000000000") { - // none - } else if (cmd.substring(0, 4) == "01") { - state = "Temp Up"; - } else if (cmd.substring(0, 4) == "02") { - state = "Temp Down"; - } else { - telnetSend("CMD: " + cmd); - } - if (!lastRaw3.equals(cmd)) { - // Controller responded to command - sendBuffer.dequeue(); - Serial.printf("YAY: command response : %u\n", delayTime); - } - - if (!lastRaw3.equals(cmd) && cmd != "0000000000") { // ignore idle command - lastRaw3 = cmd; - status.rawData3 = lastRaw3.c_str(); - } - - if (result.substring(10, 12) == "43") { // "C" - double tmp = (HexString2ASCIIString(result.substring(4, 10)).toDouble() / 10); - if (menu == "46") { - tubTargetTemp = tmp; - status.targetTemp = (float)tubTargetTemp; - Serial.printf("Sent target temp data %f\n", tubTargetTemp); - } else { - if (tubTemp != tmp) { - tubTemp = tmp; - status.temp = (float)tubTemp; - Serial.printf("Sent temp data %f\n", tubTemp); - } - if (heaterState && (tubTemp < tubTargetTemp)) { - double tempDiff = (tubTargetTemp - tubTemp); - float timeToTempValue = (tempDiff * MINUTES_PER_DEGC); - status.timeToTemp = timeToTempValue; - } else { - status.timeToTemp = 0; - } - } - } else if (result.substring(10, 12) == "2d") { // "-" - // Serial.println("temp = unknown"); - // telnetSend("temp = unknown"); - } else { - Serial.println("non-temp " + result); - telnetSend("non-temp " + result); - } - - status.state = state.c_str(); - } - } else { - // FA but not temp data - lastRaw2 = result.substring(4, 28); - status.rawData2 = lastRaw2.c_str(); - } - - if (result.length() >= 64) { // "Long" messages only - String tail = result.substring(46, 64); - if (tail != lastRaw7) { - lastRaw7 = tail; - status.rawData7 = lastRaw7.c_str(); - } - } - - status.pump1 = pump1State; - status.pump2 = pump2State; - status.heater = heaterState; - status.light = lightState; - - // end of FA14 - } else if (result.substring(0, 4) == "ae0d") { - // Serial.println("AE 0D"); - // telnetSend(result); - - String message = result.substring(0, 32); // ignore any FB ending - - if (result.substring(0, 6) == "ae0d01" && message != "ae0d010000000000000000000000005a") { - if (!lastRaw4.equals(message)) { - lastRaw4 = message; - // status.rawData4 = lastRaw4.c_str(); - } - } else if (result.substring(0, 6) == "ae0d02" && message != "ae0d02000000000000000000000000c3") { - if (!lastRaw5.equals(message)) { - lastRaw5 = message; - // status.rawData5 = lastRaw5.c_str(); - } - } else if (result.substring(0, 6) == "ae0d03" && message != "ae0d03000000000000000000000000b4") { - if (!lastRaw6.equals(message)) { - lastRaw6 = message; - // status.rawData6 = lastRaw6.c_str(); - } - } - // end of AE 0D - } else { - Serial.printf("Unknown message (%u): ", result.length()); - Serial.println(result); - telnetSend("U: " + result); - } -} - -void sendCommand() { - if (!sendBuffer.isEmpty()) { - digitalWrite(RTS_PIN, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - - delayMicroseconds(delayTime); - // Serial.println("Sending " + sendBuffer); - byte byteArray[18] = {0}; - hexCharacterStringToBytes(byteArray, sendBuffer.getHead().c_str()); - // if(digitalRead(PIN_5_PIN) != LOW) { - // Serial.println("ERROR: Pin5 went high before command before write"); - // } - tub.write(byteArray, sizeof(byteArray)); - if (digitalRead(PIN_5_PIN) != LOW) { - Serial.printf("ERROR: Pin5 went high before command before flush : %u\n", delayTime); - delayTime = 0; - sendBuffer.dequeue(); - } - // tub.flush(true); - if (digitalRead(PIN_5_PIN) == LOW) { - // sendBuffer.dequeue(); // TODO: trying to resend now till we see response - Serial.printf("message sent : %u\n", delayTime); - // delayTime += 10; - } - // else { - // Serial.println("ERROR: Pin5 went high before command could be sent after flush"); - // } - digitalWrite(RTS_PIN, LOW); - digitalWrite(LED_BUILTIN, LOW); - } -} - -String HexString2TimeString(String hexstring) { - // Convert "HHMM" in HEX to "HH:MM" with decimal representation - String time = ""; - int hour = strtol(hexstring.substring(0, 2).c_str(), NULL, 16); - int minute = strtol(hexstring.substring(2, 4).c_str(), NULL, 16); - - if (hour < 10) time.concat("0"); // Add leading zero - time.concat(hour); - time.concat(":"); - if (minute < 10) time.concat("0"); // Add leading zero - time.concat(minute); - - return time; -} - -String HexString2ASCIIString(String hexstring) { - String temp = "", sub = "", result; - char buf[3]; - for (int i = 0; i < hexstring.length(); i += 2) { - sub = hexstring.substring(i, i + 2); - sub.toCharArray(buf, 3); - char b = (char)strtol(buf, 0, 16); - if (b == '\0') break; - temp += b; - } - return temp; -} - -byte nibble(char c) { - if (c >= '0' && c <= '9') return c - '0'; - if (c >= 'a' && c <= 'f') return c - 'a' + 10; - if (c >= 'A' && c <= 'F') return c - 'A' + 10; - return 0; // Not a valid hexadecimal character -} - -void hexCharacterStringToBytes(byte* byteArray, const char* hexString) { - bool oddLength = strlen(hexString) & 1; - - byte currentByte = 0; - byte byteIndex = 0; - - for (byte charIndex = 0; charIndex < strlen(hexString); charIndex++) { - bool oddCharIndex = charIndex & 1; - - if (oddLength) { - // If the length is odd - if (oddCharIndex) { - // odd characters go in high nibble - currentByte = nibble(hexString[charIndex]) << 4; - } else { - // Even characters go into low nibble - currentByte |= nibble(hexString[charIndex]); - byteArray[byteIndex++] = currentByte; - currentByte = 0; - } - } else { - // If the length is even - if (!oddCharIndex) { - // Odd characters go into the high nibble - currentByte = nibble(hexString[charIndex]) << 4; - } else { - // Odd characters go into low nibble - currentByte |= nibble(hexString[charIndex]); - byteArray[byteIndex++] = currentByte; - currentByte = 0; - } - } - } -} - From 82195e67a615dbd520ae70911827801ba743686b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 19:04:35 +0100 Subject: [PATCH 048/378] Revert "Remove balboaGL.h" This reverts commit ae45071a187e6279aa5d73707ed0ee8ca22e16fd. --- sensor/src/balboaGL.h | 438 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 438 insertions(+) create mode 100644 sensor/src/balboaGL.h diff --git a/sensor/src/balboaGL.h b/sensor/src/balboaGL.h new file mode 100644 index 0000000..1ff3b97 --- /dev/null +++ b/sensor/src/balboaGL.h @@ -0,0 +1,438 @@ +#include + +int delayTime = 40; + +#include "constants.h" + +struct BalboaStatus { + float power; + String rawData; + String rawData2; // TODO: better name + String rawData3; // TODO: better name + String rawData7; // TODO: better name + float targetTemp; + float temp; + float timeToTemp; + int mode; + int pump1; + int pump2; + String time; + boolean heater; + boolean light; + String state; +} status; + + + + +ArduinoQueue sendBuffer(10); // TODO: might be better bigger for large temp changes. Would need testing + +void sendCommand(String command, int count) { + Serial.printf("Sending %s - %u times\n", command.c_str(), count); + for (int i = 0; i < count; i++) { + sendBuffer.enqueue(command.c_str()); + } +} + +void setOption(int currentIndex, int targetIndex, int options, String command = COMMAND_DOWN) { + if (targetIndex > currentIndex) { + sendCommand(command, (targetIndex - currentIndex)); + } else if (currentIndex != targetIndex) { + int presses = (options - currentIndex) + targetIndex; + sendCommand(command, presses); + } +} + + +String result = ""; +int msgLength = 0; + +void handleMessage(); +void sendCommand(); +String HexString2ASCIIString(String hexstring); +void hexCharacterStringToBytes(byte* byteArray, const char* hexString); +String HexString2TimeString(String hexstring); +void telnetSend(String message); + +void handleBytes(size_t len, uint8_t buf[]) { + + for (int i = 0; i < len; i++) { + if (buf[i] < 0x10) { + result += '0'; + } + result += String(buf[i], HEX); + } + if (msgLength == 0 && result.length() == 2) { + String messageType = result.substring(0, 2); + if (messageType == "fa") { + msgLength = 46; + } else if (messageType == "ae") { + msgLength = 32; + } else { + Serial.print("Unknown message length for "); + Serial.println(messageType); + } + } else if (result.length() == msgLength) { + if (result.length() == 46) { + sendCommand(); // send reply *before* we parse the FA string as we don't want to delay the reply by + // say sending MQTT updates + } + handleMessage(); + } +} + +void handleMessage() { + + // Set as static, so only allocating memory once, not per method call - as when was global + static int pump1State = 0; + static int pump2State = 0; + static boolean heaterState = false; + static boolean lightState = false; + static float tubpowerCalc = 0; + static double tubTemp = -1; + static double tubTargetTemp = -1; + static String state = "unknown"; + static String lastRaw = ""; + static String lastRaw2 = ""; + static String lastRaw3 = ""; + static String lastRaw4 = ""; + static String lastRaw5 = ""; + static String lastRaw6 = ""; + static String lastRaw7 = ""; + static String timeString = ""; + + // Serial.print("message = "); + // Serial.println(result); + + if (result.substring(0, 4) == "fa14") { + // Serial.println("FA 14"); + // telnetSend(result); + + // fa1433343043 = header + 340C = 34.0C + + // If messages is temp or ---- for temp, it is status message + if (result.substring(10, 12) == "43" || result.substring(10, 12) == "2d") { + tubpowerCalc = 0; + String pump = result.substring(13, 14); + + if (pump == "0") { // Pump 1 Off - Pump 2 Off - 0b0000 + pump1State = 0; + pump2State = 0; + } else if (pump == "1") { // Pump 1 Low - Pump 2 Off - 0b0001 + pump1State = 1; + pump2State = 0; + tubpowerCalc += POWER_PUMP1_LOW; + } else if (pump == "2") { // Pump 1 High - Pump 2 Off - 0b0010 + pump1State = PUMP1_STATE_HIGH; + pump2State = 0; + tubpowerCalc += POWER_PUMP1_HIGH; + } else if (pump == "4") { // Pump 1 Off - Pump 2 Low - 0b0100 + pump1State = 0; + pump2State = 1; + tubpowerCalc += POWER_PUMP2_LOW; + } else if (pump == "5") { // Pump 1 Low - Pump 2 Low - 0b0101 + pump1State = 1; + pump2State = 1; + tubpowerCalc += POWER_PUMP1_LOW; + tubpowerCalc += POWER_PUMP2_LOW; + } else if (pump == "6") { // Pump 1 High - Pump 2 Low - 0b0110 + pump1State = PUMP1_STATE_HIGH; + pump2State = 1; + tubpowerCalc += POWER_PUMP1_HIGH; + tubpowerCalc += POWER_PUMP2_LOW; + } else if (pump == "8") { // Pump 1 Off - Pump 2 High - 0b1000 + pump1State = 0; + pump2State = PUMP2_STATE_HIGH; + tubpowerCalc += POWER_PUMP2_HIGH; + } else if (pump == "9") { // Pump 1 Low - Pump 2 High - 0b1001 + pump1State = 1; + pump2State = PUMP2_STATE_HIGH; + tubpowerCalc += POWER_PUMP1_LOW; + tubpowerCalc += POWER_PUMP2_HIGH; + } else if (pump == "a") { // Pump 1 High - Pump 2 HIGH = 0b1010 + pump1State = PUMP1_STATE_HIGH; + pump2State = PUMP2_STATE_HIGH; + tubpowerCalc += POWER_PUMP1_HIGH; + tubpowerCalc += POWER_PUMP2_HIGH; + } + + String heater = result.substring(14, 15); + if (heater == "0") { + heaterState = false; + } else if (heater == "1") { + heaterState = true; + tubpowerCalc += POWER_HEATER; + } else if (heater == "2") { + heaterState = true; // heater off, verifying temp change, but creates noisy state if we return false + tubpowerCalc += POWER_HEATER; + } + + status.power = tubpowerCalc; + + String light = result.substring(15, 16); + if (light == "0") { + lightState = false; + } else if (light == "3") { + lightState = true; + } + + // Ignore last 2 bytes as possibly checksum, given we have temp earlier making look more complex than + // perhaps it is + String newRaw = result.substring(17, 44); + if (lastRaw != newRaw) { + lastRaw = newRaw; + status.rawData = lastRaw.c_str(); + + String s = result.substring(17, 18); + if (s == "4") { + state = "Sleep"; + status.mode = MODE_IDX_SLP; + } else if (s == "9") { + state = "Circulation ?"; + status.mode = MODE_IDX_STD; // TODO: confirm + } else if (s == "1") { + state = "Standard"; + status.mode = MODE_IDX_STD; + } else if (s == "2") { + state = "Economy"; + status.mode = MODE_IDX_ECO; + } else if (s == "a") { + state = "Cleaning"; // TODO: can't tell our actual mode here - could be any of the 3 I think + } else if (s == "c") { + state = "Circulation in sleep?"; + status.mode = MODE_IDX_SLP; + } else if (s == "b" || s == "3") { + state = "Std in Eco"; // Was in eco, Swap to STD for 1 hour only + status.mode = MODE_IDX_STD; + } else { + state = "Unknown " + s; + } + + String menu = result.substring(18, 20); + if (menu == "00") { + // idle + } else if (menu == "4c") { + state = "Set Mode"; + } else if (menu == "5a") { + state = "Standby?"; // WT: not tested to confirm if this is the act of setting Standby or just seen + // when in standby + } else { // 46 for set temp, but also other things like filter time + state = "menu " + menu; + } + + // 94600008002ffffff0200000000f5 + + if (result.substring(28, 32) != "ffff") { + timeString = HexString2TimeString(result.substring(28, 32)); + } else { + timeString = "--:--"; + } + status.time = timeString.c_str(); + + // temp up - ff0100000000?? - end varies + + // temp down - ff0200000000?? - end varies + + String cmd = result.substring(34, 44); + if (cmd == "0000000000") { + // none + } else if (cmd.substring(0, 4) == "01") { + state = "Temp Up"; + } else if (cmd.substring(0, 4) == "02") { + state = "Temp Down"; + } else { + telnetSend("CMD: " + cmd); + } + if (!lastRaw3.equals(cmd)) { + // Controller responded to command + sendBuffer.dequeue(); + Serial.printf("YAY: command response : %u\n", delayTime); + } + + if (!lastRaw3.equals(cmd) && cmd != "0000000000") { // ignore idle command + lastRaw3 = cmd; + status.rawData3 = lastRaw3.c_str(); + } + + if (result.substring(10, 12) == "43") { // "C" + double tmp = (HexString2ASCIIString(result.substring(4, 10)).toDouble() / 10); + if (menu == "46") { + tubTargetTemp = tmp; + status.targetTemp = (float)tubTargetTemp; + Serial.printf("Sent target temp data %f\n", tubTargetTemp); + } else { + if (tubTemp != tmp) { + tubTemp = tmp; + status.temp = (float)tubTemp; + Serial.printf("Sent temp data %f\n", tubTemp); + } + if (heaterState && (tubTemp < tubTargetTemp)) { + double tempDiff = (tubTargetTemp - tubTemp); + float timeToTempValue = (tempDiff * MINUTES_PER_DEGC); + status.timeToTemp = timeToTempValue; + } else { + status.timeToTemp = 0; + } + } + } else if (result.substring(10, 12) == "2d") { // "-" + // Serial.println("temp = unknown"); + // telnetSend("temp = unknown"); + } else { + Serial.println("non-temp " + result); + telnetSend("non-temp " + result); + } + + status.state = state.c_str(); + } + } else { + // FA but not temp data + lastRaw2 = result.substring(4, 28); + status.rawData2 = lastRaw2.c_str(); + } + + if (result.length() >= 64) { // "Long" messages only + String tail = result.substring(46, 64); + if (tail != lastRaw7) { + lastRaw7 = tail; + status.rawData7 = lastRaw7.c_str(); + } + } + + status.pump1 = pump1State; + status.pump2 = pump2State; + status.heater = heaterState; + status.light = lightState; + + // end of FA14 + } else if (result.substring(0, 4) == "ae0d") { + // Serial.println("AE 0D"); + // telnetSend(result); + + String message = result.substring(0, 32); // ignore any FB ending + + if (result.substring(0, 6) == "ae0d01" && message != "ae0d010000000000000000000000005a") { + if (!lastRaw4.equals(message)) { + lastRaw4 = message; + // status.rawData4 = lastRaw4.c_str(); + } + } else if (result.substring(0, 6) == "ae0d02" && message != "ae0d02000000000000000000000000c3") { + if (!lastRaw5.equals(message)) { + lastRaw5 = message; + // status.rawData5 = lastRaw5.c_str(); + } + } else if (result.substring(0, 6) == "ae0d03" && message != "ae0d03000000000000000000000000b4") { + if (!lastRaw6.equals(message)) { + lastRaw6 = message; + // status.rawData6 = lastRaw6.c_str(); + } + } + // end of AE 0D + } else { + Serial.printf("Unknown message (%u): ", result.length()); + Serial.println(result); + telnetSend("U: " + result); + } +} + +void sendCommand() { + if (!sendBuffer.isEmpty()) { + digitalWrite(RTS_PIN, HIGH); + digitalWrite(LED_BUILTIN, HIGH); + + delayMicroseconds(delayTime); + // Serial.println("Sending " + sendBuffer); + byte byteArray[18] = {0}; + hexCharacterStringToBytes(byteArray, sendBuffer.getHead().c_str()); + // if(digitalRead(PIN_5_PIN) != LOW) { + // Serial.println("ERROR: Pin5 went high before command before write"); + // } + tub.write(byteArray, sizeof(byteArray)); + if (digitalRead(PIN_5_PIN) != LOW) { + Serial.printf("ERROR: Pin5 went high before command before flush : %u\n", delayTime); + delayTime = 0; + sendBuffer.dequeue(); + } + // tub.flush(true); + if (digitalRead(PIN_5_PIN) == LOW) { + // sendBuffer.dequeue(); // TODO: trying to resend now till we see response + Serial.printf("message sent : %u\n", delayTime); + // delayTime += 10; + } + // else { + // Serial.println("ERROR: Pin5 went high before command could be sent after flush"); + // } + digitalWrite(RTS_PIN, LOW); + digitalWrite(LED_BUILTIN, LOW); + } +} + +String HexString2TimeString(String hexstring) { + // Convert "HHMM" in HEX to "HH:MM" with decimal representation + String time = ""; + int hour = strtol(hexstring.substring(0, 2).c_str(), NULL, 16); + int minute = strtol(hexstring.substring(2, 4).c_str(), NULL, 16); + + if (hour < 10) time.concat("0"); // Add leading zero + time.concat(hour); + time.concat(":"); + if (minute < 10) time.concat("0"); // Add leading zero + time.concat(minute); + + return time; +} + +String HexString2ASCIIString(String hexstring) { + String temp = "", sub = "", result; + char buf[3]; + for (int i = 0; i < hexstring.length(); i += 2) { + sub = hexstring.substring(i, i + 2); + sub.toCharArray(buf, 3); + char b = (char)strtol(buf, 0, 16); + if (b == '\0') break; + temp += b; + } + return temp; +} + +byte nibble(char c) { + if (c >= '0' && c <= '9') return c - '0'; + if (c >= 'a' && c <= 'f') return c - 'a' + 10; + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + return 0; // Not a valid hexadecimal character +} + +void hexCharacterStringToBytes(byte* byteArray, const char* hexString) { + bool oddLength = strlen(hexString) & 1; + + byte currentByte = 0; + byte byteIndex = 0; + + for (byte charIndex = 0; charIndex < strlen(hexString); charIndex++) { + bool oddCharIndex = charIndex & 1; + + if (oddLength) { + // If the length is odd + if (oddCharIndex) { + // odd characters go in high nibble + currentByte = nibble(hexString[charIndex]) << 4; + } else { + // Even characters go into low nibble + currentByte |= nibble(hexString[charIndex]); + byteArray[byteIndex++] = currentByte; + currentByte = 0; + } + } else { + // If the length is even + if (!oddCharIndex) { + // Odd characters go into the high nibble + currentByte = nibble(hexString[charIndex]) << 4; + } else { + // Odd characters go into low nibble + currentByte |= nibble(hexString[charIndex]); + byteArray[byteIndex++] = currentByte; + currentByte = 0; + } + } + } +} + From f3cecb6ca6e8903744e515b00e03f4bef171e947 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 2 Sep 2023 19:06:00 +0100 Subject: [PATCH 049/378] prevent redef --- sensor/src/balboaGL.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sensor/src/balboaGL.h b/sensor/src/balboaGL.h index 1ff3b97..0c79e76 100644 --- a/sensor/src/balboaGL.h +++ b/sensor/src/balboaGL.h @@ -1,3 +1,6 @@ +#ifndef BALBOAGL_H +#define BALBOAGL_H + #include int delayTime = 40; @@ -436,3 +439,4 @@ void hexCharacterStringToBytes(byte* byteArray, const char* hexString) { } } +#endif From 10d36fa6d690213eb13020b1a40f9464f576073f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 09:48:49 +0100 Subject: [PATCH 050/378] Comment cg.add_library as adding in yaml --- components/BalboaGL/climate.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 7f6a5ae..b207981 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -85,8 +85,8 @@ def to_code(config): yield cg.register_component(var, config) yield climate.register_climate(var, config) - cg.add_library( - name="balboa_GL_ML_spa_control", - repository="https://github.com/netmindz/balboa_GL_ML_spa_control", - version="library", - ) +# cg.add_library( +# name="balboa_GL_ML_spa_control", +# repository="https://github.com/netmindz/balboa_GL_ML_spa_control", +# version="library", +# ) From e347ab19fa5446d0105b3273df436e17c4818a24 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 11:57:10 +0100 Subject: [PATCH 051/378] remove dups --- components/BalboaGL/ESPBalboaGL.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 1f0a232..f8c9c30 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -10,25 +10,25 @@ static const char* TAG = "BalboaGL"; // Logging tag -// Perform measurements or read nameplate values on your tub to define the power [kW] -// for each device in order to calculate tub power usage -const float POWER_HEATER = 2.8; -const float POWER_PUMP_CIRCULATION = 0.3; -const float POWER_PUMP1_LOW = 0.31; -const float POWER_PUMP1_HIGH = 1.3; -const float POWER_PUMP2_LOW = 0.3; -const float POWER_PUMP2_HIGH = 0.6; - -// Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc -const int MINUTES_PER_DEGC = 45; +// // Perform measurements or read nameplate values on your tub to define the power [kW] +// // for each device in order to calculate tub power usage +// const float POWER_HEATER = 2.8; +// const float POWER_PUMP_CIRCULATION = 0.3; +// const float POWER_PUMP1_LOW = 0.31; +// const float POWER_PUMP1_HIGH = 1.3; +// const float POWER_PUMP2_LOW = 0.3; +// const float POWER_PUMP2_HIGH = 0.6; + +// // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc +// const int MINUTES_PER_DEGC = 45; const uint32_t POLL_INTERVAL_DEFAULT = 10000; #define tub Serial2 #define RX_PIN 19 #define TX_PIN 23 -#define RTS_PIN 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. -#define PIN_5_PIN 18 +// #define RTS_PIN 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. +// #define PIN_5_PIN 18 #define LED_BUILTIN 2 From fb7654aa76d4b9ea89e0d2b9082dcafac48f7827 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 12:49:27 +0100 Subject: [PATCH 052/378] Dedicated library --- component.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/component.yaml b/component.yaml index 84c4074..5e7b1c0 100644 --- a/component.yaml +++ b/component.yaml @@ -2,8 +2,8 @@ name: hottub friendly_name: Hottub libraries: - - balboa=https://github.com/netmindz/balboa_GL_ML_spa_control.git#library - ArduinoQueue=https://github.com/EinarArnason/ArduinoQueue.git@^1.2.5 + - balboaGL=https://github.com/netmindz/balboaGL.git#0145fe65e531b8d4baacbdd75adc4bf4dab97433 esp32: From 965a3dcaa51a3bd43f2245bae0ae677696fbaa0e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 12:51:46 +0100 Subject: [PATCH 053/378] Move deps to code --- components/BalboaGL/climate.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index b207981..91bbbb7 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -85,8 +85,13 @@ def to_code(config): yield cg.register_component(var, config) yield climate.register_climate(var, config) -# cg.add_library( -# name="balboa_GL_ML_spa_control", -# repository="https://github.com/netmindz/balboa_GL_ML_spa_control", -# version="library", -# ) + cg.add_library( + name="ArduinoQueue", + repository="https://github.com/EinarArnason/ArduinoQueue.git", + version="1.2.5", + ) + cg.add_library( + name="balboaGL", + repository="https://github.com/netmindz/balboaGL.git", + version="0145fe65e531b8d4baacbdd75adc4bf4dab97433", + ) From 906882d9b5c9419cf4a8afa2b1112f9f057e3443 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 13:24:08 +0100 Subject: [PATCH 054/378] Cleanup library from yaml --- component.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/component.yaml b/component.yaml index 5e7b1c0..acd4b99 100644 --- a/component.yaml +++ b/component.yaml @@ -1,11 +1,7 @@ esphome: name: hottub friendly_name: Hottub - libraries: - - ArduinoQueue=https://github.com/EinarArnason/ArduinoQueue.git@^1.2.5 - - balboaGL=https://github.com/netmindz/balboaGL.git#0145fe65e531b8d4baacbdd75adc4bf4dab97433 - esp32: board: esp32dev framework: From 0c91f40eca7a2a479fe965c64a3bf4dada8676f0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 13:26:24 +0100 Subject: [PATCH 055/378] remove sensor/src/balboaGL.h --- sensor/src/balboaGL.h | 442 ------------------------------------------ 1 file changed, 442 deletions(-) delete mode 100644 sensor/src/balboaGL.h diff --git a/sensor/src/balboaGL.h b/sensor/src/balboaGL.h deleted file mode 100644 index 0c79e76..0000000 --- a/sensor/src/balboaGL.h +++ /dev/null @@ -1,442 +0,0 @@ -#ifndef BALBOAGL_H -#define BALBOAGL_H - -#include - -int delayTime = 40; - -#include "constants.h" - -struct BalboaStatus { - float power; - String rawData; - String rawData2; // TODO: better name - String rawData3; // TODO: better name - String rawData7; // TODO: better name - float targetTemp; - float temp; - float timeToTemp; - int mode; - int pump1; - int pump2; - String time; - boolean heater; - boolean light; - String state; -} status; - - - - -ArduinoQueue sendBuffer(10); // TODO: might be better bigger for large temp changes. Would need testing - -void sendCommand(String command, int count) { - Serial.printf("Sending %s - %u times\n", command.c_str(), count); - for (int i = 0; i < count; i++) { - sendBuffer.enqueue(command.c_str()); - } -} - -void setOption(int currentIndex, int targetIndex, int options, String command = COMMAND_DOWN) { - if (targetIndex > currentIndex) { - sendCommand(command, (targetIndex - currentIndex)); - } else if (currentIndex != targetIndex) { - int presses = (options - currentIndex) + targetIndex; - sendCommand(command, presses); - } -} - - -String result = ""; -int msgLength = 0; - -void handleMessage(); -void sendCommand(); -String HexString2ASCIIString(String hexstring); -void hexCharacterStringToBytes(byte* byteArray, const char* hexString); -String HexString2TimeString(String hexstring); -void telnetSend(String message); - -void handleBytes(size_t len, uint8_t buf[]) { - - for (int i = 0; i < len; i++) { - if (buf[i] < 0x10) { - result += '0'; - } - result += String(buf[i], HEX); - } - if (msgLength == 0 && result.length() == 2) { - String messageType = result.substring(0, 2); - if (messageType == "fa") { - msgLength = 46; - } else if (messageType == "ae") { - msgLength = 32; - } else { - Serial.print("Unknown message length for "); - Serial.println(messageType); - } - } else if (result.length() == msgLength) { - if (result.length() == 46) { - sendCommand(); // send reply *before* we parse the FA string as we don't want to delay the reply by - // say sending MQTT updates - } - handleMessage(); - } -} - -void handleMessage() { - - // Set as static, so only allocating memory once, not per method call - as when was global - static int pump1State = 0; - static int pump2State = 0; - static boolean heaterState = false; - static boolean lightState = false; - static float tubpowerCalc = 0; - static double tubTemp = -1; - static double tubTargetTemp = -1; - static String state = "unknown"; - static String lastRaw = ""; - static String lastRaw2 = ""; - static String lastRaw3 = ""; - static String lastRaw4 = ""; - static String lastRaw5 = ""; - static String lastRaw6 = ""; - static String lastRaw7 = ""; - static String timeString = ""; - - // Serial.print("message = "); - // Serial.println(result); - - if (result.substring(0, 4) == "fa14") { - // Serial.println("FA 14"); - // telnetSend(result); - - // fa1433343043 = header + 340C = 34.0C - - // If messages is temp or ---- for temp, it is status message - if (result.substring(10, 12) == "43" || result.substring(10, 12) == "2d") { - tubpowerCalc = 0; - String pump = result.substring(13, 14); - - if (pump == "0") { // Pump 1 Off - Pump 2 Off - 0b0000 - pump1State = 0; - pump2State = 0; - } else if (pump == "1") { // Pump 1 Low - Pump 2 Off - 0b0001 - pump1State = 1; - pump2State = 0; - tubpowerCalc += POWER_PUMP1_LOW; - } else if (pump == "2") { // Pump 1 High - Pump 2 Off - 0b0010 - pump1State = PUMP1_STATE_HIGH; - pump2State = 0; - tubpowerCalc += POWER_PUMP1_HIGH; - } else if (pump == "4") { // Pump 1 Off - Pump 2 Low - 0b0100 - pump1State = 0; - pump2State = 1; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "5") { // Pump 1 Low - Pump 2 Low - 0b0101 - pump1State = 1; - pump2State = 1; - tubpowerCalc += POWER_PUMP1_LOW; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "6") { // Pump 1 High - Pump 2 Low - 0b0110 - pump1State = PUMP1_STATE_HIGH; - pump2State = 1; - tubpowerCalc += POWER_PUMP1_HIGH; - tubpowerCalc += POWER_PUMP2_LOW; - } else if (pump == "8") { // Pump 1 Off - Pump 2 High - 0b1000 - pump1State = 0; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP2_HIGH; - } else if (pump == "9") { // Pump 1 Low - Pump 2 High - 0b1001 - pump1State = 1; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP1_LOW; - tubpowerCalc += POWER_PUMP2_HIGH; - } else if (pump == "a") { // Pump 1 High - Pump 2 HIGH = 0b1010 - pump1State = PUMP1_STATE_HIGH; - pump2State = PUMP2_STATE_HIGH; - tubpowerCalc += POWER_PUMP1_HIGH; - tubpowerCalc += POWER_PUMP2_HIGH; - } - - String heater = result.substring(14, 15); - if (heater == "0") { - heaterState = false; - } else if (heater == "1") { - heaterState = true; - tubpowerCalc += POWER_HEATER; - } else if (heater == "2") { - heaterState = true; // heater off, verifying temp change, but creates noisy state if we return false - tubpowerCalc += POWER_HEATER; - } - - status.power = tubpowerCalc; - - String light = result.substring(15, 16); - if (light == "0") { - lightState = false; - } else if (light == "3") { - lightState = true; - } - - // Ignore last 2 bytes as possibly checksum, given we have temp earlier making look more complex than - // perhaps it is - String newRaw = result.substring(17, 44); - if (lastRaw != newRaw) { - lastRaw = newRaw; - status.rawData = lastRaw.c_str(); - - String s = result.substring(17, 18); - if (s == "4") { - state = "Sleep"; - status.mode = MODE_IDX_SLP; - } else if (s == "9") { - state = "Circulation ?"; - status.mode = MODE_IDX_STD; // TODO: confirm - } else if (s == "1") { - state = "Standard"; - status.mode = MODE_IDX_STD; - } else if (s == "2") { - state = "Economy"; - status.mode = MODE_IDX_ECO; - } else if (s == "a") { - state = "Cleaning"; // TODO: can't tell our actual mode here - could be any of the 3 I think - } else if (s == "c") { - state = "Circulation in sleep?"; - status.mode = MODE_IDX_SLP; - } else if (s == "b" || s == "3") { - state = "Std in Eco"; // Was in eco, Swap to STD for 1 hour only - status.mode = MODE_IDX_STD; - } else { - state = "Unknown " + s; - } - - String menu = result.substring(18, 20); - if (menu == "00") { - // idle - } else if (menu == "4c") { - state = "Set Mode"; - } else if (menu == "5a") { - state = "Standby?"; // WT: not tested to confirm if this is the act of setting Standby or just seen - // when in standby - } else { // 46 for set temp, but also other things like filter time - state = "menu " + menu; - } - - // 94600008002ffffff0200000000f5 - - if (result.substring(28, 32) != "ffff") { - timeString = HexString2TimeString(result.substring(28, 32)); - } else { - timeString = "--:--"; - } - status.time = timeString.c_str(); - - // temp up - ff0100000000?? - end varies - - // temp down - ff0200000000?? - end varies - - String cmd = result.substring(34, 44); - if (cmd == "0000000000") { - // none - } else if (cmd.substring(0, 4) == "01") { - state = "Temp Up"; - } else if (cmd.substring(0, 4) == "02") { - state = "Temp Down"; - } else { - telnetSend("CMD: " + cmd); - } - if (!lastRaw3.equals(cmd)) { - // Controller responded to command - sendBuffer.dequeue(); - Serial.printf("YAY: command response : %u\n", delayTime); - } - - if (!lastRaw3.equals(cmd) && cmd != "0000000000") { // ignore idle command - lastRaw3 = cmd; - status.rawData3 = lastRaw3.c_str(); - } - - if (result.substring(10, 12) == "43") { // "C" - double tmp = (HexString2ASCIIString(result.substring(4, 10)).toDouble() / 10); - if (menu == "46") { - tubTargetTemp = tmp; - status.targetTemp = (float)tubTargetTemp; - Serial.printf("Sent target temp data %f\n", tubTargetTemp); - } else { - if (tubTemp != tmp) { - tubTemp = tmp; - status.temp = (float)tubTemp; - Serial.printf("Sent temp data %f\n", tubTemp); - } - if (heaterState && (tubTemp < tubTargetTemp)) { - double tempDiff = (tubTargetTemp - tubTemp); - float timeToTempValue = (tempDiff * MINUTES_PER_DEGC); - status.timeToTemp = timeToTempValue; - } else { - status.timeToTemp = 0; - } - } - } else if (result.substring(10, 12) == "2d") { // "-" - // Serial.println("temp = unknown"); - // telnetSend("temp = unknown"); - } else { - Serial.println("non-temp " + result); - telnetSend("non-temp " + result); - } - - status.state = state.c_str(); - } - } else { - // FA but not temp data - lastRaw2 = result.substring(4, 28); - status.rawData2 = lastRaw2.c_str(); - } - - if (result.length() >= 64) { // "Long" messages only - String tail = result.substring(46, 64); - if (tail != lastRaw7) { - lastRaw7 = tail; - status.rawData7 = lastRaw7.c_str(); - } - } - - status.pump1 = pump1State; - status.pump2 = pump2State; - status.heater = heaterState; - status.light = lightState; - - // end of FA14 - } else if (result.substring(0, 4) == "ae0d") { - // Serial.println("AE 0D"); - // telnetSend(result); - - String message = result.substring(0, 32); // ignore any FB ending - - if (result.substring(0, 6) == "ae0d01" && message != "ae0d010000000000000000000000005a") { - if (!lastRaw4.equals(message)) { - lastRaw4 = message; - // status.rawData4 = lastRaw4.c_str(); - } - } else if (result.substring(0, 6) == "ae0d02" && message != "ae0d02000000000000000000000000c3") { - if (!lastRaw5.equals(message)) { - lastRaw5 = message; - // status.rawData5 = lastRaw5.c_str(); - } - } else if (result.substring(0, 6) == "ae0d03" && message != "ae0d03000000000000000000000000b4") { - if (!lastRaw6.equals(message)) { - lastRaw6 = message; - // status.rawData6 = lastRaw6.c_str(); - } - } - // end of AE 0D - } else { - Serial.printf("Unknown message (%u): ", result.length()); - Serial.println(result); - telnetSend("U: " + result); - } -} - -void sendCommand() { - if (!sendBuffer.isEmpty()) { - digitalWrite(RTS_PIN, HIGH); - digitalWrite(LED_BUILTIN, HIGH); - - delayMicroseconds(delayTime); - // Serial.println("Sending " + sendBuffer); - byte byteArray[18] = {0}; - hexCharacterStringToBytes(byteArray, sendBuffer.getHead().c_str()); - // if(digitalRead(PIN_5_PIN) != LOW) { - // Serial.println("ERROR: Pin5 went high before command before write"); - // } - tub.write(byteArray, sizeof(byteArray)); - if (digitalRead(PIN_5_PIN) != LOW) { - Serial.printf("ERROR: Pin5 went high before command before flush : %u\n", delayTime); - delayTime = 0; - sendBuffer.dequeue(); - } - // tub.flush(true); - if (digitalRead(PIN_5_PIN) == LOW) { - // sendBuffer.dequeue(); // TODO: trying to resend now till we see response - Serial.printf("message sent : %u\n", delayTime); - // delayTime += 10; - } - // else { - // Serial.println("ERROR: Pin5 went high before command could be sent after flush"); - // } - digitalWrite(RTS_PIN, LOW); - digitalWrite(LED_BUILTIN, LOW); - } -} - -String HexString2TimeString(String hexstring) { - // Convert "HHMM" in HEX to "HH:MM" with decimal representation - String time = ""; - int hour = strtol(hexstring.substring(0, 2).c_str(), NULL, 16); - int minute = strtol(hexstring.substring(2, 4).c_str(), NULL, 16); - - if (hour < 10) time.concat("0"); // Add leading zero - time.concat(hour); - time.concat(":"); - if (minute < 10) time.concat("0"); // Add leading zero - time.concat(minute); - - return time; -} - -String HexString2ASCIIString(String hexstring) { - String temp = "", sub = "", result; - char buf[3]; - for (int i = 0; i < hexstring.length(); i += 2) { - sub = hexstring.substring(i, i + 2); - sub.toCharArray(buf, 3); - char b = (char)strtol(buf, 0, 16); - if (b == '\0') break; - temp += b; - } - return temp; -} - -byte nibble(char c) { - if (c >= '0' && c <= '9') return c - '0'; - if (c >= 'a' && c <= 'f') return c - 'a' + 10; - if (c >= 'A' && c <= 'F') return c - 'A' + 10; - return 0; // Not a valid hexadecimal character -} - -void hexCharacterStringToBytes(byte* byteArray, const char* hexString) { - bool oddLength = strlen(hexString) & 1; - - byte currentByte = 0; - byte byteIndex = 0; - - for (byte charIndex = 0; charIndex < strlen(hexString); charIndex++) { - bool oddCharIndex = charIndex & 1; - - if (oddLength) { - // If the length is odd - if (oddCharIndex) { - // odd characters go in high nibble - currentByte = nibble(hexString[charIndex]) << 4; - } else { - // Even characters go into low nibble - currentByte |= nibble(hexString[charIndex]); - byteArray[byteIndex++] = currentByte; - currentByte = 0; - } - } else { - // If the length is even - if (!oddCharIndex) { - // Odd characters go into the high nibble - currentByte = nibble(hexString[charIndex]) << 4; - } else { - // Odd characters go into low nibble - currentByte |= nibble(hexString[charIndex]); - byteArray[byteIndex++] = currentByte; - currentByte = 0; - } - } - } -} - -#endif From b7c9258e9368164fa8f5e0f4065f95af2214c1dc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 3 Sep 2023 13:27:39 +0100 Subject: [PATCH 056/378] remove components/BalboaGL/constants.h --- components/BalboaGL/constants.h | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 components/BalboaGL/constants.h diff --git a/components/BalboaGL/constants.h b/components/BalboaGL/constants.h deleted file mode 100644 index 43d0731..0000000 --- a/components/BalboaGL/constants.h +++ /dev/null @@ -1,29 +0,0 @@ -// https://godbolt.org/z/TEqhrhvPc - -#define COMMAND_UP "fb0603450e0001fe66" -#define COMMAND_DOWN "fb0603450e0002fd50" -//#define COMMAND_TOGGLE "fb066666666609f6c2" -// #define COMMAND_TIME "fb066666666603fc76" -#define COMMAND_CHANGE_MODE "fb0603450e0004fb3c" -// #define COMMAND_BLOWER "fb06666666660af5f4" -#define COMMAND_JET1 "fb060343060006f9a2" // TODO: fix me - swapped to tmjo's panel as mine was one char short in my notes -#define COMMAND_JET2 "fb060343060007f8b0" // TODO: fix me - swapped to tmjo's panel as mine was one char short in my notes -#define COMMAND_EMPTY "fb0603450e0000ff74" -#define COMMAND_LIGHT "fb0603450e0009f6f6" - -// Std;Eco;Sleep -#define MODE_IDX_STD 0 -#define MODE_IDX_ECO 1 -#define MODE_IDX_SLP 2 - -#ifdef PUMP1_DUAL_SPEED -#define PUMP1_STATE_HIGH 2 -#else -#define PUMP1_STATE_HIGH 1 -#endif - -#ifdef PUMP2_DUAL_SPEED -#define PUMP2_STATE_HIGH 2 -#else -#define PUMP2_STATE_HIGH 1 -#endif From f2074d3ab0579cdb0a3ae95057cda6c0a0136edd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 13:52:27 +0100 Subject: [PATCH 057/378] Use updated library --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 91bbbb7..db64eb7 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -93,5 +93,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="0145fe65e531b8d4baacbdd75adc4bf4dab97433", + version="d015e1ae014f7f2e0df1fc24d65e1cfcb66ed1cb", ) From 595a0770a0af622515c6162fd2d99135bb139b73 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 13:57:08 +0100 Subject: [PATCH 058/378] Create spa object --- components/BalboaGL/ESPBalboaGL.cpp | 8 ++++---- components/BalboaGL/ESPBalboaGL.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index dcc469f..f886d1f 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -385,7 +385,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // this->hp->setRemoteTemperature(temp); // } -// void BalboaGL::setup() { +void BalboaGL::setup() { // // This will be called by App.setup() // this->banner(); // ESP_LOGCONFIG(TAG, "Setting up UART..."); @@ -400,8 +400,8 @@ void BalboaGL::control(const climate::ClimateCall &call) { // } // this->check_logger_conflict_(); -// ESP_LOGCONFIG(TAG, "Intializing new HeatPump object."); -// this->hp = new HeatPump(); + ESP_LOGCONFIG(TAG, "Intializing new balboaGL object."); + this->spa = new balboaGL(18,22); // this->current_temperature = NAN; // this->target_temperature = NAN; // this->fan_mode = climate::CLIMATE_FAN_OFF; @@ -454,7 +454,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // auto_setpoint = load(auto_storage); // this->dump_config(); -// } +} // /** // * The ESP only has a few bytes of rtc storage, so instead diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index f8c9c30..3b27e80 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -81,5 +81,7 @@ class BalboaGL : public PollingComponent, public climate::Climate { private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; + + balboaGL spa; }; #endif \ No newline at end of file From 9b0cd717818cd3646f767fddc5a18683f1515ebe Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 13:59:36 +0100 Subject: [PATCH 059/378] Correct include --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 3b27e80..800a41c 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -6,7 +6,7 @@ #ifndef ESPMHP_H #define ESPMHP_H -#include "constants.h" +#include "balboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag From c0acdc2461561127a944e3a7db5390ebdcbf92ca Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 14:03:11 +0100 Subject: [PATCH 060/378] Enable setup --- components/BalboaGL/ESPBalboaGL.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 800a41c..1fb198a 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -31,7 +31,6 @@ const uint32_t POLL_INTERVAL_DEFAULT = 10000; // #define PIN_5_PIN 18 #define LED_BUILTIN 2 - #include "balboaGL.h" using namespace esphome; @@ -51,8 +50,8 @@ class BalboaGL : public PollingComponent, public climate::Climate { // // Handle a change in status as detected by the HeatPump library. // void hpStatusChanged(heatpumpStatus currentStatus); - // // Set up the component, initializing the HeatPump object. - // void setup() override; + // // Set up the component, initializing the balboaGL object. + void setup() override; // // This is called every poll_interval. void update() override; From 09b291f84869632c0f7c0e3beaa0291451b5b8b0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 14:19:59 +0100 Subject: [PATCH 061/378] Pass HardwareSerial --- components/BalboaGL/ESPBalboaGL.cpp | 5 +++-- components/BalboaGL/climate.py | 5 +---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f886d1f..2876ba3 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -33,6 +33,7 @@ BalboaGL::BalboaGL( // } void BalboaGL::update() { + this->spa->readSerial(); // // This will be called every "update_interval" milliseconds. // //this->dump_config(); // this->hp->sync(); @@ -400,8 +401,8 @@ void BalboaGL::setup() { // } // this->check_logger_conflict_(); - ESP_LOGCONFIG(TAG, "Intializing new balboaGL object."); - this->spa = new balboaGL(18,22); + ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); + this->spa = new balboaGL(hw_serial_, 18,22); // this->current_temperature = NAN; // this->target_temperature = NAN; // this->fan_mode = climate::CLIMATE_FAN_OFF; diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index db64eb7..b7132a8 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -64,9 +64,6 @@ def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) -# if CONF_BAUD_RATE in config: -# cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) - supports = config[CONF_SUPPORTS] traits = var.config_traits() @@ -93,5 +90,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="d015e1ae014f7f2e0df1fc24d65e1cfcb66ed1cb", + version="d05f8e83f500e9a85670766165a561eb277f7086", ) From 43e1b821cf11f3c1924872e11a692c478713f4be Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 14:43:08 +0100 Subject: [PATCH 062/378] New library --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- components/BalboaGL/climate.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2876ba3..f958ab0 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -402,7 +402,7 @@ void BalboaGL::setup() { // this->check_logger_conflict_(); ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - this->spa = new balboaGL(hw_serial_, 18,22); + this->spa = new balboaGL(hw_serial_, 18, 22); // this->current_temperature = NAN; // this->target_temperature = NAN; // this->fan_mode = climate::CLIMATE_FAN_OFF; diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index b7132a8..566c900 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -90,5 +90,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="d05f8e83f500e9a85670766165a561eb277f7086", + version="e56660d5140229a5c489e5f1add134dd1cfe036a", ) From 361d66e5cef258a8af7dcd0bc7f330a3bb719a58 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 14:53:16 +0100 Subject: [PATCH 063/378] New library --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 566c900..5aeb921 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -90,5 +90,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="e56660d5140229a5c489e5f1add134dd1cfe036a", + version="c9231e1c7341ab2ff8a641810283732999e9cdbf", ) From 7808183c84b6810de8221d8d5205dbda059e7d01 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:00:22 +0100 Subject: [PATCH 064/378] Disable ESP8266 builds as SoftwareSerial not supported --- sensor/platformio.ini | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sensor/platformio.ini b/sensor/platformio.ini index 0d28de1..d22a591 100644 --- a/sensor/platformio.ini +++ b/sensor/platformio.ini @@ -31,6 +31,7 @@ upload_flags = --timeout=60 ; --host_ip=192.168.178.107 -[env:d1_mini_lite] -board = d1_mini_lite -platform = espressif8266 + ; New library version of code uses HardwareSerial +; [env:d1_mini_lite] +; board = d1_mini_lite +; platform = espressif8266 From bb4a089243eeef327ba62cebf097e9295619f71b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:07:28 +0100 Subject: [PATCH 065/378] Constructor tweak --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f958ab0..a7c607e 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -11,8 +11,9 @@ using namespace esphome; BalboaGL::BalboaGL( HardwareSerial* hw_serial ) : - hw_serial_{hw_serial} + // hw_serial_{hw_serial} { + this->hw_serial_ = hw_serial; this->traits_.set_supports_action(true); this->traits_.set_supports_current_temperature(true); this->traits_.set_supports_two_point_target_temperature(false); From 0355c8d84eab003aeff79f6ec0c006f679245e8f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:09:31 +0100 Subject: [PATCH 066/378] Constructor tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index a7c607e..7d79ffd 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -10,7 +10,7 @@ using namespace esphome; */ BalboaGL::BalboaGL( HardwareSerial* hw_serial -) : +) //: // hw_serial_{hw_serial} { this->hw_serial_ = hw_serial; From 0c05b35da62c4fc6e1008dea22bb4872dce0f3ff Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:18:08 +0100 Subject: [PATCH 067/378] Constructor tweak --- components/BalboaGL/ESPBalboaGL.cpp | 5 ++--- components/BalboaGL/ESPBalboaGL.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 7d79ffd..f958ab0 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -10,10 +10,9 @@ using namespace esphome; */ BalboaGL::BalboaGL( HardwareSerial* hw_serial -) //: - // hw_serial_{hw_serial} +) : + hw_serial_{hw_serial} { - this->hw_serial_ = hw_serial; this->traits_.set_supports_action(true); this->traits_.set_supports_current_temperature(true); this->traits_.set_supports_two_point_target_temperature(false); diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 1fb198a..b5491b7 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -81,6 +81,6 @@ class BalboaGL : public PollingComponent, public climate::Climate { // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; - balboaGL spa; + balboaGL* spa; }; #endif \ No newline at end of file From f6753ca42cd04eb91e84fff397c30a5f7ccbe9dd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:27:13 +0100 Subject: [PATCH 068/378] Set values --- components/BalboaGL/ESPBalboaGL.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f958ab0..c1b0a71 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -33,6 +33,7 @@ BalboaGL::BalboaGL( // } void BalboaGL::update() { + ESP_LOGV(TAG, "Update called."); this->spa->readSerial(); // // This will be called every "update_interval" milliseconds. // //this->dump_config(); @@ -217,7 +218,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); // // send the update back to esphome: -// this->publish_state(); + this->publish_state(); // // and the heat pump: // hp->update(); } @@ -403,10 +404,10 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); this->spa = new balboaGL(hw_serial_, 18, 22); -// this->current_temperature = NAN; -// this->target_temperature = NAN; -// this->fan_mode = climate::CLIMATE_FAN_OFF; -// this->swing_mode = climate::CLIMATE_SWING_OFF; + this->current_temperature = NAN; + this->target_temperature = NAN; + this->fan_mode = climate::CLIMATE_FAN_AUTO; + this->swing_mode = climate::CLIMATE_SWING_OFF; // #ifdef USE_CALLBACKS // hp->setSettingsChangedCallback( From 5c2cada490d7318ae1f7ac5ee936e0a3930031b1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:35:07 +0100 Subject: [PATCH 069/378] Check UART --- components/BalboaGL/ESPBalboaGL.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index c1b0a71..f5bf403 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -388,19 +388,19 @@ void BalboaGL::control(const climate::ClimateCall &call) { // } void BalboaGL::setup() { -// // This will be called by App.setup() -// this->banner(); -// ESP_LOGCONFIG(TAG, "Setting up UART..."); -// if (!this->get_hw_serial_()) { -// ESP_LOGCONFIG( -// TAG, -// "No HardwareSerial was provided. " -// "Software serial ports are unsupported by this component." -// ); -// this->mark_failed(); -// return; -// } -// this->check_logger_conflict_(); + // This will be called by App.setup() + this->banner(); + ESP_LOGCONFIG(TAG, "Setting up UART..."); + if (!this->get_hw_serial_()) { + ESP_LOGCONFIG( + TAG, + "No HardwareSerial was provided. " + "Software serial ports are unsupported by this component." + ); + this->mark_failed(); + return; + } + this->check_logger_conflict_(); ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); this->spa = new balboaGL(hw_serial_, 18, 22); @@ -408,6 +408,7 @@ void BalboaGL::setup() { this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_AUTO; this->swing_mode = climate::CLIMATE_SWING_OFF; + this->action = climate::CLIMATE_ACTION_HEATING; // #ifdef USE_CALLBACKS // hp->setSettingsChangedCallback( From cfd6e5a0d0e08d79b7410a23c4669898264eed9b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:43:29 +0100 Subject: [PATCH 070/378] Add check_logger_conflict_ back in --- components/BalboaGL/ESPBalboaGL.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f5bf403..09f595a 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -21,16 +21,16 @@ BalboaGL::BalboaGL( this->traits_.set_visual_temperature_step(0.5); } -// void BalboaGL::check_logger_conflict_() { -// #ifdef USE_LOGGER -// if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) { -// ESP_LOGW(TAG, " You're using the same serial port for logging" -// " and the BalboaGL component. Please disable" -// " logging over the serial port by setting" -// " logger:baud_rate to 0."); -// } -// #endif -// } +void BalboaGL::check_logger_conflict_() { +#ifdef USE_LOGGER + if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) { + ESP_LOGW(TAG, " You're using the same serial port for logging" + " and the BalboaGL component. Please disable" + " logging over the serial port by setting" + " logger:baud_rate to 0."); + } +#endif +} void BalboaGL::update() { ESP_LOGV(TAG, "Update called."); @@ -389,7 +389,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { void BalboaGL::setup() { // This will be called by App.setup() - this->banner(); + // this->banner(); ESP_LOGCONFIG(TAG, "Setting up UART..."); if (!this->get_hw_serial_()) { ESP_LOGCONFIG( From 67e2075ebc8d38c80dbe64c0b2ce11b3eb4a8d5b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 15:49:21 +0100 Subject: [PATCH 071/378] Add check_logger_conflict_ back in --- components/BalboaGL/ESPBalboaGL.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index b5491b7..93a57ee 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -77,6 +77,15 @@ class BalboaGL : public PollingComponent, public climate::Climate { // The ClimateTraits supported by this HeatPump. climate::ClimateTraits traits_; + //Accessor method for the HardwareSerial pointer + HardwareSerial* get_hw_serial_() { + return this->hw_serial_; + } + + //Print a warning message if we're using the sole hardware UART on an + //ESP8266 or UART0 on ESP32 + void check_logger_conflict_(); + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From 6bb8aa3afacc5f7651101ce32edf3583155c8217 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 16:01:07 +0100 Subject: [PATCH 072/378] Tweaks --- components/BalboaGL/ESPBalboaGL.cpp | 7 +++---- components/BalboaGL/climate.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 09f595a..447d8f7 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -33,11 +33,10 @@ void BalboaGL::check_logger_conflict_() { } void BalboaGL::update() { - ESP_LOGV(TAG, "Update called."); + // This will be called every "update_interval" milliseconds. + ESP_LOGI(TAG, "Update called."); this->spa->readSerial(); -// // This will be called every "update_interval" milliseconds. // //this->dump_config(); -// this->hp->sync(); // #ifndef USE_CALLBACKS // this->hpSettingsChanged(); // heatpumpStatus currentStatus = hp->getStatus(); @@ -217,7 +216,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // } // ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); -// // send the update back to esphome: + // send the update back to esphome: this->publish_state(); // // and the heat pump: // hp->update(); diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 5aeb921..8b6eaff 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -38,12 +38,11 @@ def valid_uart(uart): { cv.GenerateID(): cv.declare_id(BalboaGL), cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, -# cv.Optional(CONF_BAUD_RATE): cv.positive_int, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. -# cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( -# cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) -# ), + cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( + cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) + ), # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { From d3cf689201c891610c6453097c0786f5aad1f525 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 17:57:18 +0100 Subject: [PATCH 073/378] Pass status back --- components/BalboaGL/ESPBalboaGL.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 447d8f7..ecfb5fc 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -36,6 +36,8 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGI(TAG, "Update called."); this->spa->readSerial(); + this->current_temperature = status.temp; + this->target_temperature = status.targetTemp; // //this->dump_config(); // #ifndef USE_CALLBACKS // this->hpSettingsChanged(); From 8ebc2e21f6d906365f34d53cadf2ecfb8a45f9cf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 17:57:21 +0100 Subject: [PATCH 074/378] Pass status back --- components/BalboaGL/ESPBalboaGL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index ecfb5fc..05f9ccf 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,6 +38,7 @@ void BalboaGL::update() { this->spa->readSerial(); this->current_temperature = status.temp; this->target_temperature = status.targetTemp; + this->publish_state(); // //this->dump_config(); // #ifndef USE_CALLBACKS // this->hpSettingsChanged(); From 4a17939d8dced03087efe9074e7b27cefac93648 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:15:36 +0100 Subject: [PATCH 075/378] Configure serial port --- components/BalboaGL/ESPBalboaGL.cpp | 5 ++++- components/BalboaGL/ESPBalboaGL.h | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 05f9ccf..fb10228 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -405,7 +405,10 @@ void BalboaGL::setup() { this->check_logger_conflict_(); ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - this->spa = new balboaGL(hw_serial_, 18, 22); + + hw_serial_.begin(115200, SERIAL_8N1, RX_PIN_DEF, TX_PIN_DEF); + + this->spa = new balboaGL(hw_serial_, RTS_PIN_DEF, PIN_5_PIN_DEF); this->current_temperature = NAN; this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_AUTO; diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 93a57ee..e534772 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -24,12 +24,11 @@ static const char* TAG = "BalboaGL"; // Logging tag const uint32_t POLL_INTERVAL_DEFAULT = 10000; -#define tub Serial2 -#define RX_PIN 19 -#define TX_PIN 23 -// #define RTS_PIN 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. -// #define PIN_5_PIN 18 -#define LED_BUILTIN 2 +// TODO: hard coded values for T-RSC3 +#define RX_PIN_DEF 3 +#define TX_PIN_DEF 10 +#define RTS_PIN_DEF 5 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. +#define PIN_5_PIN_DEF 6 #include "balboaGL.h" From 1b754ec3fe36599a8572360548decb2593cecfc2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:16:52 +0100 Subject: [PATCH 076/378] Configure serial port --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index fb10228..5674d70 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -406,7 +406,7 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - hw_serial_.begin(115200, SERIAL_8N1, RX_PIN_DEF, TX_PIN_DEF); + hw_serial_->begin(115200, SERIAL_8N1, RX_PIN_DEF, TX_PIN_DEF); this->spa = new balboaGL(hw_serial_, RTS_PIN_DEF, PIN_5_PIN_DEF); this->current_temperature = NAN; From 0f6288d201998e1e7f521249cfee7648c3717da5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:33:00 +0100 Subject: [PATCH 077/378] Send heater status as mode --- components/BalboaGL/ESPBalboaGL.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 5674d70..852b348 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,6 +38,12 @@ void BalboaGL::update() { this->spa->readSerial(); this->current_temperature = status.temp; this->target_temperature = status.targetTemp; + if(status.heater) { + this->mode = climate::CLIMATE_MODE_HEAT; + } + else { + this->mode = climate::CLIMATE_MODE_AUTO; + } this->publish_state(); // //this->dump_config(); // #ifndef USE_CALLBACKS From ebc1d92a596349d0855119e56504439796294934 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:46:42 +0100 Subject: [PATCH 078/378] No fans --- components/BalboaGL/ESPBalboaGL.cpp | 37 ----------------------------- 1 file changed, 37 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 852b348..68f720f 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -165,43 +165,6 @@ void BalboaGL::control(const climate::ClimateCall &call) { // updated = true; // } -// //const char* FAN_MAP[6] = {"AUTO", "QUIET", "1", "2", "3", "4"}; -// if (call.get_fan_mode().has_value()) { -// ESP_LOGV("control", "Requested fan mode is %s", *call.get_fan_mode()); -// this->fan_mode = *call.get_fan_mode(); -// switch(*call.get_fan_mode()) { -// case climate::CLIMATE_FAN_OFF: -// hp->setPowerSetting("OFF"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_DIFFUSE: -// hp->setFanSpeed("QUIET"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_LOW: -// hp->setFanSpeed("1"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_MEDIUM: -// hp->setFanSpeed("2"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_MIDDLE: -// hp->setFanSpeed("3"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_HIGH: -// hp->setFanSpeed("4"); -// updated = true; -// break; -// case climate::CLIMATE_FAN_ON: -// case climate::CLIMATE_FAN_AUTO: -// default: -// hp->setFanSpeed("AUTO"); -// updated = true; -// break; -// } -// } // //const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; // if (call.get_swing_mode().has_value()) { From b4b2ee21d0be47077d0faaf8e7b56bccf6ba77a7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:48:05 +0100 Subject: [PATCH 079/378] No swing --- components/BalboaGL/ESPBalboaGL.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 68f720f..54b545e 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -166,26 +166,6 @@ void BalboaGL::control(const climate::ClimateCall &call) { // } -// //const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; -// if (call.get_swing_mode().has_value()) { -// ESP_LOGV(TAG, "control - requested swing mode is %s", -// *call.get_swing_mode()); - -// this->swing_mode = *call.get_swing_mode(); -// switch(*call.get_swing_mode()) { -// case climate::CLIMATE_SWING_OFF: -// hp->setVaneSetting("AUTO"); -// updated = true; -// break; -// case climate::CLIMATE_SWING_VERTICAL: -// hp->setVaneSetting("SWING"); -// updated = true; -// break; -// default: -// ESP_LOGW(TAG, "control - received unsupported swing mode request."); - -// } -// } // ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); // send the update back to esphome: From 7a179d111d66796cf24ebab37d22c497757972d2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:49:32 +0100 Subject: [PATCH 080/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 54b545e..5c91e83 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -364,19 +364,6 @@ void BalboaGL::setup() { this->swing_mode = climate::CLIMATE_SWING_OFF; this->action = climate::CLIMATE_ACTION_HEATING; -// #ifdef USE_CALLBACKS -// hp->setSettingsChangedCallback( -// [this]() { -// this->hpSettingsChanged(); -// } -// ); - -// hp->setStatusChangedCallback( -// [this](heatpumpStatus currentStatus) { -// this->hpStatusChanged(currentStatus); -// } -// ); -// #endif // ESP_LOGCONFIG( // TAG, From a940bacc2e843bcb906ee7f22fe885e077a667ce Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:51:37 +0100 Subject: [PATCH 081/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 5c91e83..8eec9bb 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -45,12 +45,6 @@ void BalboaGL::update() { this->mode = climate::CLIMATE_MODE_AUTO; } this->publish_state(); -// //this->dump_config(); -// #ifndef USE_CALLBACKS -// this->hpSettingsChanged(); -// heatpumpStatus currentStatus = hp->getStatus(); -// this->hpStatusChanged(currentStatus); -// #endif } // /** From 886b16c876e5a91bd73b5e2654e10e919a3401a4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:54:14 +0100 Subject: [PATCH 082/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 8eec9bb..8e5cdd6 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,6 +38,7 @@ void BalboaGL::update() { this->spa->readSerial(); this->current_temperature = status.temp; this->target_temperature = status.targetTemp; + this->custom_preset = status.mode; if(status.heater) { this->mode = climate::CLIMATE_MODE_HEAT; } From 79658fb281b4bba3eb0171d0a90e1f036ba8b99f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 18:59:56 +0100 Subject: [PATCH 083/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 8e5cdd6..639a70b 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,6 +38,20 @@ void BalboaGL::update() { this->spa->readSerial(); this->current_temperature = status.temp; this->target_temperature = status.targetTemp; + switch(status.mode) { + case MODE_IDX_STD: + this->custom_preset = "STD"; + break; + case MODE_IDX_ECO: + this->custom_preset = "ECO"; + break; + case MODE_IDX_SLP: + this->custom_preset = "Sleep"; + break; + default: + this->custom_preset = "UNKNOWN"; + break; + } this->custom_preset = status.mode; if(status.heater) { this->mode = climate::CLIMATE_MODE_HEAT; From b6bff21da9c895d7b4ef2be99f74b02b0d6cf36f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:00:34 +0100 Subject: [PATCH 084/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 639a70b..d97f515 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -52,7 +52,7 @@ void BalboaGL::update() { this->custom_preset = "UNKNOWN"; break; } - this->custom_preset = status.mode; + if(status.heater) { this->mode = climate::CLIMATE_MODE_HEAT; } From 07425db109f88c74cc998b272a178055857adc08 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:01:52 +0100 Subject: [PATCH 085/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index d97f515..026df93 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,16 +40,16 @@ void BalboaGL::update() { this->target_temperature = status.targetTemp; switch(status.mode) { case MODE_IDX_STD: - this->custom_preset = "STD"; + this->custom_preset = "STD".c_str(); break; case MODE_IDX_ECO: - this->custom_preset = "ECO"; + this->custom_preset = "ECO".c_str(); break; case MODE_IDX_SLP: - this->custom_preset = "Sleep"; + this->custom_preset = "Sleep".c_str(); break; default: - this->custom_preset = "UNKNOWN"; + this->custom_preset = "UNKNOWN".c_str(); break; } From 42c7eaccb3b66aef86ee4f73d20990f06cfe8bc8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:05:25 +0100 Subject: [PATCH 086/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 026df93..2238385 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,16 +40,16 @@ void BalboaGL::update() { this->target_temperature = status.targetTemp; switch(status.mode) { case MODE_IDX_STD: - this->custom_preset = "STD".c_str(); + this->custom_preset string("STD"); break; case MODE_IDX_ECO: - this->custom_preset = "ECO".c_str(); + this->custom_preset = string("ECO"); break; case MODE_IDX_SLP: - this->custom_preset = "Sleep".c_str(); + this->custom_preset = string("Sleep"); break; default: - this->custom_preset = "UNKNOWN".c_str(); + this->custom_preset = string("UNKNOWN"); break; } From 921f5b5b4921e3897f10047ad4c6c08b06dc5f97 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:05:57 +0100 Subject: [PATCH 087/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2238385..cfba7db 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,7 +40,7 @@ void BalboaGL::update() { this->target_temperature = status.targetTemp; switch(status.mode) { case MODE_IDX_STD: - this->custom_preset string("STD"); + this->custom_preset = string("STD"); break; case MODE_IDX_ECO: this->custom_preset = string("ECO"); From de42e12ac8043c9a49427c06fad41cbdfeecd8a1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:07:19 +0100 Subject: [PATCH 088/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index cfba7db..c79f22c 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -1,3 +1,4 @@ +#include #include "ESPBalboaGL.h" using namespace esphome; @@ -40,16 +41,16 @@ void BalboaGL::update() { this->target_temperature = status.targetTemp; switch(status.mode) { case MODE_IDX_STD: - this->custom_preset = string("STD"); + this->custom_preset = std::string("STD"); break; case MODE_IDX_ECO: - this->custom_preset = string("ECO"); + this->custom_preset = std:string("ECO"); break; case MODE_IDX_SLP: - this->custom_preset = string("Sleep"); + this->custom_preset = std::string("Sleep"); break; default: - this->custom_preset = string("UNKNOWN"); + this->custom_preset = std::string("UNKNOWN"); break; } From b96bb4a33456d275564e03f184fcfbe6874693a1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:07:46 +0100 Subject: [PATCH 089/378] pass custom_preset --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index c79f22c..6dbb992 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -44,7 +44,7 @@ void BalboaGL::update() { this->custom_preset = std::string("STD"); break; case MODE_IDX_ECO: - this->custom_preset = std:string("ECO"); + this->custom_preset = std::string("ECO"); break; case MODE_IDX_SLP: this->custom_preset = std::string("Sleep"); From ced3f4bf866faf302b99733506b925556de5f510 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:16:50 +0100 Subject: [PATCH 090/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 6dbb992..016d51e 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -441,4 +441,18 @@ void BalboaGL::setup() { // void BalboaGL::dump_state() { // LOG_CLIMATE("", "BalboaGL Climate", this); // ESP_LOGI(TAG, "HELLO"); -// } \ No newline at end of file +// } + +class BalboaGLSensor : public PollingComponent { + public: + Sensor *status_sensor = new Sensor(); + + MyCustomSensor() : PollingComponent(15000) { } + + void setup() override { + } + + void update() override { + status_sensor->publish_state(status.state); + } +}; \ No newline at end of file From d69f2208a75789e30b068d38608872f6d2cc867b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:18:57 +0100 Subject: [PATCH 091/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 016d51e..67b0dd6 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -447,7 +447,7 @@ class BalboaGLSensor : public PollingComponent { public: Sensor *status_sensor = new Sensor(); - MyCustomSensor() : PollingComponent(15000) { } + BalboaGLSensor() : PollingComponent(15000) { } void setup() override { } From 368a33f1dcfcae5c6cfcae5d2462367148554ed2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:21:17 +0100 Subject: [PATCH 092/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index e534772..5f88cde 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,5 +1,6 @@ #include "esphome.h" #include "esphome/core/preferences.h" +#include "esphome/components/sensor/sensor.h" #include "esphome/components/climate/climate.h" From 4739bef3120e125b861d7512bcb651ed55d6d207 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:34:41 +0100 Subject: [PATCH 093/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 67b0dd6..78e990d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -443,6 +443,8 @@ void BalboaGL::setup() { // ESP_LOGI(TAG, "HELLO"); // } +using namespace sensor; + class BalboaGLSensor : public PollingComponent { public: Sensor *status_sensor = new Sensor(); From a72c925c5b3e844764fc5b14e260bb1bfe87e79f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:37:04 +0100 Subject: [PATCH 094/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- components/BalboaGL/ESPBalboaGL.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 78e990d..f22b5aa 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -443,11 +443,11 @@ void BalboaGL::setup() { // ESP_LOGI(TAG, "HELLO"); // } -using namespace sensor; +using namespace text_sensor; class BalboaGLSensor : public PollingComponent { public: - Sensor *status_sensor = new Sensor(); + TextSensor *status_sensor = new TextSensor(); BalboaGLSensor() : PollingComponent(15000) { } diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 5f88cde..4020cfb 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,6 +1,7 @@ #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" From fc6acda703632465c118fefb4f22121488cba829 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:38:28 +0100 Subject: [PATCH 095/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f22b5aa..fabd564 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -455,6 +455,6 @@ class BalboaGLSensor : public PollingComponent { } void update() override { - status_sensor->publish_state(status.state); + status_sensor->publish_state(std::string(status.state)); } }; \ No newline at end of file From 87b95cc252443b00aa1ca90f9ad07d8682e23c11 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:39:16 +0100 Subject: [PATCH 096/378] Add BalboaGLSensor --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index fabd564..1f39a45 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -455,6 +455,6 @@ class BalboaGLSensor : public PollingComponent { } void update() override { - status_sensor->publish_state(std::string(status.state)); + status_sensor->publish_state(status.state.c_str()); } }; \ No newline at end of file From 7b4170e5b7ef12fcf3f066075094ac65534af200 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:43:21 +0100 Subject: [PATCH 097/378] Add BalboaGLSensor --- components/BalboaGL/text_sensor.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 components/BalboaGL/text_sensor.py diff --git a/components/BalboaGL/text_sensor.py b/components/BalboaGL/text_sensor.py new file mode 100644 index 0000000..6f551d5 --- /dev/null +++ b/components/BalboaGL/text_sensor.py @@ -0,0 +1,18 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import text_sensor +from esphome.const import CONF_ID + +balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') +BalboaGLSensor = balboa_sensor_ns.class_('BalboaGLSensor', text_sensor.TextSensor, cg.Component) + +CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(BalboaGLSensor) +}).extend(cv.COMPONENT_SCHEMA) + + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield text_sensor.register_text_sensor(var, config) + yield cg.register_component(var, config) + From 8d4f6e0db8b58b16f505a3cf45128f2adcd26b16 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 19:52:34 +0100 Subject: [PATCH 098/378] Create BalboaGLSensor component --- components/BalboaGLSensor/__init__.py | 0 components/{BalboaGL => BalboaGLSensor}/text_sensor.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 components/BalboaGLSensor/__init__.py rename components/{BalboaGL => BalboaGLSensor}/text_sensor.py (100%) diff --git a/components/BalboaGLSensor/__init__.py b/components/BalboaGLSensor/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/components/BalboaGL/text_sensor.py b/components/BalboaGLSensor/text_sensor.py similarity index 100% rename from components/BalboaGL/text_sensor.py rename to components/BalboaGLSensor/text_sensor.py From b47ca63a7e9d80c2d4068b79ac989a7095436a40 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:14:12 +0100 Subject: [PATCH 099/378] Create BalboaGLSensor component --- components/BalboaGL/ESPBalboaGL.cpp | 16 ---------------- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 17 +++++++++++++++++ components/BalboaGLSensor/ESPBalboaGLSensor.h | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 components/BalboaGLSensor/ESPBalboaGLSensor.cpp create mode 100644 components/BalboaGLSensor/ESPBalboaGLSensor.h diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 1f39a45..cb6c286 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -442,19 +442,3 @@ void BalboaGL::setup() { // LOG_CLIMATE("", "BalboaGL Climate", this); // ESP_LOGI(TAG, "HELLO"); // } - -using namespace text_sensor; - -class BalboaGLSensor : public PollingComponent { - public: - TextSensor *status_sensor = new TextSensor(); - - BalboaGLSensor() : PollingComponent(15000) { } - - void setup() override { - } - - void update() override { - status_sensor->publish_state(status.state.c_str()); - } -}; \ No newline at end of file diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp new file mode 100644 index 0000000..ca361f3 --- /dev/null +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -0,0 +1,17 @@ +#include + +using namespace text_sensor; + +class BalboaGLSensor : public PollingComponent { + public: + TextSensor *status_sensor = new TextSensor(); + + BalboaGLSensor() : PollingComponent(15000) { } + + void setup() override { + } + + void update() override { + status_sensor->publish_state(status.state.c_str()); + } +}; diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h new file mode 100644 index 0000000..604052f --- /dev/null +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -0,0 +1,14 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/components/text_sensor/text_sensor.h" + +namespace esphome { + +class BalboaGLSensor : public text_sensor::TextSensor, public Component { + public: + void setup() override; + void update() override; +}; + +} // namespace esphome From 478aaaac3b610af3a46db23deaf87cdf0627c3af Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:16:08 +0100 Subject: [PATCH 100/378] Creating BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index ca361f3..ac2943d 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -1,4 +1,5 @@ #include +#include "ESPBalboaGLSensor.h" using namespace text_sensor; From 0de06c308bb76712a71152249409a9adeb9bf9fc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:21:42 +0100 Subject: [PATCH 101/378] Creating BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 17 ++++++----------- components/BalboaGLSensor/ESPBalboaGLSensor.h | 6 +++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index ac2943d..7be142b 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -3,16 +3,11 @@ using namespace text_sensor; -class BalboaGLSensor : public PollingComponent { - public: - TextSensor *status_sensor = new TextSensor(); +BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } - BalboaGLSensor() : PollingComponent(15000) { } +void BalboaGLSensor::setup() { +} - void setup() override { - } - - void update() override { - status_sensor->publish_state(status.state.c_str()); - } -}; +void BalboaGLSensor::update() { + status_sensor->publish_state(status.state.c_str()); +} diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 604052f..595dc4b 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -5,10 +5,14 @@ namespace esphome { -class BalboaGLSensor : public text_sensor::TextSensor, public Component { +using namespace text_sensor; + +class BalboaGLSensor : public TextSensor, public Component { public: void setup() override; void update() override; + TextSensor *status_sensor = new TextSensor(); + }; } // namespace esphome From f97d207465581bb2c9dce2b34a6f7a17735eafaa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:23:07 +0100 Subject: [PATCH 102/378] Creating BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 7be142b..05a6ffd 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -1,7 +1,6 @@ #include #include "ESPBalboaGLSensor.h" -using namespace text_sensor; BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } From 989abec33f4a56d3fd701c4edfbf8bf92c9b4669 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:23:52 +0100 Subject: [PATCH 103/378] Creating BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 05a6ffd..15a9463 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -1,5 +1,6 @@ #include #include "ESPBalboaGLSensor.h" +#include "balboaGL.h" BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } From e57762d2fc950c08f2786ad7463d27e734ccad17 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:33:06 +0100 Subject: [PATCH 104/378] Creating BalboaGLSensor --- .../BalboaGLSensor/ESPBalboaGLSensor.cpp | 16 ++++++++++------ components/BalboaGLSensor/ESPBalboaGLSensor.h | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 15a9463..779e257 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -2,12 +2,16 @@ #include "ESPBalboaGLSensor.h" #include "balboaGL.h" +namespace esphome { + namespace empty_text_sensor { -BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } + BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } -void BalboaGLSensor::setup() { -} + void BalboaGLSensor::setup() { + } -void BalboaGLSensor::update() { - status_sensor->publish_state(status.state.c_str()); -} + void BalboaGLSensor::update() { + status_sensor->publish_state(status.state.c_str()); + } + } +} \ No newline at end of file diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 595dc4b..b79582b 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -4,15 +4,17 @@ #include "esphome/components/text_sensor/text_sensor.h" namespace esphome { + namespace empty_text_sensor { -using namespace text_sensor; + using namespace text_sensor; -class BalboaGLSensor : public TextSensor, public Component { - public: - void setup() override; - void update() override; - TextSensor *status_sensor = new TextSensor(); + class BalboaGLSensor : public TextSensor, public Component { + public: + void setup() override; + void update() override; + TextSensor *status_sensor = new TextSensor(); -}; + }; -} // namespace esphome + } +} From d7e03731c658a0581b2fd526347d55abcc9f9489 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:37:13 +0100 Subject: [PATCH 105/378] Creating BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 779e257..beca214 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -5,7 +5,7 @@ namespace esphome { namespace empty_text_sensor { - BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } +// BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } void BalboaGLSensor::setup() { } From 25ff57ffb0c5007f0052712fac78432d4aab0c27 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:41:48 +0100 Subject: [PATCH 106/378] Fix namespace --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 2 +- components/BalboaGLSensor/ESPBalboaGLSensor.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index beca214..dec12a9 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -3,7 +3,7 @@ #include "balboaGL.h" namespace esphome { - namespace empty_text_sensor { + namespace balboa_sensor { // BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index b79582b..e205a8b 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -4,7 +4,7 @@ #include "esphome/components/text_sensor/text_sensor.h" namespace esphome { - namespace empty_text_sensor { + namespace balboa_sensor { using namespace text_sensor; From 4852fd68528a9099d708b3a01441754f8f338b7e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:43:11 +0100 Subject: [PATCH 107/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index e205a8b..31fdcb7 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -9,10 +9,10 @@ namespace esphome { using namespace text_sensor; class BalboaGLSensor : public TextSensor, public Component { - public: - void setup() override; - void update() override; - TextSensor *status_sensor = new TextSensor(); + public: + void setup(); + void update(); + TextSensor *status_sensor = new TextSensor(); }; From 9dd7598757e93f14a05f03bf0abd0c0ef9e7acac Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:51:31 +0100 Subject: [PATCH 108/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 5 ++--- components/BalboaGLSensor/ESPBalboaGLSensor.h | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index dec12a9..9cba680 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -5,13 +5,12 @@ namespace esphome { namespace balboa_sensor { -// BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } - void BalboaGLSensor::setup() { } void BalboaGLSensor::update() { - status_sensor->publish_state(status.state.c_str()); + std::string state = "test"; + status_sensor->publish_state(state); } } } \ No newline at end of file diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 31fdcb7..5b2abe2 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -10,6 +10,7 @@ namespace esphome { class BalboaGLSensor : public TextSensor, public Component { public: + BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } void setup(); void update(); TextSensor *status_sensor = new TextSensor(); From 3001489168cdcb6e071c020a1376a15f83199d29 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:52:45 +0100 Subject: [PATCH 109/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 5b2abe2..e898b59 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -10,7 +10,7 @@ namespace esphome { class BalboaGLSensor : public TextSensor, public Component { public: - BalboaGLSensor::BalboaGLSensor() : PollingComponent(15000) { } + BalboaGLSensor() : PollingComponent(15000) { } void setup(); void update(); TextSensor *status_sensor = new TextSensor(); From 98f91272492075b7668631271b3857f2f608d766 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:54:18 +0100 Subject: [PATCH 110/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index e898b59..7c8406f 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -1,6 +1,6 @@ #pragma once -#include "esphome/core/component.h" +#include "esphome/core/pollingcomponent.h" #include "esphome/components/text_sensor/text_sensor.h" namespace esphome { @@ -8,7 +8,7 @@ namespace esphome { using namespace text_sensor; - class BalboaGLSensor : public TextSensor, public Component { + class BalboaGLSensor : public TextSensor, public PollingComponent { public: BalboaGLSensor() : PollingComponent(15000) { } void setup(); From d171f0b7dc2d93545f62c3ac6f894a497d77f3bb Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 20:55:28 +0100 Subject: [PATCH 111/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 7c8406f..99025cb 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -1,6 +1,6 @@ #pragma once -#include "esphome/core/pollingcomponent.h" +#include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" namespace esphome { From 142ca242b84646e66678ef3e1b285b9218470cc8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:05:23 +0100 Subject: [PATCH 112/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 1 + components/BalboaGLSensor/ESPBalboaGLSensor.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 9cba680..46a5416 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -10,6 +10,7 @@ namespace esphome { void BalboaGLSensor::update() { std::string state = "test"; + ESP_LOGD(TAG, "status.state = " + status.state); status_sensor->publish_state(state); } } diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 99025cb..fcd7960 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -3,6 +3,8 @@ #include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" +static const char* TAG = "BalboaGLSensor"; // Logging tag + namespace esphome { namespace balboa_sensor { From 7c3f32987c2429a895bce977491d42b28ceff1fa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:06:15 +0100 Subject: [PATCH 113/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index fcd7960..a00cd47 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -3,11 +3,12 @@ #include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" -static const char* TAG = "BalboaGLSensor"; // Logging tag namespace esphome { namespace balboa_sensor { + static const char* TAG = "BalboaGLSensor"; // Logging tag + using namespace text_sensor; class BalboaGLSensor : public TextSensor, public PollingComponent { From ec80d5ef3ddda0a3815f21f4deb9453390ead8f0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:06:49 +0100 Subject: [PATCH 114/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 46a5416..8f36cf0 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -10,7 +10,7 @@ namespace esphome { void BalboaGLSensor::update() { std::string state = "test"; - ESP_LOGD(TAG, "status.state = " + status.state); + ESP_LOGD(TAG, "status.state = " + status.state.c_str()); status_sensor->publish_state(state); } } From f62bc7be988914e1eeb2cbd722a78a7b9588fb4b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:07:44 +0100 Subject: [PATCH 115/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 8f36cf0..bae36fe 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -10,7 +10,7 @@ namespace esphome { void BalboaGLSensor::update() { std::string state = "test"; - ESP_LOGD(TAG, "status.state = " + status.state.c_str()); + ESP_LOGD(TAG, std::string("status.state = " + status.state.c_str())); status_sensor->publish_state(state); } } From 5cb1bcd4f4ec72ef8f310b5ac8cb8ad87294025f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:08:24 +0100 Subject: [PATCH 116/378] BalboaGLSensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index bae36fe..0af848e 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -10,7 +10,7 @@ namespace esphome { void BalboaGLSensor::update() { std::string state = "test"; - ESP_LOGD(TAG, std::string("status.state = " + status.state.c_str())); + ESP_LOGD(TAG, status.state.c_str()); status_sensor->publish_state(state); } } From 814d8045d8d4920ab992c78b4c68618427d65fc9 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:15:06 +0100 Subject: [PATCH 117/378] BalboaGLSensor - add raw_sensor --- components/BalboaGLSensor/ESPBalboaGLSensor.cpp | 1 + components/BalboaGLSensor/ESPBalboaGLSensor.h | 1 + 2 files changed, 2 insertions(+) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp index 0af848e..b66ae73 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp @@ -12,6 +12,7 @@ namespace esphome { std::string state = "test"; ESP_LOGD(TAG, status.state.c_str()); status_sensor->publish_state(state); + raw_sensor->publish_state(status.rawData.c_str()); } } } \ No newline at end of file diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index a00cd47..715524c 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -17,6 +17,7 @@ namespace esphome { void setup(); void update(); TextSensor *status_sensor = new TextSensor(); + TextSensor *raw_sensor = new TextSensor(); }; From 20bb24a67a89b198b4fc5311980a058784ab4a99 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:33:44 +0100 Subject: [PATCH 118/378] BalboaGLSensor - define multiple sensors --- .../BalboaGLSensor/ESPBalboaGLSensor.cpp | 18 --------------- components/BalboaGLSensor/ESPBalboaGLSensor.h | 22 ++++++++++++++----- components/BalboaGLSensor/text_sensor.py | 18 +++++++++++---- 3 files changed, 31 insertions(+), 27 deletions(-) delete mode 100644 components/BalboaGLSensor/ESPBalboaGLSensor.cpp diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp b/components/BalboaGLSensor/ESPBalboaGLSensor.cpp deleted file mode 100644 index b66ae73..0000000 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include "ESPBalboaGLSensor.h" -#include "balboaGL.h" - -namespace esphome { - namespace balboa_sensor { - - void BalboaGLSensor::setup() { - } - - void BalboaGLSensor::update() { - std::string state = "test"; - ESP_LOGD(TAG, status.state.c_str()); - status_sensor->publish_state(state); - raw_sensor->publish_state(status.rawData.c_str()); - } - } -} \ No newline at end of file diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 715524c..79fd2f2 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -11,13 +11,25 @@ namespace esphome { using namespace text_sensor; - class BalboaGLSensor : public TextSensor, public PollingComponent { + class BalboaGLStateSensor : public TextSensor, public PollingComponent { public: - BalboaGLSensor() : PollingComponent(15000) { } + BalboaGLStateSensor() : PollingComponent(15000) { } void setup(); - void update(); - TextSensor *status_sensor = new TextSensor(); - TextSensor *raw_sensor = new TextSensor(); + void update() { + std::string state = "test"; + ESP_LOGD(TAG, status.state.c_str()); + this->publish_state(state); + } + + }; + + class BalboaGLRawSensor : public TextSensor, public PollingComponent { + public: + BalboaGLStateSensor() : PollingComponent(15000) { } + void setup(); + void update() { + this->publish_state(status.rawData.c_str()); + } }; diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index 6f551d5..4627817 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -4,13 +4,23 @@ from esphome.const import CONF_ID balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') -BalboaGLSensor = balboa_sensor_ns.class_('BalboaGLSensor', text_sensor.TextSensor, cg.Component) +StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) +RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(BalboaGLSensor) -}).extend(cv.COMPONENT_SCHEMA) +# CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({ +# cv.GenerateID(): cv.declare_id(BalboaGLSensor) +# }).extend(cv.COMPONENT_SCHEMA) +CONFIG_SCHEMA = cv.Schema({ + cv.Optional("state"): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(StateInfo), + }), + cv.Optional("raw"): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(RawInfo), + }), +}) + def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield text_sensor.register_text_sensor(var, config) From f06d51a15b43919bbdd85b0d2ac422c344bc0496 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:37:28 +0100 Subject: [PATCH 119/378] BalboaGLSensor - define multiple sensors --- components/BalboaGLSensor/text_sensor.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index 4627817..59da043 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -3,6 +3,10 @@ from esphome.components import text_sensor from esphome.const import CONF_ID +CONF_STATE = "state" +CONF_RAW = "raw" + + balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) @@ -13,16 +17,15 @@ CONFIG_SCHEMA = cv.Schema({ - cv.Optional("state"): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.Optional(CONF_STATE): text_sensor.TEXT_SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(StateInfo), }), - cv.Optional("raw"): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(RawInfo), }), }) def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - yield text_sensor.register_text_sensor(var, config) - yield cg.register_component(var, config) + yield setup_conf(config, CONF_STATE) + yield setup_conf(config, CONF_RAW) From d6c1b071392a16dfd11cfec982e79ef081ea763e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:38:27 +0100 Subject: [PATCH 120/378] BalboaGLSensor - define multiple sensors --- components/BalboaGLSensor/text_sensor.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index 59da043..cac143a 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -25,6 +25,14 @@ }), }) +@coroutine +def setup_conf(config, key): + if key in config: + conf = config[key] + var = cg.new_Pvariable(conf[CONF_ID]) + yield cg.register_component(var, conf) + yield text_sensor.register_text_sensor(var, conf) + def to_code(config): yield setup_conf(config, CONF_STATE) yield setup_conf(config, CONF_RAW) From ade6c3f4f252c046c806ae3cc05ff37f808f183f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:40:38 +0100 Subject: [PATCH 121/378] BalboaGLSensor - define multiple sensors --- components/BalboaGLSensor/text_sensor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index cac143a..c9efc31 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -2,6 +2,7 @@ import esphome.config_validation as cv from esphome.components import text_sensor from esphome.const import CONF_ID +from esphome.core import coroutine CONF_STATE = "state" CONF_RAW = "raw" From 0e053d0c753fc1b294d536d0677d508489942535 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 21:41:53 +0100 Subject: [PATCH 122/378] BalboaGLSensor - define multiple sensors --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 4 ++-- components/BalboaGLSensor/text_sensor.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 79fd2f2..052d070 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -22,10 +22,10 @@ namespace esphome { } }; - + class BalboaGLRawSensor : public TextSensor, public PollingComponent { public: - BalboaGLStateSensor() : PollingComponent(15000) { } + BalboaGLRawSensor() : PollingComponent(15000) { } void setup(); void update() { this->publish_state(status.rawData.c_str()); diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index c9efc31..9284c56 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -33,7 +33,7 @@ def setup_conf(config, key): var = cg.new_Pvariable(conf[CONF_ID]) yield cg.register_component(var, conf) yield text_sensor.register_text_sensor(var, conf) - + def to_code(config): yield setup_conf(config, CONF_STATE) yield setup_conf(config, CONF_RAW) From d7124ba4759b5bd2af7f12d96b5df58e38ccb9d9 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 24 Sep 2023 22:39:16 +0100 Subject: [PATCH 123/378] remove setup --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 4 ++-- components/BalboaGLSensor/text_sensor.py | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 052d070..fe8f3ba 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -14,7 +14,7 @@ namespace esphome { class BalboaGLStateSensor : public TextSensor, public PollingComponent { public: BalboaGLStateSensor() : PollingComponent(15000) { } - void setup(); + // void setup() {}; void update() { std::string state = "test"; ESP_LOGD(TAG, status.state.c_str()); @@ -26,7 +26,7 @@ namespace esphome { class BalboaGLRawSensor : public TextSensor, public PollingComponent { public: BalboaGLRawSensor() : PollingComponent(15000) { } - void setup(); + // void setup() {}; void update() { this->publish_state(status.rawData.c_str()); } diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index 9284c56..4a4d4b7 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -12,11 +12,6 @@ StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -# CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend({ -# cv.GenerateID(): cv.declare_id(BalboaGLSensor) -# }).extend(cv.COMPONENT_SCHEMA) - - CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_STATE): text_sensor.TEXT_SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(StateInfo), From b47fc552f5a3a3799de988de438e22877cffbea0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:35:21 +0100 Subject: [PATCH 124/378] log panel select --- components/BalboaGL/ESPBalboaGL.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index cb6c286..eb2da3d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -37,6 +37,14 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGI(TAG, "Update called."); this->spa->readSerial(); + bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); + if(panelSelect == HIGH) { + ESP_LOGD(TAG, "PanelSelect == HIGH"); + } + else { + ESP_LOGD(TAG, "PanelSelect == LOw"); + } + this->current_temperature = status.temp; this->target_temperature = status.targetTemp; switch(status.mode) { From 44ff66411a6a6b227e4ab70658b10d935ff38cd1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:38:43 +0100 Subject: [PATCH 125/378] Selective update --- components/BalboaGL/ESPBalboaGL.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index eb2da3d..2b39208 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -68,7 +68,13 @@ void BalboaGL::update() { else { this->mode = climate::CLIMATE_MODE_AUTO; } - this->publish_state(); + + static String lastRaw = ""; + if(status.rawData != lastRaw) { + lastRaw = status.rawData; + this->publish_state(); + } + } // /** From 98eba08b6e506066640d05bcfdf9bebe8c8091c4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:43:01 +0100 Subject: [PATCH 126/378] log bytes --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- components/BalboaGL/climate.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2b39208..ea06e5c 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -36,7 +36,8 @@ void BalboaGL::check_logger_conflict_() { void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGI(TAG, "Update called."); - this->spa->readSerial(); + size_t len = this->spa->readSerial(); + ESP_LOGD(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGD(TAG, "PanelSelect == HIGH"); diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 8b6eaff..74e1bab 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -89,5 +89,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="c9231e1c7341ab2ff8a641810283732999e9cdbf", + version="7b03c4130247471701a97c88d0bc7879cc99e509", ) From c5390bf7ac1836974300a548bd39a3ecf08ba828 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:48:01 +0100 Subject: [PATCH 127/378] log bytes --- components/BalboaGL/climate.py | 2 +- components/BalboaGLSensor/ESPBalboaGLSensor.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 74e1bab..0fbd815 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -89,5 +89,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="7b03c4130247471701a97c88d0bc7879cc99e509", + version="99e703abd8c418a2d470bf8076f8d88a41fae7c8", ) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index fe8f3ba..a88ff65 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -16,8 +16,8 @@ namespace esphome { BalboaGLStateSensor() : PollingComponent(15000) { } // void setup() {}; void update() { - std::string state = "test"; - ESP_LOGD(TAG, status.state.c_str()); + std::string state = status.state.c_str(); + ESP_LOGD(TAG, state); this->publish_state(state); } From 82d1973ef2f4335c5275569a91e8f7cf338a5491 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:50:22 +0100 Subject: [PATCH 128/378] log bytes --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index a88ff65..277ffbc 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -17,8 +17,8 @@ namespace esphome { // void setup() {}; void update() { std::string state = status.state.c_str(); - ESP_LOGD(TAG, state); - this->publish_state(state); + ESP_LOGD(TAG, state.c_str()); + this->publish_state(state.c_str()); } }; From 10838d507cbfca0cd5505c9447c98722ec954182 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 12:55:06 +0100 Subject: [PATCH 129/378] Selective update --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index ea06e5c..313807d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -70,7 +70,7 @@ void BalboaGL::update() { this->mode = climate::CLIMATE_MODE_AUTO; } - static String lastRaw = ""; + static String lastRaw = "0"; if(status.rawData != lastRaw) { lastRaw = status.rawData; this->publish_state(); From dcf00f999e11111785e7675672d921dfb9e74b5b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 13:01:47 +0100 Subject: [PATCH 130/378] Selective update --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 313807d..4d8c16c 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -71,10 +71,10 @@ void BalboaGL::update() { } static String lastRaw = "0"; - if(status.rawData != lastRaw) { + // if(status.rawData != lastRaw) { lastRaw = status.rawData; this->publish_state(); - } + // } } From 88a855cc3b7b543027fe23336a278ef0a6bd7acf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 13:04:39 +0100 Subject: [PATCH 131/378] Selective update --- components/BalboaGL/ESPBalboaGL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 4d8c16c..5be4a8c 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -41,6 +41,7 @@ void BalboaGL::update() { bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGD(TAG, "PanelSelect == HIGH"); + return; } else { ESP_LOGD(TAG, "PanelSelect == LOw"); From f84c4f5dfac4c69e232036eb1a5346a0da2e23ba Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 15:57:19 +0100 Subject: [PATCH 132/378] log temp --- components/BalboaGL/ESPBalboaGL.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 5be4a8c..5f3682d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -37,7 +37,7 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGI(TAG, "Update called."); size_t len = this->spa->readSerial(); - ESP_LOGD(TAG, "Read %u bytes", len); + ESP_LOGV(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGD(TAG, "PanelSelect == HIGH"); @@ -47,6 +47,8 @@ void BalboaGL::update() { ESP_LOGD(TAG, "PanelSelect == LOw"); } + ESP_LOGD(TAG, "Current Temp: %f", status.temp); + ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); this->current_temperature = status.temp; this->target_temperature = status.targetTemp; switch(status.mode) { From f724f64d1d27d1d94c833c6ebf3e94d87f852be4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 15:59:44 +0100 Subject: [PATCH 133/378] set modes --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- components/BalboaGL/climate.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 5f3682d..fde28c5 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -388,9 +388,9 @@ void BalboaGL::setup() { this->spa = new balboaGL(hw_serial_, RTS_PIN_DEF, PIN_5_PIN_DEF); this->current_temperature = NAN; this->target_temperature = NAN; - this->fan_mode = climate::CLIMATE_FAN_AUTO; + this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; - this->action = climate::CLIMATE_ACTION_HEATING; + this->action = climate::CLIMATE_ACTION_AUTO; // ESP_LOGCONFIG( diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 0fbd815..7db595c 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -16,8 +16,8 @@ AUTO_LOAD = ["climate"] CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ["HEAT"] -DEFAULT_FAN_MODES = ["AUTO"] +DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] +DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] BalboaGL = cg.global_ns.class_( From 63a7e484f793de156ad4125249f066839b95b5ac Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 25 Sep 2023 21:49:06 +0100 Subject: [PATCH 134/378] fix action --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index fde28c5..526eeed 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -390,7 +390,7 @@ void BalboaGL::setup() { this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; - this->action = climate::CLIMATE_ACTION_AUTO; + this->action = climate::CLIMATE_ACTION_FAN; // ESP_LOGCONFIG( From 753c664908b38f31db37d930fe83246a6239e820 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:15:01 +0100 Subject: [PATCH 135/378] Add light switch --- components/BalboaGLSwitch/BalboaGLSwitch.h | 17 +++++++++++++++++ components/BalboaGLSwitch/__init__.py | 0 components/BalboaGLSwitch/switch.py | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 components/BalboaGLSwitch/BalboaGLSwitch.h create mode 100644 components/BalboaGLSwitch/__init__.py create mode 100644 components/BalboaGLSwitch/switch.py diff --git a/components/BalboaGLSwitch/BalboaGLSwitch.h b/components/BalboaGLSwitch/BalboaGLSwitch.h new file mode 100644 index 0000000..801c951 --- /dev/null +++ b/components/BalboaGLSwitch/BalboaGLSwitch.h @@ -0,0 +1,17 @@ +#include "esphome.h" + +class BalboaGLLightSwitch : public Component, public Switch { + public: + void setup() override { + // This will be called by App.setup() + // pinMode(5, INPUT); + } + void write_state(bool state) override { + // This will be called every time the user requests a state change. + + // digitalWrite(5, state); + + // Acknowledge new state by publishing it + // publish_state(state); + } +}; \ No newline at end of file diff --git a/components/BalboaGLSwitch/__init__.py b/components/BalboaGLSwitch/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/components/BalboaGLSwitch/switch.py b/components/BalboaGLSwitch/switch.py new file mode 100644 index 0000000..7fd1a2e --- /dev/null +++ b/components/BalboaGLSwitch/switch.py @@ -0,0 +1,16 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import switch +from esphome.const import CONF_ID + +empty_switch_ns = cg.esphome_ns.namespace('balboa_switch') +LightSwitch = empty_switch_ns.class_('BalboaGLLightSwitch', switch.Switch, cg.Component) + +CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(LightSwitch) +}).extend(cv.COMPONENT_SCHEMA) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + yield switch.register_switch(var, config) From 9743ebfe71f575d6d7c6acfa8034c501cc69f731 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:20:49 +0100 Subject: [PATCH 136/378] Add light switch --- components/BalboaGLSwitch/BalboaGLSwitch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGLSwitch/BalboaGLSwitch.h b/components/BalboaGLSwitch/BalboaGLSwitch.h index 801c951..a3e8d50 100644 --- a/components/BalboaGLSwitch/BalboaGLSwitch.h +++ b/components/BalboaGLSwitch/BalboaGLSwitch.h @@ -1,6 +1,7 @@ #include "esphome.h" -class BalboaGLLightSwitch : public Component, public Switch { + +class BalboaGLLightSwitch : public Component, public switch_::Switch { public: void setup() override { // This will be called by App.setup() From 1874666dd2e2e980a9a5cb8c9746c2f95d33bb2b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:22:56 +0100 Subject: [PATCH 137/378] Add light switch --- components/BalboaGLSwitch/BalboaGLSwitch.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSwitch/BalboaGLSwitch.h b/components/BalboaGLSwitch/BalboaGLSwitch.h index a3e8d50..f736ea7 100644 --- a/components/BalboaGLSwitch/BalboaGLSwitch.h +++ b/components/BalboaGLSwitch/BalboaGLSwitch.h @@ -1,5 +1,8 @@ -#include "esphome.h" +#include "esphome/core/component.h" +#include "esphome/components/switch/switch.h" +namespace esphome { + namespace balboa_switch { class BalboaGLLightSwitch : public Component, public switch_::Switch { public: @@ -15,4 +18,7 @@ class BalboaGLLightSwitch : public Component, public switch_::Switch { // Acknowledge new state by publishing it // publish_state(state); } -}; \ No newline at end of file +}; + + } +} \ No newline at end of file From 4cbb716c9a77add7a7413392740dec26932ddb27 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:43:01 +0100 Subject: [PATCH 138/378] Add select for pump1 --- components/BalboaGLSelect/BalboaGLSelect.h | 13 +++++++++++ components/BalboaGLSelect/__init__.py | 0 components/BalboaGLSelect/select.py | 16 +++++++++++++ components/BalboaGLSwitch/BalboaGLSwitch.h | 26 +++++++++++----------- 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 components/BalboaGLSelect/BalboaGLSelect.h create mode 100644 components/BalboaGLSelect/__init__.py create mode 100644 components/BalboaGLSelect/select.py diff --git a/components/BalboaGLSelect/BalboaGLSelect.h b/components/BalboaGLSelect/BalboaGLSelect.h new file mode 100644 index 0000000..6653d66 --- /dev/null +++ b/components/BalboaGLSelect/BalboaGLSelect.h @@ -0,0 +1,13 @@ +#include "esphome/core/component.h" +#include "esphome/components/select/select.h" + +namespace esphome { + namespace balboa_select { + + class BalboaGLPump1Select : public Component, public select::Select { + public: + + }; + + } +} \ No newline at end of file diff --git a/components/BalboaGLSelect/__init__.py b/components/BalboaGLSelect/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py new file mode 100644 index 0000000..ed9fd61 --- /dev/null +++ b/components/BalboaGLSelect/select.py @@ -0,0 +1,16 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import select +from esphome.const import CONF_ID + +empty_switch_ns = cg.esphome_ns.namespace('balboa_select') +Pump1Select = empty_switch_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) + +CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(LightSwitch) +}).extend(cv.COMPONENT_SCHEMA) + +def to_code(config): + var = cg.new_Pvariable(config[CONF_ID]) + yield cg.register_component(var, config) + yield switch.register_switch(var, config) diff --git a/components/BalboaGLSwitch/BalboaGLSwitch.h b/components/BalboaGLSwitch/BalboaGLSwitch.h index f736ea7..323c457 100644 --- a/components/BalboaGLSwitch/BalboaGLSwitch.h +++ b/components/BalboaGLSwitch/BalboaGLSwitch.h @@ -4,21 +4,21 @@ namespace esphome { namespace balboa_switch { -class BalboaGLLightSwitch : public Component, public switch_::Switch { - public: - void setup() override { - // This will be called by App.setup() - // pinMode(5, INPUT); - } - void write_state(bool state) override { - // This will be called every time the user requests a state change. + class BalboaGLLightSwitch : public Component, public switch_::Switch { + public: + void setup() override { + // This will be called by App.setup() + // pinMode(5, INPUT); + } + void write_state(bool state) override { + // This will be called every time the user requests a state change. - // digitalWrite(5, state); + // digitalWrite(5, state); - // Acknowledge new state by publishing it - // publish_state(state); - } -}; + // Acknowledge new state by publishing it + // publish_state(state); + } + }; } } \ No newline at end of file From 866be6a93ba2b2bdd6b5cb35ad253144e7d2a9b4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:45:01 +0100 Subject: [PATCH 139/378] Add select for pump1 --- components/BalboaGLSelect/select.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index ed9fd61..7f49028 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -3,14 +3,14 @@ from esphome.components import select from esphome.const import CONF_ID -empty_switch_ns = cg.esphome_ns.namespace('balboa_select') -Pump1Select = empty_switch_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) +select_ns = cg.esphome_ns.namespace('balboa_select') +Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) -CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(LightSwitch) +CONFIG_SCHEMA = select.SWITCH_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(Pump1Select) }).extend(cv.COMPONENT_SCHEMA) def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) - yield switch.register_switch(var, config) + yield select.tch.register_switch(var, config) From 407d53933d4e021c8cdf46772658dad273da7c91 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:46:52 +0100 Subject: [PATCH 140/378] Add select for pump1 --- components/BalboaGLSelect/select.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 7f49028..4a754ec 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -6,11 +6,11 @@ select_ns = cg.esphome_ns.namespace('balboa_select') Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) -CONFIG_SCHEMA = select.SWITCH_SCHEMA.extend({ +CONFIG_SCHEMA = select.SELECT_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(Pump1Select) }).extend(cv.COMPONENT_SCHEMA) def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) - yield select.tch.register_switch(var, config) + yield select.register_select(var, config) From 72ac6cbf69ffed8bba269609adf2b1417e1487f4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:48:55 +0100 Subject: [PATCH 141/378] Add select for pump1 --- components/BalboaGLSelect/select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 4a754ec..2fa4708 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -13,4 +13,4 @@ def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) - yield select.register_select(var, config) + yield select.register_select(var, config, {"OFF", "HIGH"}) From 07db65720385eb0fca4ab6b3781de970da6dc3df Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:49:55 +0100 Subject: [PATCH 142/378] Add select for pump1 --- components/BalboaGLSelect/select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 2fa4708..3e52170 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -13,4 +13,4 @@ def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) - yield select.register_select(var, config, {"OFF", "HIGH"}) + yield select.register_select(var, config, options={"OFF", "HIGH"}) From a1e4b12df4d46927107a38434df4d2df8f35b4ed Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 20:54:58 +0100 Subject: [PATCH 143/378] Add select for pump1 --- components/BalboaGLSelect/select.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 3e52170..e036b66 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -1,7 +1,10 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import select -from esphome.const import CONF_ID +from esphome.const import ( + CONF_ID, + CONF_OPTIONS, +) select_ns = cg.esphome_ns.namespace('balboa_select') Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) @@ -13,4 +16,4 @@ def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) yield cg.register_component(var, config) - yield select.register_select(var, config, options={"OFF", "HIGH"}) + yield select.register_select(var, config, options=config[CONF_OPTIONS]) From 43aade111f370aba88ad17597295e6afd2347bb6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 21:06:50 +0100 Subject: [PATCH 144/378] Add select for pump2 --- components/BalboaGLSelect/BalboaGLSelect.h | 5 +++ components/BalboaGLSelect/select.py | 38 ++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/components/BalboaGLSelect/BalboaGLSelect.h b/components/BalboaGLSelect/BalboaGLSelect.h index 6653d66..35e0213 100644 --- a/components/BalboaGLSelect/BalboaGLSelect.h +++ b/components/BalboaGLSelect/BalboaGLSelect.h @@ -9,5 +9,10 @@ namespace esphome { }; + class BalboaGLPump2Select : public Component, public select::Select { + public: + + }; + } } \ No newline at end of file diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index e036b66..e8aa973 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -5,15 +5,41 @@ CONF_ID, CONF_OPTIONS, ) +from esphome.core import coroutine + + +CONF_PUMP1 = "pump1" +CONF_PUMP2 = "pump2" select_ns = cg.esphome_ns.namespace('balboa_select') Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) +Pump2Select = select_ns.class_('BalboaGLPump2Select', select.Select, cg.Component) -CONFIG_SCHEMA = select.SELECT_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(Pump1Select) -}).extend(cv.COMPONENT_SCHEMA) +CONFIG_SCHEMA = cv.Schema({ + cv.Optional(CONF_PUMP1): select.SELECT_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(Pump1Select), + cv.Required(CONF_OPTIONS): cv.All( + cv.ensure_list(cv.string_strict), cv.Length(min=1) + ), + }), + cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(Pump1Select), + cv.Required(CONF_OPTIONS): cv.All( + cv.ensure_list(cv.string_strict), cv.Length(min=1) + ), + }), + +}) + +@coroutine +def setup_conf(config, key): + if key in config: + conf = config[key] + var = cg.new_Pvariable(conf[CONF_ID]) + yield cg.register_component(var, conf) + yield select.register_select(var, config, options=config[CONF_OPTIONS]) def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield select.register_select(var, config, options=config[CONF_OPTIONS]) + yield setup_conf(config, CONF_PUMP1) + yield setup_conf(config, CONF_PUMP2) + From 302f625429dd83f4360c53ab0c64ef8fa5f46175 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 21:08:34 +0100 Subject: [PATCH 145/378] Add select for pump2 --- components/BalboaGLSelect/select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index e8aa973..217c8ac 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -37,7 +37,7 @@ def setup_conf(config, key): conf = config[key] var = cg.new_Pvariable(conf[CONF_ID]) yield cg.register_component(var, conf) - yield select.register_select(var, config, options=config[CONF_OPTIONS]) + yield select.register_select(var, config, options=conf[CONF_OPTIONS]) def to_code(config): yield setup_conf(config, CONF_PUMP1) From 2c8b874c5430a88fcb5f6d991df35e358c1bae4a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 21:13:21 +0100 Subject: [PATCH 146/378] Add select for pump2 --- components/BalboaGLSelect/select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 217c8ac..36a128b 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -37,7 +37,7 @@ def setup_conf(config, key): conf = config[key] var = cg.new_Pvariable(conf[CONF_ID]) yield cg.register_component(var, conf) - yield select.register_select(var, config, options=conf[CONF_OPTIONS]) + yield select.register_select(var, config, options=list()) def to_code(config): yield setup_conf(config, CONF_PUMP1) From 6fb18ade443773709ed56b5977f2a1c21c2d681a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 26 Sep 2023 21:18:14 +0100 Subject: [PATCH 147/378] Add select for pump2 --- components/BalboaGLSelect/select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGLSelect/select.py index 36a128b..5f284ab 100644 --- a/components/BalboaGLSelect/select.py +++ b/components/BalboaGLSelect/select.py @@ -23,7 +23,7 @@ ), }), cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(Pump1Select), + cv.GenerateID(): cv.declare_id(Pump2Select), cv.Required(CONF_OPTIONS): cv.All( cv.ensure_list(cv.string_strict), cv.Length(min=1) ), From 2d618adbe05cfbffd0a9e303cef48b3e727a9820 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:19:06 +0100 Subject: [PATCH 148/378] Add LCD --- components/BalboaGL/climate.py | 2 +- components/BalboaGLSensor/ESPBalboaGLSensor.h | 10 ++++++++++ components/BalboaGLSensor/text_sensor.py | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 7db595c..2e1e7cd 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -89,5 +89,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="99e703abd8c418a2d470bf8076f8d88a41fae7c8", + version="ec30c86f8100fb8cd6562ba4e333cda527b62704", ) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index 277ffbc..e98c0e9 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -33,5 +33,15 @@ namespace esphome { }; + class BalboaGLLCDSensor : public TextSensor, public PollingComponent { + public: + BalboaGLLCDSensor() : PollingComponent(15000) { } + // void setup() {}; + void update() { + this->publish_state(status.lcd); + } + + }; + } } diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGLSensor/text_sensor.py index 4a4d4b7..ad3b4b9 100644 --- a/components/BalboaGLSensor/text_sensor.py +++ b/components/BalboaGLSensor/text_sensor.py @@ -6,11 +6,13 @@ CONF_STATE = "state" CONF_RAW = "raw" +CONF_LCD = "lcd" balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) +LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_STATE): text_sensor.TEXT_SENSOR_SCHEMA.extend({ @@ -19,6 +21,9 @@ cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(RawInfo), }), + cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(LCDInfo), + }), }) @coroutine @@ -32,4 +37,4 @@ def setup_conf(config, key): def to_code(config): yield setup_conf(config, CONF_STATE) yield setup_conf(config, CONF_RAW) - + yield setup_conf(config, CONF_LCD) From 496c8c89d2e2843070fce1e2159ba601b3e82a97 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:25:56 +0100 Subject: [PATCH 149/378] Add explicit dep to CircularBuffer --- components/BalboaGL/climate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 2e1e7cd..c9577ec 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -86,6 +86,12 @@ def to_code(config): repository="https://github.com/EinarArnason/ArduinoQueue.git", version="1.2.5", ) + + cg.add_library( + name="CircularBuffer", # TODO: should really pull in a dep of balboaGL + repository="https://github.com/rlogiacco/CircularBuffer.git", + version="1.3.3", + ) cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", From f3c23ff53155aa921cd3f231bcb763e5cbc9f22a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:29:14 +0100 Subject: [PATCH 150/378] telnetSend --- components/BalboaGL/ESPBalboaGL.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 526eeed..b10db67 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -2,6 +2,9 @@ #include "ESPBalboaGL.h" using namespace esphome; +void telnetSend(String msg) { + ESP_LOGI(TAG, msg); +} /** * Create a new BalboaGL object * From 573c154188ae2597631cdd262f2f083be3849a9b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:29:44 +0100 Subject: [PATCH 151/378] telnetSend --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index b10db67..98a92cc 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -3,7 +3,7 @@ using namespace esphome; void telnetSend(String msg) { - ESP_LOGI(TAG, msg); + ESP_LOGI(TAG, msg.c_str()); } /** * Create a new BalboaGL object From ede1bc137710d68681c9303d79429b0a64a6acc8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:35:34 +0100 Subject: [PATCH 152/378] debug raw --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 98a92cc..b81788a 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -47,7 +47,7 @@ void BalboaGL::update() { return; } else { - ESP_LOGD(TAG, "PanelSelect == LOw"); + ESP_LOGD(TAG, "PanelSelect == LOW"); } ESP_LOGD(TAG, "Current Temp: %f", status.temp); @@ -78,6 +78,7 @@ void BalboaGL::update() { static String lastRaw = "0"; // if(status.rawData != lastRaw) { + ESP_LOGD(TAG, "Raw: %f", status.rawData.c_str()); lastRaw = status.rawData; this->publish_state(); // } From 1f4f3b3f4bee8d7c48d8222d761381d1a96ce997 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:50:39 +0100 Subject: [PATCH 153/378] faster polling --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- components/BalboaGL/climate.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index b81788a..ca95c44 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -43,7 +43,7 @@ void BalboaGL::update() { ESP_LOGV(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { - ESP_LOGD(TAG, "PanelSelect == HIGH"); + ESP_LOGV(TAG, "PanelSelect == HIGH"); return; } else { diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index c9577ec..26e9177 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -40,7 +40,7 @@ def valid_uart(uart): cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. - cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( + cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) ), # Optionally override the supported ClimateTraits. From c5531d05e5d1381b7b6c4c818c4a6a8e4efe16e4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 11:56:53 +0100 Subject: [PATCH 154/378] Log level tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index ca95c44..0666c98 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,7 +38,7 @@ void BalboaGL::check_logger_conflict_() { void BalboaGL::update() { // This will be called every "update_interval" milliseconds. - ESP_LOGI(TAG, "Update called."); + ESP_LOGV(TAG, "Update called."); size_t len = this->spa->readSerial(); ESP_LOGV(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); From 8e38ff1aef647fd09f86b3773b627594ffad9e8f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 15:45:42 +0100 Subject: [PATCH 155/378] setLight and setTemp --- components/BalboaGL/ESPBalboaGL.cpp | 23 +++++++++----------- components/BalboaGL/climate.py | 2 +- sensor/src/sensor.cpp | 33 ++--------------------------- 3 files changed, 13 insertions(+), 45 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 0666c98..1bd515a 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -119,7 +119,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // bool updated = false; // bool has_mode = call.get_mode().has_value(); -// bool has_temp = call.get_target_temperature().has_value(); + bool has_temp = call.get_target_temperature().has_value(); // if (has_mode){ // this->mode = *call.get_mode(); // } @@ -187,23 +187,20 @@ void BalboaGL::control(const climate::ClimateCall &call) { // break; // } -// if (has_temp){ -// ESP_LOGV( -// "control", "Sending target temp: %.1f", -// *call.get_target_temperature() -// ); -// hp->setTemperature(*call.get_target_temperature()); -// this->target_temperature = *call.get_target_temperature(); -// updated = true; -// } + if (has_temp){ + ESP_LOGV( + "control", "Sending target temp: %.1f", + *call.get_target_temperature() + ); + this->spa->setTemp(*call.get_target_temperature()); + updated = true; + } -// ESP_LOGD(TAG, "control - Was HeatPump updated? %s", YESNO(updated)); +// ESP_LOGD(TAG, "control - Was SPA updated? %s", YESNO(updated)); // send the update back to esphome: this->publish_state(); -// // and the heat pump: -// hp->update(); } // void BalboaGL::hpSettingsChanged() { diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 26e9177..80901c3 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -95,5 +95,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="ec30c86f8100fb8cd6562ba4e333cda527b62704", + version="e5b7e189f4b687295f66075c1bdfa8b3ce5f06be", ) diff --git a/sensor/src/sensor.cpp b/sensor/src/sensor.cpp index c6514ba..4bf3390 100644 --- a/sensor/src/sensor.cpp +++ b/sensor/src/sensor.cpp @@ -116,12 +116,7 @@ int lastUptime = 0; void onSwitchStateChanged(bool state, HASwitch* sender) { Serial.printf("Switch %s changed - ", sender->getName()); - if (state != status.light) { - Serial.println("Toggle"); - sendBuffer.enqueue(COMMAND_LIGHT); - } else { - Serial.println("No change needed"); - } + spa.setLight(state); } void onPumpSwitchStateChanged(int8_t index, HASelect* sender) { @@ -165,31 +160,7 @@ void onTargetTemperatureCommand(HANumeric temperature, HAHVAC* sender) { Serial.print("Target temperature: "); Serial.println(temperatureFloat); - if (status.targetTemp <= 0) { - Serial.print("ERROR: can't adjust target as current value not known"); - sendBuffer.enqueue( - COMMAND_UP); // Enter set temp mode - won't change, but should allow us to capture the set target value - return; - } - - int target = temperatureFloat * 2; // 0.5 inc so double - int current = status.targetTemp * 2; - sendBuffer.enqueue(COMMAND_UP); // Enter set temp mode - sendBuffer.enqueue(COMMAND_EMPTY); - - if (temperatureFloat > status.targetTemp) { - for (int i = 0; i < (target - current); i++) { - Serial.println("Raise the temp"); - sendBuffer.enqueue(COMMAND_UP); - // sendBuffer.enqueue(COMMAND_EMPTY); - } - } else { - for (int i = 0; i < (current - target); i++) { - Serial.println("Lower the temp"); - sendBuffer.enqueue(COMMAND_DOWN); - // sendBuffer.enqueue(COMMAND_EMPTY); - } - } + spa.setTemp(temperatureFloat); // sender->setTargetTemperature(temperature); // report target temperature back to the HA panel - better to see what // the control unit reports that assume our commands worked From 5d00a783bf717ef20050bb567b27af9844cbb52b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 15:48:27 +0100 Subject: [PATCH 156/378] setLight and setTemp --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 1bd515a..14f5ea4 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -117,7 +117,7 @@ climate::ClimateTraits& BalboaGL::config_traits() { void BalboaGL::control(const climate::ClimateCall &call) { ESP_LOGV(TAG, "Control called."); -// bool updated = false; + bool updated = false; // bool has_mode = call.get_mode().has_value(); bool has_temp = call.get_target_temperature().has_value(); // if (has_mode){ From d3df30ac6ff828284159767dd797941d81c12958 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 15:57:34 +0100 Subject: [PATCH 157/378] Fix commenting --- components/BalboaGL/ESPBalboaGL.cpp | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 14f5ea4..010e64d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -85,35 +85,35 @@ void BalboaGL::update() { } -// /** -// * Get our supported traits. -// * -// * Note: -// * Many of the following traits are only available in the 1.5.0 dev train of -// * ESPHome, particularly the Dry operation mode, and several of the fan modes. -// * -// * Returns: -// * This class' supported climate::ClimateTraits. -// */ +/** + * Get our supported traits. + * + * Note: + * Many of the following traits are only available in the 1.5.0 dev train of + * ESPHome, particularly the Dry operation mode, and several of the fan modes. + * + * Returns: + * This class' supported climate::ClimateTraits. + */ climate::ClimateTraits BalboaGL::traits() { return traits_; } -// /** -// * Modify our supported traits. -// * -// * Returns: -// * A reference to this class' supported climate::ClimateTraits. -// */ +/** + * Modify our supported traits. + * + * Returns: + * A reference to this class' supported climate::ClimateTraits. + */ climate::ClimateTraits& BalboaGL::config_traits() { return traits_; } -// /** -// * Implement control of a BalboaGL. -// * -// * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. -// */ +/** + * Implement control of a BalboaGL. + * + * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. + */ void BalboaGL::control(const climate::ClimateCall &call) { ESP_LOGV(TAG, "Control called."); From 800cd0c180d5625e2c8dadbeeb5bb2267570ebaa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 16:15:41 +0100 Subject: [PATCH 158/378] Cleanup --- components/BalboaGLSensor/ESPBalboaGLSensor.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGLSensor/ESPBalboaGLSensor.h index e98c0e9..3406f3d 100644 --- a/components/BalboaGLSensor/ESPBalboaGLSensor.h +++ b/components/BalboaGLSensor/ESPBalboaGLSensor.h @@ -14,10 +14,9 @@ namespace esphome { class BalboaGLStateSensor : public TextSensor, public PollingComponent { public: BalboaGLStateSensor() : PollingComponent(15000) { } - // void setup() {}; void update() { std::string state = status.state.c_str(); - ESP_LOGD(TAG, state.c_str()); + ESP_LOGD(TAG, "State: %s", state.c_str()); this->publish_state(state.c_str()); } @@ -26,7 +25,6 @@ namespace esphome { class BalboaGLRawSensor : public TextSensor, public PollingComponent { public: BalboaGLRawSensor() : PollingComponent(15000) { } - // void setup() {}; void update() { this->publish_state(status.rawData.c_str()); } @@ -36,7 +34,6 @@ namespace esphome { class BalboaGLLCDSensor : public TextSensor, public PollingComponent { public: BalboaGLLCDSensor() : PollingComponent(15000) { } - // void setup() {}; void update() { this->publish_state(status.lcd); } From 66d6957b59a3f5b5abf37ea114d407969e0031ed Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:10:23 +0100 Subject: [PATCH 159/378] logger tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 010e64d..97611ee 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,7 +40,7 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGV(TAG, "Update called."); size_t len = this->spa->readSerial(); - ESP_LOGV(TAG, "Read %u bytes", len); + ESP_LOGD(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGV(TAG, "PanelSelect == HIGH"); From 16a69688ee577d019276fa75aebc4fb8c2c846f1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:19:25 +0100 Subject: [PATCH 160/378] Fix library dep --- sensor/platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sensor/platformio.ini b/sensor/platformio.ini index d2fb042..28a5afd 100644 --- a/sensor/platformio.ini +++ b/sensor/platformio.ini @@ -20,7 +20,8 @@ lib_deps = links2004/WebSockets@^2.3.7 https://github.com/EinarArnason/ArduinoQueue.git@^1.2.5 https://github.com/scottchiefbaker/ESP-WebOTA.git#aefb6c1a9190601b12b973a0c1cce39cb4e0f453 - ../../balboaGL/ + https://github.com/netmindz/balboaGL.git + [env:wemos_d1_mini32] platform = espressif32 From 1a7e736fccd2e085e8a00b24d41dfc696ba548cc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:43:25 +0100 Subject: [PATCH 161/378] require pins --- components/BalboaGL/climate.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 80901c3..48db9b8 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -5,11 +5,12 @@ from esphome.const import ( CONF_ID, CONF_HARDWARE_UART, - CONF_BAUD_RATE, CONF_UPDATE_INTERVAL, CONF_MODE, CONF_FAN_MODE, CONF_SWING_MODE, + CONF_RX_PIN, + CONF_TX_PIN, ) from esphome.core import CORE, coroutine @@ -52,6 +53,8 @@ def valid_uart(uart): cv.ensure_list(climate.validate_climate_fan_mode), cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): cv.ensure_list(climate.validate_climate_swing_mode), + cv.Required(CONF_RX_PIN): cv.int_range(), + cv.Required(CONF_TX_PIN): cv.int_range(), } ), } From 3cccd2fc81596156275922bf86ab3febd92a63c6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:46:02 +0100 Subject: [PATCH 162/378] require pins --- components/BalboaGL/climate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 48db9b8..79bfb60 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -44,6 +44,8 @@ def valid_uart(uart): cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) ), + cv.Required(CONF_RX_PIN): cv.int_range(), + cv.Required(CONF_TX_PIN): cv.int_range(), # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { @@ -53,8 +55,6 @@ def valid_uart(uart): cv.ensure_list(climate.validate_climate_fan_mode), cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): cv.ensure_list(climate.validate_climate_swing_mode), - cv.Required(CONF_RX_PIN): cv.int_range(), - cv.Required(CONF_TX_PIN): cv.int_range(), } ), } From 7db035cb4328d0f8a31401a08750620029948f42 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:51:37 +0100 Subject: [PATCH 163/378] extra pin config --- components/BalboaGL/climate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 79bfb60..2f7bb40 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -21,6 +21,9 @@ DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] +CONF_ENABLE_PIN = "enable_pin" +CONF_PANEL_SELECT_PIN = "panel_select_pin" + BalboaGL = cg.global_ns.class_( "BalboaGL", climate.Climate, cg.PollingComponent ) @@ -46,6 +49,8 @@ def valid_uart(uart): ), cv.Required(CONF_RX_PIN): cv.int_range(), cv.Required(CONF_TX_PIN): cv.int_range(), + cv.Required(CONF_PANEL_SELECT_PIN): cv.int_range(), + cv.Optional(CONF_ENABLE_PIN): cv.int_range(), # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { From 81edcb3688c1128f672f5411cd8a8b0e388f17ef Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 17:55:27 +0100 Subject: [PATCH 164/378] extra pin config --- component.yaml | 99 +++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 53 deletions(-) diff --git a/component.yaml b/component.yaml index acd4b99..28268b9 100644 --- a/component.yaml +++ b/component.yaml @@ -1,68 +1,61 @@ - esphome: - name: hottub - friendly_name: Hottub - - esp32: - board: esp32dev - framework: - type: arduino - external_components: +external_components: - source: type: git url: https://github.com/netmindz/balboa_GL_ML_spa_control.git ref: ESPHome refresh: 0s - components: [BalboaGL] - - - # Enable logging - logger: - - # Enable Home Assistant API - api: - encryption: - key: "sUhVA1uqxqWBmBu6BGISQHfi7+9a0HXf+1WIcBYrnz0=" - - ota: - password: "e82fe9bada398051d779151a591a1e2e" - - wifi: - ssid: !secret wifi_ssid - password: !secret wifi_password - - # Enable fallback hotspot (captive portal) in case wifi connection fails - ap: - ssid: "Hottub Fallback Hotspot" - password: "tHV1HzrYNvGo" - - captive_portal: + # components: [BalboaGL,BalboaGLSensor] # Text sensors with general information. - text_sensor: +text_sensor: # Expose ESPHome version as sensor. - platform: version - name: ${name} ESPHome Version + name: ESPHome Version # Expose WiFi information as sensors. - platform: wifi_info ip_address: - name: ${name} IP + name: IP ssid: - name: ${name} SSID + name: SSID bssid: - name: ${name} BSSID - - # Sensors with general information. - sensor: - # Uptime sensor. - - platform: uptime - name: ${name} Uptime - - # WiFi Signal sensor. - - platform: wifi_signal - name: ${name} WiFi Signal - update_interval: 60s - - climate: - - platform: BalboaGL - name: ${friendly_name} + name: BSSID + + - platform: BalboaGLSensor + state: + name: State + raw: + name: Raw Data + lcd: + name: LCD Display + +# Sensors with general information. +sensor: + # Uptime sensor. + - platform: uptime + name: Uptime + + # WiFi Signal sensor. + - platform: wifi_signal + name: WiFi Signal + update_interval: 60s + +switch: + - platform: BalboaGLSwitch + name: Light + +# select: +# - platform: BalboaGLSelect +# pump1: +# name: Pump1 +# options: "HIGH" + +climate: + - platform: BalboaGL + name: Temp + hardware_uart: UART1 + rx_pin: 3 + tx_pin: 10 + enable_pin: 5 + panel_select_pin: 6 + update_interval: 1000ms From c7b1631b44e78ed2565a250ecfc7fc1c2cf584ac Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 18:24:55 +0100 Subject: [PATCH 165/378] extra pin config --- components/BalboaGL/ESPBalboaGL.cpp | 15 ++++++++++++--- components/BalboaGL/ESPBalboaGL.h | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 97611ee..af86bff 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -447,17 +447,26 @@ void BalboaGL::setup() { // return ESPMHP_MIN_TEMPERATURE + (steps * ESPMHP_TEMPERATURE_STEP); // } -// void BalboaGL::dump_config() { -// this->banner(); +void BalboaGL::dump_config() { + // this->banner(); + ESP_LOGI(TAG, " rx,tx = %u,%u", this->rx_pin, this->tx_pin); // ESP_LOGI(TAG, " Supports HEAT: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports COOL: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports AWAY mode: %s", YESNO(false)); // ESP_LOGI(TAG, " Saved heat: %.1f", heat_setpoint.value_or(-1)); // ESP_LOGI(TAG, " Saved cool: %.1f", cool_setpoint.value_or(-1)); // ESP_LOGI(TAG, " Saved auto: %.1f", auto_setpoint.value_or(-1)); -// } +} // void BalboaGL::dump_state() { // LOG_CLIMATE("", "BalboaGL Climate", this); // ESP_LOGI(TAG, "HELLO"); // } + +void void BalboaGL::set_rx_pin(int pin) { + this->rx_pin = pin; +} + +void void BalboaGL::set_tx_pin(int pin) { + this->tx_pin = pin; +} diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 4020cfb..97b05ca 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -42,8 +42,8 @@ class BalboaGL : public PollingComponent, public climate::Climate { HardwareSerial* hw_serial ); - // // print the current configuration - // void dump_config() override; + // print the current configuration + void dump_config() override; // // handle a change in settings as detected by the HeatPump library. // void hpSettingsChanged(); @@ -51,16 +51,16 @@ class BalboaGL : public PollingComponent, public climate::Climate { // // Handle a change in status as detected by the HeatPump library. // void hpStatusChanged(heatpumpStatus currentStatus); - // // Set up the component, initializing the balboaGL object. + // Set up the component, initializing the balboaGL object. void setup() override; - // // This is called every poll_interval. + // This is called every poll_interval. void update() override; - // // Configure the climate object with traits that we support. + // Configure the climate object with traits that we support. climate::ClimateTraits traits() override; - // // Get a mutable reference to the traits that we support. + // Get a mutable reference to the traits that we support. climate::ClimateTraits& config_traits(); // Debugging function to print the object's state. @@ -73,6 +73,9 @@ class BalboaGL : public PollingComponent, public climate::Climate { // // set_remote_temp(0) to switch back to the internal sensor. // void set_remote_temperature(float); + void set_rx_pin(int pin); + + void set_tx_pin(int pin); protected: // The ClimateTraits supported by this HeatPump. @@ -87,6 +90,9 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); + int rx_pin; + int tx_pin; + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From fa557dd01492765f5ef22645e7e431a8c3b03fa2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 18:26:27 +0100 Subject: [PATCH 166/378] extra pin config --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index af86bff..2c6c2a6 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -463,10 +463,10 @@ void BalboaGL::dump_config() { // ESP_LOGI(TAG, "HELLO"); // } -void void BalboaGL::set_rx_pin(int pin) { +void BalboaGL::set_rx_pin(int pin) { this->rx_pin = pin; } -void void BalboaGL::set_tx_pin(int pin) { +void BalboaGL::set_tx_pin(int pin) { this->tx_pin = pin; } From 6bb7ccbf5ac1136ae785fcb24ac9ac604c626b3f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 7 Oct 2023 18:30:56 +0100 Subject: [PATCH 167/378] extra pin config --- components/BalboaGL/ESPBalboaGL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 97b05ca..5d59b39 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -90,8 +90,8 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - int rx_pin; - int tx_pin; + int rx_pin = -1; + int tx_pin = -1; private: // Retrieve the HardwareSerial pointer from friend and subclasses. From 5c616bac8c06cb1c8ef952f8931e148f087e0763 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 09:29:32 +0100 Subject: [PATCH 168/378] Setup after WiFi --- components/BalboaGL/ESPBalboaGL.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 5d59b39..742bdd4 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -77,6 +77,8 @@ class BalboaGL : public PollingComponent, public climate::Climate { void set_tx_pin(int pin); + float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } + protected: // The ClimateTraits supported by this HeatPump. climate::ClimateTraits traits_; From 0ee5ce7ae8cdedee011343f053bbbbe05588d700 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 09:42:42 +0100 Subject: [PATCH 169/378] Use libary version with correct send message size --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 2f7bb40..1e544b5 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -103,5 +103,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="e5b7e189f4b687295f66075c1bdfa8b3ce5f06be", + version="0971976e020a930a20a2ebbada65487fe4170927", ) From c9f3dc95149443649b89e77313ccc563502fffa6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 09:50:01 +0100 Subject: [PATCH 170/378] No actions and tweak logger --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2c6c2a6..335d2b8 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -17,7 +17,7 @@ BalboaGL::BalboaGL( ) : hw_serial_{hw_serial} { - this->traits_.set_supports_action(true); + this->traits_.set_supports_action(false); this->traits_.set_supports_current_temperature(true); this->traits_.set_supports_two_point_target_temperature(false); this->traits_.set_visual_min_temperature(26); @@ -188,7 +188,7 @@ void BalboaGL::control(const climate::ClimateCall &call) { // } if (has_temp){ - ESP_LOGV( + ESP_LOGI( "control", "Sending target temp: %.1f", *call.get_target_temperature() ); From ab084c7a85cce3b42aed1ea56485bb2c0ff5f801 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 09:57:36 +0100 Subject: [PATCH 171/378] raw logger --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 335d2b8..548ff04 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -78,7 +78,7 @@ void BalboaGL::update() { static String lastRaw = "0"; // if(status.rawData != lastRaw) { - ESP_LOGD(TAG, "Raw: %f", status.rawData.c_str()); + ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); lastRaw = status.rawData; this->publish_state(); // } From 0e9f74a5ab1f2dc9d8e62bb2a2560737726f5a89 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 09:58:05 +0100 Subject: [PATCH 172/378] tweak logger --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 548ff04..32cf858 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,7 +40,7 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGV(TAG, "Update called."); size_t len = this->spa->readSerial(); - ESP_LOGD(TAG, "Read %u bytes", len); + ESP_LOGv(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGV(TAG, "PanelSelect == HIGH"); From e09173c116ca14fceaf665cc26bb78a286e32dcc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 10:00:55 +0100 Subject: [PATCH 173/378] tweak logger --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 32cf858..5a49d75 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -40,7 +40,7 @@ void BalboaGL::update() { // This will be called every "update_interval" milliseconds. ESP_LOGV(TAG, "Update called."); size_t len = this->spa->readSerial(); - ESP_LOGv(TAG, "Read %u bytes", len); + ESP_LOGV(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); if(panelSelect == HIGH) { ESP_LOGV(TAG, "PanelSelect == HIGH"); From c0cbf081b98393b69cdbfe44632cd47f5cfa1747 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 10:27:51 +0100 Subject: [PATCH 174/378] ESPHome loggers --- components/BalboaGL/ESPBalboaGL.h | 6 ++++++ components/BalboaGL/climate.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 742bdd4..bcffe0a 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,6 +8,12 @@ #ifndef ESPMHP_H #define ESPMHP_H + +#define LOGGER_PRINT ESP_LOGD +#define LOGGER_PRINTLN ESP_LOGD +#define LOGGER_PRINTF ESP_LOGD + + #include "balboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 1e544b5..28b1ffa 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -103,5 +103,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="0971976e020a930a20a2ebbada65487fe4170927", + version="1c90d08f819ba2f55a5cc4bd36c82cdf846e4c7e", ) From 13be7d00b2f3cc8a7a1d4f4e5a70be6af6eb0c0d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 10:41:46 +0100 Subject: [PATCH 175/378] Swap to ESP_LOG --- components/BalboaGL/ESPBalboaGL.h | 6 ------ components/BalboaGL/climate.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index bcffe0a..742bdd4 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,12 +8,6 @@ #ifndef ESPMHP_H #define ESPMHP_H - -#define LOGGER_PRINT ESP_LOGD -#define LOGGER_PRINTLN ESP_LOGD -#define LOGGER_PRINTF ESP_LOGD - - #include "balboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 28b1ffa..3fb3f2a 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -103,5 +103,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="1c90d08f819ba2f55a5cc4bd36c82cdf846e4c7e", + version="d37a80b7d3c4da6b5b2e34784c52cfd5b49e1d4d", ) From 1d8efd1cb17ec78e5788ead6ea121b5babead60f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 10:46:58 +0100 Subject: [PATCH 176/378] Swap to ESP_LOG --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 3fb3f2a..2e3c4c0 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -103,5 +103,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="d37a80b7d3c4da6b5b2e34784c52cfd5b49e1d4d", + version="7e2d6fbc2d3d7baf39ca8483248e4ea7db5204f1", ) From ea804bc27cb1596db7f94b20af45b4253fcef8f4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:00:27 +0100 Subject: [PATCH 177/378] library update --- components/BalboaGL/ESPBalboaGL.h | 2 -- components/BalboaGL/climate.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 742bdd4..a62b761 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,8 +8,6 @@ #ifndef ESPMHP_H #define ESPMHP_H -#include "balboaGL.h" - static const char* TAG = "BalboaGL"; // Logging tag // // Perform measurements or read nameplate values on your tub to define the power [kW] diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 2e3c4c0..d2fbbcf 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -103,5 +103,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="7e2d6fbc2d3d7baf39ca8483248e4ea7db5204f1", + version="0e23dd2e7fced5ab78c8bac5c817bed93c08aa25", ) From df61ba60d478e9df24a26b3290862debe50234a9 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:08:33 +0100 Subject: [PATCH 178/378] Set RX and TX if present --- components/BalboaGL/climate.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index d2fbbcf..e7ba154 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -87,6 +87,12 @@ def to_code(config): climate.CLIMATE_SWING_MODES[mode] )) + if CONF_RX_PIN in config: + cg.add(var.set_rx_pin(config[CONF_RX_PIN])) + + if CONF_TX_PIN in config: + cg.add(var.set_tx_pin(config[CONF_TX_PIN])) + yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add_library( From d8df5d8ebfe9338c4ce9d7d05681afe92ca41b5c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:08:48 +0100 Subject: [PATCH 179/378] Revert update to new logger --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index e7ba154..1d188d5 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -109,5 +109,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="0e23dd2e7fced5ab78c8bac5c817bed93c08aa25", + version="0971976e020a930a20a2ebbada65487fe4170927", ) From 01c14ff5c4208e954458f84324bbe5ba7296e9a5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:15:02 +0100 Subject: [PATCH 180/378] Revert update to new logger --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 1d188d5..9d87f02 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -109,5 +109,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="0971976e020a930a20a2ebbada65487fe4170927", + version="command-length-fix", ) From 1fd92082ce5b57d788c2a8b6c57f29a65beed1cd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:25:46 +0100 Subject: [PATCH 181/378] Remove hard coded pins --- components/BalboaGL/ESPBalboaGL.cpp | 13 +++++++++++-- components/BalboaGL/ESPBalboaGL.h | 12 ++++++------ components/BalboaGL/climate.py | 7 +++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 5a49d75..11cfe0d 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -384,9 +384,9 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - hw_serial_->begin(115200, SERIAL_8N1, RX_PIN_DEF, TX_PIN_DEF); + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, RTS_PIN_DEF, PIN_5_PIN_DEF); + this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->current_temperature = NAN; this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_OFF; @@ -450,6 +450,8 @@ void BalboaGL::setup() { void BalboaGL::dump_config() { // this->banner(); ESP_LOGI(TAG, " rx,tx = %u,%u", this->rx_pin, this->tx_pin); + ESP_LOGI(TAG, " rts_pin = %u", this->rts_pin); + ESP_LOGI(TAG, " panel_select_pin = %u", this->panel_select_pin); // ESP_LOGI(TAG, " Supports HEAT: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports COOL: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports AWAY mode: %s", YESNO(false)); @@ -470,3 +472,10 @@ void BalboaGL::set_rx_pin(int pin) { void BalboaGL::set_tx_pin(int pin) { this->tx_pin = pin; } +void set_rts_pin(int pin) { + this->rts_pin = pin; +} + +void set_panel_select_pin(int pin) { + this->panel_select_pin = pin; +} diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index a62b761..37e3a6b 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -24,12 +24,6 @@ static const char* TAG = "BalboaGL"; // Logging tag const uint32_t POLL_INTERVAL_DEFAULT = 10000; -// TODO: hard coded values for T-RSC3 -#define RX_PIN_DEF 3 -#define TX_PIN_DEF 10 -#define RTS_PIN_DEF 5 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. -#define PIN_5_PIN_DEF 6 - #include "balboaGL.h" using namespace esphome; @@ -75,6 +69,10 @@ class BalboaGL : public PollingComponent, public climate::Climate { void set_tx_pin(int pin); + void set_rts_pin(int pin); + + void set_panel_select_pin(int pin); + float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } protected: @@ -92,6 +90,8 @@ class BalboaGL : public PollingComponent, public climate::Climate { int rx_pin = -1; int tx_pin = -1; + int rts_pin = -1 + int panel_select_pin = -1; private: // Retrieve the HardwareSerial pointer from friend and subclasses. diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index 9d87f02..ef3f696 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -93,6 +93,13 @@ def to_code(config): if CONF_TX_PIN in config: cg.add(var.set_tx_pin(config[CONF_TX_PIN])) + if CONF_ENABLE_PIN in config: + cg.add(var.set_rts_pin(config[CONF_ENABLE_PIN])) + + if CONF_PANEL_SELECT_PIN in config: + cg.add(var.set_panel_select_pin(config[CONF_PANEL_SELECT_PIN])) + + yield cg.register_component(var, config) yield climate.register_climate(var, config) cg.add_library( From 9878cb4d6b5924432593e7b7c93223ac05e8e4a3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:26:42 +0100 Subject: [PATCH 182/378] Remove hard coded pins --- components/BalboaGL/ESPBalboaGL.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 37e3a6b..a9af9ff 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -90,7 +90,7 @@ class BalboaGL : public PollingComponent, public climate::Climate { int rx_pin = -1; int tx_pin = -1; - int rts_pin = -1 + int rts_pin = -1; int panel_select_pin = -1; private: From c107f0b58b195113ec49bd87fa427691cdf9bb44 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:27:40 +0100 Subject: [PATCH 183/378] Remove hard coded pins --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 11cfe0d..e788cc8 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -472,10 +472,10 @@ void BalboaGL::set_rx_pin(int pin) { void BalboaGL::set_tx_pin(int pin) { this->tx_pin = pin; } -void set_rts_pin(int pin) { +void BalboaGL::set_rts_pin(int pin) { this->rts_pin = pin; } -void set_panel_select_pin(int pin) { +void BalboaGL::set_panel_select_pin(int pin) { this->panel_select_pin = pin; } From 897d75d12e873a97fb0c990046b40752ecdf551e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 14 Oct 2023 11:40:54 +0100 Subject: [PATCH 184/378] Remove hard coded pins --- components/BalboaGL/ESPBalboaGL.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index e788cc8..551d4bb 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -384,6 +384,7 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); + ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); From 74a8b1d201d5dd930fe3df23c06c46ed39c126a0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 15 Oct 2023 12:32:14 +0100 Subject: [PATCH 185/378] library update --- components/BalboaGL/climate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py index ef3f696..0000690 100644 --- a/components/BalboaGL/climate.py +++ b/components/BalboaGL/climate.py @@ -116,5 +116,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="command-length-fix", + version="ce3e1f8b9c6d3a0b141658432ed8751971b47fee", ) From 45edcf7dfab678c3081f819d96e0df03a178c9d4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 15 Oct 2023 12:49:02 +0100 Subject: [PATCH 186/378] log inccludes --- components/BalboaGL/ESPBalboaGL.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index a9af9ff..11bdae9 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -3,7 +3,8 @@ #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" #ifndef ESPMHP_H #define ESPMHP_H From 6f0e1ad082f8dc6a1d75e4bb40ab31143cbf1ab5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 15 Oct 2023 14:35:49 +0100 Subject: [PATCH 187/378] move config --- components/BalboaGL/__init__.py | 120 ++++++++++++++++++++++++++++++++ components/BalboaGL/climate.py | 120 -------------------------------- 2 files changed, 120 insertions(+), 120 deletions(-) delete mode 100644 components/BalboaGL/climate.py diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index e69de29..0000690 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -0,0 +1,120 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import climate +from esphome.components.logger import HARDWARE_UART_TO_SERIAL +from esphome.const import ( + CONF_ID, + CONF_HARDWARE_UART, + CONF_UPDATE_INTERVAL, + CONF_MODE, + CONF_FAN_MODE, + CONF_SWING_MODE, + CONF_RX_PIN, + CONF_TX_PIN, +) +from esphome.core import CORE, coroutine + +AUTO_LOAD = ["climate"] + +CONF_SUPPORTS = "supports" +DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] +DEFAULT_FAN_MODES = ["OFF"] +DEFAULT_SWING_MODES = ["OFF"] + +CONF_ENABLE_PIN = "enable_pin" +CONF_PANEL_SELECT_PIN = "panel_select_pin" + +BalboaGL = cg.global_ns.class_( + "BalboaGL", climate.Climate, cg.PollingComponent +) + + +def valid_uart(uart): + if CORE.is_esp32: + uarts = [ "UART1", "UART2"] + else: + raise NotImplementedError + + return cv.one_of(*uarts, upper=True)(uart) + + +CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(BalboaGL), + cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, + # If polling interval is greater than 9 seconds, the HeatPump library + # reconnects, but doesn't then follow up with our data request. + cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( + cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) + ), + cv.Required(CONF_RX_PIN): cv.int_range(), + cv.Required(CONF_TX_PIN): cv.int_range(), + cv.Required(CONF_PANEL_SELECT_PIN): cv.int_range(), + cv.Optional(CONF_ENABLE_PIN): cv.int_range(), + # Optionally override the supported ClimateTraits. + cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( + { + cv.Optional(CONF_MODE, default=DEFAULT_CLIMATE_MODES): + cv.ensure_list(climate.validate_climate_mode), + cv.Optional(CONF_FAN_MODE, default=DEFAULT_FAN_MODES): + cv.ensure_list(climate.validate_climate_fan_mode), + cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): + cv.ensure_list(climate.validate_climate_swing_mode), + } + ), + } +).extend(cv.COMPONENT_SCHEMA) + + +@coroutine +def to_code(config): + serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] + var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) + + supports = config[CONF_SUPPORTS] + traits = var.config_traits() + + for mode in supports[CONF_MODE]: + if mode == "OFF": + continue + cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) + + for mode in supports[CONF_FAN_MODE]: + cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) + + for mode in supports[CONF_SWING_MODE]: + cg.add(traits.add_supported_swing_mode( + climate.CLIMATE_SWING_MODES[mode] + )) + + if CONF_RX_PIN in config: + cg.add(var.set_rx_pin(config[CONF_RX_PIN])) + + if CONF_TX_PIN in config: + cg.add(var.set_tx_pin(config[CONF_TX_PIN])) + + if CONF_ENABLE_PIN in config: + cg.add(var.set_rts_pin(config[CONF_ENABLE_PIN])) + + if CONF_PANEL_SELECT_PIN in config: + cg.add(var.set_panel_select_pin(config[CONF_PANEL_SELECT_PIN])) + + + yield cg.register_component(var, config) + yield climate.register_climate(var, config) + cg.add_library( + name="ArduinoQueue", + repository="https://github.com/EinarArnason/ArduinoQueue.git", + version="1.2.5", + ) + + cg.add_library( + name="CircularBuffer", # TODO: should really pull in a dep of balboaGL + repository="https://github.com/rlogiacco/CircularBuffer.git", + version="1.3.3", + ) + cg.add_library( + name="balboaGL", + repository="https://github.com/netmindz/balboaGL.git", + version="ce3e1f8b9c6d3a0b141658432ed8751971b47fee", + ) diff --git a/components/BalboaGL/climate.py b/components/BalboaGL/climate.py deleted file mode 100644 index 0000690..0000000 --- a/components/BalboaGL/climate.py +++ /dev/null @@ -1,120 +0,0 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import climate -from esphome.components.logger import HARDWARE_UART_TO_SERIAL -from esphome.const import ( - CONF_ID, - CONF_HARDWARE_UART, - CONF_UPDATE_INTERVAL, - CONF_MODE, - CONF_FAN_MODE, - CONF_SWING_MODE, - CONF_RX_PIN, - CONF_TX_PIN, -) -from esphome.core import CORE, coroutine - -AUTO_LOAD = ["climate"] - -CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] -DEFAULT_FAN_MODES = ["OFF"] -DEFAULT_SWING_MODES = ["OFF"] - -CONF_ENABLE_PIN = "enable_pin" -CONF_PANEL_SELECT_PIN = "panel_select_pin" - -BalboaGL = cg.global_ns.class_( - "BalboaGL", climate.Climate, cg.PollingComponent -) - - -def valid_uart(uart): - if CORE.is_esp32: - uarts = [ "UART1", "UART2"] - else: - raise NotImplementedError - - return cv.one_of(*uarts, upper=True)(uart) - - -CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( - { - cv.GenerateID(): cv.declare_id(BalboaGL), - cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, - # If polling interval is greater than 9 seconds, the HeatPump library - # reconnects, but doesn't then follow up with our data request. - cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( - cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) - ), - cv.Required(CONF_RX_PIN): cv.int_range(), - cv.Required(CONF_TX_PIN): cv.int_range(), - cv.Required(CONF_PANEL_SELECT_PIN): cv.int_range(), - cv.Optional(CONF_ENABLE_PIN): cv.int_range(), - # Optionally override the supported ClimateTraits. - cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( - { - cv.Optional(CONF_MODE, default=DEFAULT_CLIMATE_MODES): - cv.ensure_list(climate.validate_climate_mode), - cv.Optional(CONF_FAN_MODE, default=DEFAULT_FAN_MODES): - cv.ensure_list(climate.validate_climate_fan_mode), - cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): - cv.ensure_list(climate.validate_climate_swing_mode), - } - ), - } -).extend(cv.COMPONENT_SCHEMA) - - -@coroutine -def to_code(config): - serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] - var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) - - supports = config[CONF_SUPPORTS] - traits = var.config_traits() - - for mode in supports[CONF_MODE]: - if mode == "OFF": - continue - cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) - - for mode in supports[CONF_FAN_MODE]: - cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) - - for mode in supports[CONF_SWING_MODE]: - cg.add(traits.add_supported_swing_mode( - climate.CLIMATE_SWING_MODES[mode] - )) - - if CONF_RX_PIN in config: - cg.add(var.set_rx_pin(config[CONF_RX_PIN])) - - if CONF_TX_PIN in config: - cg.add(var.set_tx_pin(config[CONF_TX_PIN])) - - if CONF_ENABLE_PIN in config: - cg.add(var.set_rts_pin(config[CONF_ENABLE_PIN])) - - if CONF_PANEL_SELECT_PIN in config: - cg.add(var.set_panel_select_pin(config[CONF_PANEL_SELECT_PIN])) - - - yield cg.register_component(var, config) - yield climate.register_climate(var, config) - cg.add_library( - name="ArduinoQueue", - repository="https://github.com/EinarArnason/ArduinoQueue.git", - version="1.2.5", - ) - - cg.add_library( - name="CircularBuffer", # TODO: should really pull in a dep of balboaGL - repository="https://github.com/rlogiacco/CircularBuffer.git", - version="1.3.3", - ) - cg.add_library( - name="balboaGL", - repository="https://github.com/netmindz/balboaGL.git", - version="ce3e1f8b9c6d3a0b141658432ed8751971b47fee", - ) From 35f66be80cc29d1650f7cc8ee8077f4e809f891b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 15 Oct 2023 14:40:30 +0100 Subject: [PATCH 188/378] comment unused imports --- components/BalboaGL/ESPBalboaGL.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 11bdae9..61c7531 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,7 +1,7 @@ #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/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" From b58fa84b3eeb58c813533516fa3d24226fdaeddd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 19:34:39 +0100 Subject: [PATCH 189/378] Move into unified component --- .../BalboaGLSelect.h | 0 .../BalboaGLSwitch.h | 0 components/BalboaGL/ESPBalboaGL.h | 16 ++++++++++++++-- .../ESPBalboaGLSensor.h | 0 4 files changed, 14 insertions(+), 2 deletions(-) rename components/{BalboaGLSelect => BalboaGL}/BalboaGLSelect.h (100%) rename components/{BalboaGLSwitch => BalboaGL}/BalboaGLSwitch.h (100%) rename components/{BalboaGLSensor => BalboaGL}/ESPBalboaGLSensor.h (100%) diff --git a/components/BalboaGLSelect/BalboaGLSelect.h b/components/BalboaGL/BalboaGLSelect.h similarity index 100% rename from components/BalboaGLSelect/BalboaGLSelect.h rename to components/BalboaGL/BalboaGLSelect.h diff --git a/components/BalboaGLSwitch/BalboaGLSwitch.h b/components/BalboaGL/BalboaGLSwitch.h similarity index 100% rename from components/BalboaGLSwitch/BalboaGLSwitch.h rename to components/BalboaGL/BalboaGLSwitch.h diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 61c7531..67726fa 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -1,3 +1,6 @@ +#ifndef ESPMHP_H +#define ESPMHP_H + #include "esphome.h" #include "esphome/core/preferences.h" // #include "esphome/components/sensor/sensor.h" @@ -6,8 +9,10 @@ #include "esphome/core/log.h" #include "esp_log.h" -#ifndef ESPMHP_H -#define ESPMHP_H +#include "BalboaGLSelect.h" +#include "BalboaGLSwitch.h" +#include "ESPBalboaGL.h" +#include "ESPBalboaGLSensor.h" static const char* TAG = "BalboaGL"; // Logging tag @@ -89,6 +94,13 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); + BalboaGLPump1Select pump1; + BalboaGLPump2Select pump2; + BalboaGLLightSwitch lightSwitch; + BalboaGLStateSensor stateSensor; + BalboaGLRawSensor rawSensor; + BalboaGLLCDSensor lcdSensor; + int rx_pin = -1; int tx_pin = -1; int rts_pin = -1; diff --git a/components/BalboaGLSensor/ESPBalboaGLSensor.h b/components/BalboaGL/ESPBalboaGLSensor.h similarity index 100% rename from components/BalboaGLSensor/ESPBalboaGLSensor.h rename to components/BalboaGL/ESPBalboaGLSensor.h From 2e20380fe3bb13baac39671a8f6337949ee40f77 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 21:31:10 +0100 Subject: [PATCH 190/378] Fix build --- components/BalboaGL/BalboaGLSelect.h | 2 ++ components/BalboaGL/BalboaGLSwitch.h | 3 +++ components/BalboaGL/ESPBalboaGL.h | 12 ++++++------ components/BalboaGL/ESPBalboaGLSensor.h | 3 +++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/BalboaGLSelect.h b/components/BalboaGL/BalboaGLSelect.h index 35e0213..c8fdf6d 100644 --- a/components/BalboaGL/BalboaGLSelect.h +++ b/components/BalboaGL/BalboaGLSelect.h @@ -1,3 +1,5 @@ +#pragma once + #include "esphome/core/component.h" #include "esphome/components/select/select.h" diff --git a/components/BalboaGL/BalboaGLSwitch.h b/components/BalboaGL/BalboaGLSwitch.h index 323c457..219a7b4 100644 --- a/components/BalboaGL/BalboaGLSwitch.h +++ b/components/BalboaGL/BalboaGLSwitch.h @@ -1,3 +1,6 @@ +#pragma once + + #include "esphome/core/component.h" #include "esphome/components/switch/switch.h" diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 67726fa..e4b9443 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -94,12 +94,12 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - BalboaGLPump1Select pump1; - BalboaGLPump2Select pump2; - BalboaGLLightSwitch lightSwitch; - BalboaGLStateSensor stateSensor; - BalboaGLRawSensor rawSensor; - BalboaGLLCDSensor lcdSensor; + // esphome::balboa_select::BalboaGLPump1Select pump1; + // esphome::balboa_select::BalboaGLPump2Select pump2; + esphome::balboa_switch::BalboaGLLightSwitch lightSwitch; + esphome::balboa_sensor::BalboaGLStateSensor stateSensor; + esphome::balboa_sensor::BalboaGLRawSensor rawSensor; + esphome::balboa_sensor::BalboaGLLCDSensor lcdSensor; int rx_pin = -1; int tx_pin = -1; diff --git a/components/BalboaGL/ESPBalboaGLSensor.h b/components/BalboaGL/ESPBalboaGLSensor.h index 3406f3d..78bcb33 100644 --- a/components/BalboaGL/ESPBalboaGLSensor.h +++ b/components/BalboaGL/ESPBalboaGLSensor.h @@ -2,7 +2,10 @@ #include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" +#include "esp_log.h" +#include "balboaGL.h" +extern struct BalboaStatus status; namespace esphome { namespace balboa_sensor { From 05506310873ecd55c8a128e8881c69199ce31d9d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 21:45:33 +0100 Subject: [PATCH 191/378] Push state --- components/BalboaGL/ESPBalboaGL.cpp | 14 ++++++++++++-- components/BalboaGL/ESPBalboaGL.h | 14 ++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 551d4bb..7a49efb 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -77,11 +77,21 @@ void BalboaGL::update() { } static String lastRaw = "0"; - // if(status.rawData != lastRaw) { + if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); lastRaw = status.rawData; + + // this->pump1->publish_state(pump_mode[status.pump1]); + // this->pump2->publish_state(pump_mode[status.pump2]); + + this->lightSwitch->publish_state(status.light); + + this->stateSensor->update(); + this->rawSensor->update(); + this->lcdSensor->update(); + this->publish_state(); - // } + } } diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index e4b9443..74de810 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -94,12 +94,14 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - // esphome::balboa_select::BalboaGLPump1Select pump1; - // esphome::balboa_select::BalboaGLPump2Select pump2; - esphome::balboa_switch::BalboaGLLightSwitch lightSwitch; - esphome::balboa_sensor::BalboaGLStateSensor stateSensor; - esphome::balboa_sensor::BalboaGLRawSensor rawSensor; - esphome::balboa_sensor::BalboaGLLCDSensor lcdSensor; + esphome::balboa_select::BalboaGLPump1Select* pump1; + esphome::balboa_select::BalboaGLPump2Select* pump2; + + esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; + + esphome::balboa_sensor::BalboaGLStateSensor* stateSensor; + esphome::balboa_sensor::BalboaGLRawSensor* rawSensor; + esphome::balboa_sensor::BalboaGLLCDSensor* lcdSensor; int rx_pin = -1; int tx_pin = -1; From 18d80e1439d75ec890ac2eb3a7ba98690605c062 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 21:54:01 +0100 Subject: [PATCH 192/378] Push state --- components/BalboaGL/BalboaGLSwitch.h | 10 ++++++++-- components/BalboaGL/ESPBalboaGL.cpp | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/BalboaGLSwitch.h b/components/BalboaGL/BalboaGLSwitch.h index 219a7b4..7cbc035 100644 --- a/components/BalboaGL/BalboaGLSwitch.h +++ b/components/BalboaGL/BalboaGLSwitch.h @@ -1,14 +1,18 @@ #pragma once - #include "esphome/core/component.h" #include "esphome/components/switch/switch.h" +#include "balboaGL.h" + namespace esphome { namespace balboa_switch { class BalboaGLLightSwitch : public Component, public switch_::Switch { public: + void setSpa(balboaGL* spa) { + this->spa = spa; + } void setup() override { // This will be called by App.setup() // pinMode(5, INPUT); @@ -16,11 +20,13 @@ namespace esphome { void write_state(bool state) override { // This will be called every time the user requests a state change. - // digitalWrite(5, state); + spa->setLight(state); // Acknowledge new state by publishing it // publish_state(state); } + private: + balboaGL* spa; }; } diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 7a49efb..0b88d72 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -23,6 +23,8 @@ BalboaGL::BalboaGL( this->traits_.set_visual_min_temperature(26); this->traits_.set_visual_max_temperature(40); this->traits_.set_visual_temperature_step(0.5); + + this->lightSwitch->setSpa(spa); } void BalboaGL::check_logger_conflict_() { From 99bd64d3ceb6a799160f1226ba4a4906bcf408ae Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 22:01:28 +0100 Subject: [PATCH 193/378] Auto load components --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 0000690..e9b6494 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -14,7 +14,7 @@ ) from esphome.core import CORE, coroutine -AUTO_LOAD = ["climate"] +AUTO_LOAD = ["climate","switch","select","sensor"] CONF_SUPPORTS = "supports" DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] From ff50d5191a16e9c47da5531685b42ecb77120719 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 22:18:21 +0100 Subject: [PATCH 194/378] Auto load components --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index e9b6494..59b8dff 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -14,7 +14,7 @@ ) from esphome.core import CORE, coroutine -AUTO_LOAD = ["climate","switch","select","sensor"] +AUTO_LOAD = ["climate","switch","select","sensor","text_sensor"] CONF_SUPPORTS = "supports" DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] From 5f6bd749d3d4227505f93321408bd98c3308127f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 22:19:32 +0100 Subject: [PATCH 195/378] Update example --- component.yaml | 61 +++++++------------------------------------------- 1 file changed, 8 insertions(+), 53 deletions(-) diff --git a/component.yaml b/component.yaml index 28268b9..dfd61a0 100644 --- a/component.yaml +++ b/component.yaml @@ -5,57 +5,12 @@ external_components: url: https://github.com/netmindz/balboa_GL_ML_spa_control.git ref: ESPHome refresh: 0s - # components: [BalboaGL,BalboaGLSensor] - - # Text sensors with general information. -text_sensor: - # Expose ESPHome version as sensor. - - platform: version - name: ESPHome Version - # Expose WiFi information as sensors. - - platform: wifi_info - ip_address: - name: IP - ssid: - name: SSID - bssid: - name: BSSID - - platform: BalboaGLSensor - state: - name: State - raw: - name: Raw Data - lcd: - name: LCD Display - -# Sensors with general information. -sensor: - # Uptime sensor. - - platform: uptime - name: Uptime - - # WiFi Signal sensor. - - platform: wifi_signal - name: WiFi Signal - update_interval: 60s - -switch: - - platform: BalboaGLSwitch - name: Light - -# select: -# - platform: BalboaGLSelect -# pump1: -# name: Pump1 -# options: "HIGH" - -climate: - - platform: BalboaGL - name: Temp - hardware_uart: UART1 - rx_pin: 3 - tx_pin: 10 - enable_pin: 5 - panel_select_pin: 6 - update_interval: 1000ms +BalboaGL: + name: Temp + hardware_uart: UART1 + rx_pin: 3 + tx_pin: 10 + enable_pin: 5 + panel_select_pin: 6 + update_interval: 220ms From 22bbfc69b0717f7ffa987a608c7934b4ac35ab34 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Tue, 17 Oct 2023 22:53:29 +0100 Subject: [PATCH 196/378] Create only state --- components/BalboaGL/ESPBalboaGL.cpp | 13 +++++++------ components/BalboaGL/ESPBalboaGL.h | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 0b88d72..2d7a698 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -24,7 +24,7 @@ BalboaGL::BalboaGL( this->traits_.set_visual_max_temperature(40); this->traits_.set_visual_temperature_step(0.5); - this->lightSwitch->setSpa(spa); + // this->lightSwitch->setSpa(spa); } void BalboaGL::check_logger_conflict_() { @@ -86,11 +86,11 @@ void BalboaGL::update() { // this->pump1->publish_state(pump_mode[status.pump1]); // this->pump2->publish_state(pump_mode[status.pump2]); - this->lightSwitch->publish_state(status.light); + // this->lightSwitch->publish_state(status.light); - this->stateSensor->update(); - this->rawSensor->update(); - this->lcdSensor->update(); + // this->stateSensor->update(); + // this->rawSensor->update(); + // this->lcdSensor->update(); this->publish_state(); } @@ -439,7 +439,8 @@ void BalboaGL::setup() { // heat_setpoint = load(heat_storage); // auto_setpoint = load(auto_storage); -// this->dump_config(); + ESP_LOGCONFIG(TAG, "End of seutp"); + this->dump_config(); } // /** diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 74de810..b7c01ca 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -94,10 +94,10 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - esphome::balboa_select::BalboaGLPump1Select* pump1; - esphome::balboa_select::BalboaGLPump2Select* pump2; + // esphome::balboa_select::BalboaGLPump1Select* pump1; + // esphome::balboa_select::BalboaGLPump2Select* pump2; - esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; + // esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; esphome::balboa_sensor::BalboaGLStateSensor* stateSensor; esphome::balboa_sensor::BalboaGLRawSensor* rawSensor; From f12f9de7c51f70b9468a13d8e0fe16977935116c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 09:52:53 +0100 Subject: [PATCH 197/378] Swap to basic TextSensor --- components/BalboaGL/ESPBalboaGL.cpp | 2 ++ components/BalboaGL/ESPBalboaGL.h | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2d7a698..06a4126 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -24,6 +24,8 @@ BalboaGL::BalboaGL( this->traits_.set_visual_max_temperature(40); this->traits_.set_visual_temperature_step(0.5); + this->rawSensor = new text_sensor::TextSensor(); + // this->lightSwitch->setSpa(spa); } diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index b7c01ca..ce7a64a 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -4,7 +4,7 @@ #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/text_sensor/text_sensor.h" #include "esphome/components/climate/climate.h" #include "esphome/core/log.h" #include "esp_log.h" @@ -99,9 +99,9 @@ class BalboaGL : public PollingComponent, public climate::Climate { // esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; - esphome::balboa_sensor::BalboaGLStateSensor* stateSensor; - esphome::balboa_sensor::BalboaGLRawSensor* rawSensor; - esphome::balboa_sensor::BalboaGLLCDSensor* lcdSensor; + esphome::text_sensor::TextSensor* stateSensor; + esphome::text_sensor::TextSensor* rawSensor; + esphome::text_sensor::TextSensor* lcdSensor; int rx_pin = -1; int tx_pin = -1; From be8fe55cf9b69138d93bb7caaa0ecbc1af725554 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 18:31:27 +0100 Subject: [PATCH 198/378] Swap to basic TextSensor --- components/BalboaGL/ESPBalboaGL.cpp | 10 +++--- components/BalboaGL/ESPBalboaGL.h | 2 +- components/BalboaGL/ESPBalboaGLSensor.h | 47 ------------------------- 3 files changed, 6 insertions(+), 53 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 06a4126..235ae12 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -25,6 +25,7 @@ BalboaGL::BalboaGL( this->traits_.set_visual_temperature_step(0.5); this->rawSensor = new text_sensor::TextSensor(); + this->stateSensor = new text_sensor::TextSensor(); // this->lightSwitch->setSpa(spa); } @@ -81,7 +82,7 @@ void BalboaGL::update() { } static String lastRaw = "0"; - if(status.rawData != lastRaw) { + // if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); lastRaw = status.rawData; @@ -90,12 +91,12 @@ void BalboaGL::update() { // this->lightSwitch->publish_state(status.light); - // this->stateSensor->update(); - // this->rawSensor->update(); + this->stateSensor->publish_state("testing"); // status.state.c_str()); + this->rawSensor->publish_state(status.rawData.c_str()); // this->lcdSensor->update(); this->publish_state(); - } + // } } @@ -400,7 +401,6 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->current_temperature = NAN; this->target_temperature = NAN; diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index ce7a64a..e83b381 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -101,7 +101,7 @@ class BalboaGL : public PollingComponent, public climate::Climate { esphome::text_sensor::TextSensor* stateSensor; esphome::text_sensor::TextSensor* rawSensor; - esphome::text_sensor::TextSensor* lcdSensor; + // esphome::text_sensor::TextSensor* lcdSensor; int rx_pin = -1; int tx_pin = -1; diff --git a/components/BalboaGL/ESPBalboaGLSensor.h b/components/BalboaGL/ESPBalboaGLSensor.h index 78bcb33..e69de29 100644 --- a/components/BalboaGL/ESPBalboaGLSensor.h +++ b/components/BalboaGL/ESPBalboaGLSensor.h @@ -1,47 +0,0 @@ -#pragma once - -#include "esphome.h" -#include "esphome/components/text_sensor/text_sensor.h" -#include "esp_log.h" -#include "balboaGL.h" - -extern struct BalboaStatus status; - -namespace esphome { - namespace balboa_sensor { - - static const char* TAG = "BalboaGLSensor"; // Logging tag - - using namespace text_sensor; - - class BalboaGLStateSensor : public TextSensor, public PollingComponent { - public: - BalboaGLStateSensor() : PollingComponent(15000) { } - void update() { - std::string state = status.state.c_str(); - ESP_LOGD(TAG, "State: %s", state.c_str()); - this->publish_state(state.c_str()); - } - - }; - - class BalboaGLRawSensor : public TextSensor, public PollingComponent { - public: - BalboaGLRawSensor() : PollingComponent(15000) { } - void update() { - this->publish_state(status.rawData.c_str()); - } - - }; - - class BalboaGLLCDSensor : public TextSensor, public PollingComponent { - public: - BalboaGLLCDSensor() : PollingComponent(15000) { } - void update() { - this->publish_state(status.lcd); - } - - }; - - } -} From 1aba257d6438fe8cbcc3078447dd6b782df4a640 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 19:31:14 +0100 Subject: [PATCH 199/378] Switch --- components/BalboaGL/BalboaGLSelect.h | 13 +++++++++++++ components/BalboaGL/BalboaGLSwitch.h | 4 ---- components/BalboaGL/ESPBalboaGL.cpp | 13 +++++++++---- components/BalboaGL/ESPBalboaGL.h | 7 +++---- components/BalboaGL/ESPBalboaGLSensor.h | 0 5 files changed, 25 insertions(+), 12 deletions(-) delete mode 100644 components/BalboaGL/ESPBalboaGLSensor.h diff --git a/components/BalboaGL/BalboaGLSelect.h b/components/BalboaGL/BalboaGLSelect.h index c8fdf6d..d3ca36a 100644 --- a/components/BalboaGL/BalboaGLSelect.h +++ b/components/BalboaGL/BalboaGLSelect.h @@ -3,16 +3,29 @@ #include "esphome/core/component.h" #include "esphome/components/select/select.h" +#include "balboaGL.h" + namespace esphome { namespace balboa_select { class BalboaGLPump1Select : public Component, public select::Select { public: + void setSpa(balboaGL* spa) { + this->spa = spa; + } + private: + balboaGL* spa; + }; class BalboaGLPump2Select : public Component, public select::Select { public: + void setSpa(balboaGL* spa) { + this->spa = spa; + } + private: + balboaGL* spa; }; diff --git a/components/BalboaGL/BalboaGLSwitch.h b/components/BalboaGL/BalboaGLSwitch.h index 7cbc035..88a411e 100644 --- a/components/BalboaGL/BalboaGLSwitch.h +++ b/components/BalboaGL/BalboaGLSwitch.h @@ -13,10 +13,6 @@ namespace esphome { void setSpa(balboaGL* spa) { this->spa = spa; } - void setup() override { - // This will be called by App.setup() - // pinMode(5, INPUT); - } void write_state(bool state) override { // This will be called every time the user requests a state change. diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 235ae12..f74b996 100644 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -27,7 +27,10 @@ BalboaGL::BalboaGL( this->rawSensor = new text_sensor::TextSensor(); this->stateSensor = new text_sensor::TextSensor(); - // this->lightSwitch->setSpa(spa); + this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); + + // this->pump1 = new balboa_select::BalboaGLPump1Select(); + // this->pump2 = new balboa_select::BalboaGLPump12elect(); } void BalboaGL::check_logger_conflict_() { @@ -82,21 +85,21 @@ void BalboaGL::update() { } static String lastRaw = "0"; - // if(status.rawData != lastRaw) { + if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); lastRaw = status.rawData; // this->pump1->publish_state(pump_mode[status.pump1]); // this->pump2->publish_state(pump_mode[status.pump2]); - // this->lightSwitch->publish_state(status.light); + this->lightSwitch->publish_state(status.light); this->stateSensor->publish_state("testing"); // status.state.c_str()); this->rawSensor->publish_state(status.rawData.c_str()); // this->lcdSensor->update(); this->publish_state(); - // } + } } @@ -408,6 +411,8 @@ void BalboaGL::setup() { this->swing_mode = climate::CLIMATE_SWING_OFF; this->action = climate::CLIMATE_ACTION_FAN; + this->lightSwitch->setSpa(spa); + // ESP_LOGCONFIG( // TAG, diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index e83b381..b12269f 100644 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -12,7 +12,6 @@ #include "BalboaGLSelect.h" #include "BalboaGLSwitch.h" #include "ESPBalboaGL.h" -#include "ESPBalboaGLSensor.h" static const char* TAG = "BalboaGL"; // Logging tag @@ -94,10 +93,10 @@ class BalboaGL : public PollingComponent, public climate::Climate { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - // esphome::balboa_select::BalboaGLPump1Select* pump1; - // esphome::balboa_select::BalboaGLPump2Select* pump2; + esphome::balboa_select::BalboaGLPump1Select* pump1; + esphome::balboa_select::BalboaGLPump2Select* pump2; - // esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; + esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; esphome::text_sensor::TextSensor* stateSensor; esphome::text_sensor::TextSensor* rawSensor; diff --git a/components/BalboaGL/ESPBalboaGLSensor.h b/components/BalboaGL/ESPBalboaGLSensor.h deleted file mode 100644 index e69de29..0000000 From 84b72486543191f5ce28682faf3c75ad465385cc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 22:18:13 +0100 Subject: [PATCH 200/378] Move files to new structure --- .../BalboaGL/{ => climate}/ESPBalboaGL.cpp | 0 .../BalboaGL/{ => climate}/ESPBalboaGL.h | 0 .../BalboaGL/{ => select}/BalboaGLSelect.h | 0 .../select}/__init__.py | 0 .../select}/select.py | 0 .../sensor}/__init__.py | 0 .../sensor}/text_sensor.py | 0 .../BalboaGL/{ => switch}/BalboaGLSwitch.h | 0 .../switch}/__init__.py | 0 .../switch}/switch.py | 0 components/ESPBalboaGL.cpp | 504 ++++++++++++++++++ components/ESPBalboaGL.h | 116 ++++ 12 files changed, 620 insertions(+) rename components/BalboaGL/{ => climate}/ESPBalboaGL.cpp (100%) rename components/BalboaGL/{ => climate}/ESPBalboaGL.h (100%) rename components/BalboaGL/{ => select}/BalboaGLSelect.h (100%) rename components/{BalboaGLSelect => BalboaGL/select}/__init__.py (100%) rename components/{BalboaGLSelect => BalboaGL/select}/select.py (100%) rename components/{BalboaGLSensor => BalboaGL/sensor}/__init__.py (100%) rename components/{BalboaGLSensor => BalboaGL/sensor}/text_sensor.py (100%) rename components/BalboaGL/{ => switch}/BalboaGLSwitch.h (100%) rename components/{BalboaGLSwitch => BalboaGL/switch}/__init__.py (100%) rename components/{BalboaGLSwitch => BalboaGL/switch}/switch.py (100%) create mode 100755 components/ESPBalboaGL.cpp create mode 100755 components/ESPBalboaGL.h diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/climate/ESPBalboaGL.cpp similarity index 100% rename from components/BalboaGL/ESPBalboaGL.cpp rename to components/BalboaGL/climate/ESPBalboaGL.cpp diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/climate/ESPBalboaGL.h similarity index 100% rename from components/BalboaGL/ESPBalboaGL.h rename to components/BalboaGL/climate/ESPBalboaGL.h diff --git a/components/BalboaGL/BalboaGLSelect.h b/components/BalboaGL/select/BalboaGLSelect.h similarity index 100% rename from components/BalboaGL/BalboaGLSelect.h rename to components/BalboaGL/select/BalboaGLSelect.h diff --git a/components/BalboaGLSelect/__init__.py b/components/BalboaGL/select/__init__.py similarity index 100% rename from components/BalboaGLSelect/__init__.py rename to components/BalboaGL/select/__init__.py diff --git a/components/BalboaGLSelect/select.py b/components/BalboaGL/select/select.py similarity index 100% rename from components/BalboaGLSelect/select.py rename to components/BalboaGL/select/select.py diff --git a/components/BalboaGLSensor/__init__.py b/components/BalboaGL/sensor/__init__.py similarity index 100% rename from components/BalboaGLSensor/__init__.py rename to components/BalboaGL/sensor/__init__.py diff --git a/components/BalboaGLSensor/text_sensor.py b/components/BalboaGL/sensor/text_sensor.py similarity index 100% rename from components/BalboaGLSensor/text_sensor.py rename to components/BalboaGL/sensor/text_sensor.py diff --git a/components/BalboaGL/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h similarity index 100% rename from components/BalboaGL/BalboaGLSwitch.h rename to components/BalboaGL/switch/BalboaGLSwitch.h diff --git a/components/BalboaGLSwitch/__init__.py b/components/BalboaGL/switch/__init__.py similarity index 100% rename from components/BalboaGLSwitch/__init__.py rename to components/BalboaGL/switch/__init__.py diff --git a/components/BalboaGLSwitch/switch.py b/components/BalboaGL/switch/switch.py similarity index 100% rename from components/BalboaGLSwitch/switch.py rename to components/BalboaGL/switch/switch.py diff --git a/components/ESPBalboaGL.cpp b/components/ESPBalboaGL.cpp new file mode 100755 index 0000000..ed8ebf5 --- /dev/null +++ b/components/ESPBalboaGL.cpp @@ -0,0 +1,504 @@ +#include +#include "ESPBalboaGL.h" +using namespace esphome; + +void telnetSend(String msg) { + ESP_LOGI(TAG, msg.c_str()); +} +/** + * Create a new BalboaGL object + * + * Args: + * hw_serial: pointer to an Arduino HardwareSerial instance + * poll_interval: polling interval in milliseconds + */ +BalboaGL::BalboaGL( + HardwareSerial* hw_serial +) : + hw_serial_{hw_serial} +{ + this->traits_.set_supports_action(false); + this->traits_.set_supports_current_temperature(true); + this->traits_.set_supports_two_point_target_temperature(false); + this->traits_.set_visual_min_temperature(26); + this->traits_.set_visual_max_temperature(40); + this->traits_.set_visual_temperature_step(0.5); + + this->rawSensor = new text_sensor::TextSensor(); + this->stateSensor = new text_sensor::TextSensor(); + + this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); + + // this->pump1 = new balboa_select::BalboaGLPump1Select(); + // this->pump2 = new balboa_select::BalboaGLPump12elect(); +} + +void BalboaGL::check_logger_conflict_() { +#ifdef USE_LOGGER + if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) { + ESP_LOGW(TAG, " You're using the same serial port for logging" + " and the BalboaGL component. Please disable" + " logging over the serial port by setting" + " logger:baud_rate to 0."); + } +#endif +} + +void BalboaGL::update() { + // This will be called every "update_interval" milliseconds. + ESP_LOGV(TAG, "Update called."); + size_t len = this->spa->readSerial(); + ESP_LOGV(TAG, "Read %u bytes", len); + bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); + if(panelSelect == HIGH) { + ESP_LOGV(TAG, "PanelSelect == HIGH"); + return; + } + else { + ESP_LOGD(TAG, "PanelSelect == LOW"); + } + + ESP_LOGD(TAG, "Current Temp: %f", status.temp); + ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); + this->current_temperature = status.temp; + this->target_temperature = status.targetTemp; + switch(status.mode) { + case MODE_IDX_STD: + this->custom_preset = std::string("STD"); + break; + case MODE_IDX_ECO: + this->custom_preset = std::string("ECO"); + break; + case MODE_IDX_SLP: + this->custom_preset = std::string("Sleep"); + break; + default: + this->custom_preset = std::string("UNKNOWN"); + break; + } + + if(status.heater) { + this->mode = climate::CLIMATE_MODE_HEAT; + } + else { + this->mode = climate::CLIMATE_MODE_AUTO; + } + + static String lastRaw = "0"; + if(status.rawData != lastRaw) { + ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); + lastRaw = status.rawData; + + // this->pump1->publish_state(pump_mode[status.pump1]); + // this->pump2->publish_state(pump_mode[status.pump2]); + + this->lightSwitch->publish_state(status.light); + + this->stateSensor->publish_state("testing"); // status.state.c_str()); + this->rawSensor->publish_state(status.rawData.c_str()); + // this->lcdSensor->update(); + + this->publish_state(); + } + +} + +/** + * Get our supported traits. + * + * Note: + * Many of the following traits are only available in the 1.5.0 dev train of + * ESPHome, particularly the Dry operation mode, and several of the fan modes. + * + * Returns: + * This class' supported climate::ClimateTraits. + */ +climate::ClimateTraits BalboaGL::traits() { + return traits_; +} + +/** + * Modify our supported traits. + * + * Returns: + * A reference to this class' supported climate::ClimateTraits. + */ +climate::ClimateTraits& BalboaGL::config_traits() { + return traits_; +} + +/** + * Implement control of a BalboaGL. + * + * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. + */ +void BalboaGL::control(const climate::ClimateCall &call) { + ESP_LOGV(TAG, "Control called."); + + bool updated = false; +// bool has_mode = call.get_mode().has_value(); + bool has_temp = call.get_target_temperature().has_value(); +// if (has_mode){ +// this->mode = *call.get_mode(); +// } +// switch (this->mode) { +// case climate::CLIMATE_MODE_COOL: +// hp->setModeSetting("COOL"); +// hp->setPowerSetting("ON"); + +// if (has_mode){ +// if (cool_setpoint.has_value() && !has_temp) { +// hp->setTemperature(cool_setpoint.value()); +// this->target_temperature = cool_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_HEAT: +// hp->setModeSetting("HEAT"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// if (heat_setpoint.has_value() && !has_temp) { +// hp->setTemperature(heat_setpoint.value()); +// this->target_temperature = heat_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_DRY: +// hp->setModeSetting("DRY"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// this->action = climate::CLIMATE_ACTION_DRYING; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_HEAT_COOL: +// hp->setModeSetting("AUTO"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// if (auto_setpoint.has_value() && !has_temp) { +// hp->setTemperature(auto_setpoint.value()); +// this->target_temperature = auto_setpoint.value(); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// updated = true; +// break; +// case climate::CLIMATE_MODE_FAN_ONLY: +// hp->setModeSetting("FAN"); +// hp->setPowerSetting("ON"); +// if (has_mode){ +// this->action = climate::CLIMATE_ACTION_FAN; +// updated = true; +// } +// break; +// case climate::CLIMATE_MODE_OFF: +// default: +// if (has_mode){ +// hp->setPowerSetting("OFF"); +// this->action = climate::CLIMATE_ACTION_OFF; +// updated = true; +// } +// break; +// } + + if (has_temp){ + ESP_LOGI( + "control", "Sending target temp: %.1f", + *call.get_target_temperature() + ); + this->spa->setTemp(*call.get_target_temperature()); + updated = true; + } + + +// ESP_LOGD(TAG, "control - Was SPA updated? %s", YESNO(updated)); + + // send the update back to esphome: + this->publish_state(); +} + +// void BalboaGL::hpSettingsChanged() { +// heatpumpSettings currentSettings = hp->getSettings(); + +// if (currentSettings.power == NULL) { +// /* +// * We should always get a valid pointer here once the HeatPump +// * component fully initializes. If HeatPump hasn't read the settings +// * from the unit yet (hp->connect() doesn't do this, sadly), we'll need +// * to punt on the update. Likely not an issue when run in callback +// * mode, but that isn't working right yet. +// */ +// ESP_LOGW(TAG, "Waiting for HeatPump to read the settings the first time."); +// esphome::delay(10); +// return; +// } + +// /* +// * ************ HANDLE POWER AND MODE CHANGES *********** +// * https://github.com/geoffdavis/HeatPump/blob/stream/src/HeatPump.h#L125 +// * const char* POWER_MAP[2] = {"OFF", "ON"}; +// * const char* MODE_MAP[5] = {"HEAT", "DRY", "COOL", "FAN", "AUTO"}; +// */ +// if (strcmp(currentSettings.power, "ON") == 0) { +// if (strcmp(currentSettings.mode, "HEAT") == 0) { +// this->mode = climate::CLIMATE_MODE_HEAT; +// if (heat_setpoint != currentSettings.temperature) { +// heat_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, heat_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else if (strcmp(currentSettings.mode, "DRY") == 0) { +// this->mode = climate::CLIMATE_MODE_DRY; +// this->action = climate::CLIMATE_ACTION_DRYING; +// } else if (strcmp(currentSettings.mode, "COOL") == 0) { +// this->mode = climate::CLIMATE_MODE_COOL; +// if (cool_setpoint != currentSettings.temperature) { +// cool_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, cool_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else if (strcmp(currentSettings.mode, "FAN") == 0) { +// this->mode = climate::CLIMATE_MODE_FAN_ONLY; +// this->action = climate::CLIMATE_ACTION_FAN; +// } else if (strcmp(currentSettings.mode, "AUTO") == 0) { +// this->mode = climate::CLIMATE_MODE_HEAT_COOL; +// if (auto_setpoint != currentSettings.temperature) { +// auto_setpoint = currentSettings.temperature; +// save(currentSettings.temperature, auto_storage); +// } +// this->action = climate::CLIMATE_ACTION_IDLE; +// } else { +// ESP_LOGW( +// TAG, +// "Unknown climate mode value %s received from HeatPump", +// currentSettings.mode +// ); +// } +// } else { +// this->mode = climate::CLIMATE_MODE_OFF; +// this->action = climate::CLIMATE_ACTION_OFF; +// } + +// ESP_LOGI(TAG, "Climate mode is: %i", this->mode); + +// /* +// * ******* HANDLE FAN CHANGES ******** +// * +// * const char* FAN_MAP[6] = {"AUTO", "QUIET", "1", "2", "3", "4"}; +// */ +// if (strcmp(currentSettings.fan, "QUIET") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_DIFFUSE; +// } else if (strcmp(currentSettings.fan, "1") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_LOW; +// } else if (strcmp(currentSettings.fan, "2") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_MEDIUM; +// } else if (strcmp(currentSettings.fan, "3") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_MIDDLE; +// } else if (strcmp(currentSettings.fan, "4") == 0) { +// this->fan_mode = climate::CLIMATE_FAN_HIGH; +// } else { //case "AUTO" or default: +// this->fan_mode = climate::CLIMATE_FAN_AUTO; +// } +// ESP_LOGI(TAG, "Fan mode is: %i", this->fan_mode); + +// /* ******** HANDLE MITSUBISHI VANE CHANGES ******** +// * const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; +// */ +// if (strcmp(currentSettings.vane, "SWING") == 0) { +// this->swing_mode = climate::CLIMATE_SWING_VERTICAL; +// } +// else { +// this->swing_mode = climate::CLIMATE_SWING_OFF; +// } +// ESP_LOGI(TAG, "Swing mode is: %i", this->swing_mode); + + + +// /* +// * ******** HANDLE TARGET TEMPERATURE CHANGES ******** +// */ +// this->target_temperature = currentSettings.temperature; +// ESP_LOGI(TAG, "Target temp is: %f", this->target_temperature); + +// /* +// * ******** Publish state back to ESPHome. ******** +// */ +// this->publish_state(); +// } + +// /** +// * Report changes in the current temperature sensed by the HeatPump. +// */ +// void BalboaGL::hpStatusChanged(heatpumpStatus currentStatus) { +// this->current_temperature = currentStatus.roomTemperature; +// switch (this->mode) { +// case climate::CLIMATE_MODE_HEAT: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_HEATING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_COOL: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_COOLING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_HEAT_COOL: +// this->action = climate::CLIMATE_ACTION_IDLE; +// if (currentStatus.operating) { +// if (this->current_temperature > this->target_temperature) { +// this->action = climate::CLIMATE_ACTION_COOLING; +// } else if (this->current_temperature < this->target_temperature) { +// this->action = climate::CLIMATE_ACTION_HEATING; +// } +// } +// break; +// case climate::CLIMATE_MODE_DRY: +// if (currentStatus.operating) { +// this->action = climate::CLIMATE_ACTION_DRYING; +// } +// else { +// this->action = climate::CLIMATE_ACTION_IDLE; +// } +// break; +// case climate::CLIMATE_MODE_FAN_ONLY: +// this->action = climate::CLIMATE_ACTION_FAN; +// break; +// default: +// this->action = climate::CLIMATE_ACTION_OFF; +// } + +// this->publish_state(); +// } + +// void BalboaGL::set_remote_temperature(float temp) { +// ESP_LOGD(TAG, "Setting remote temp: %.1f", temp); +// this->hp->setRemoteTemperature(temp); +// } + +void BalboaGL::setup() { + // This will be called by App.setup() + // this->banner(); + ESP_LOGCONFIG(TAG, "Setting up UART..."); + if (!this->get_hw_serial_()) { + ESP_LOGCONFIG( + TAG, + "No HardwareSerial was provided. " + "Software serial ports are unsupported by this component." + ); + this->mark_failed(); + return; + } + this->check_logger_conflict_(); + + ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); + + ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); + this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); + this->current_temperature = NAN; + this->target_temperature = NAN; + this->fan_mode = climate::CLIMATE_FAN_OFF; + this->swing_mode = climate::CLIMATE_SWING_OFF; + this->action = climate::CLIMATE_ACTION_FAN; + + this->lightSwitch->setSpa(spa); + + // this->pump1->setSpa(spa); + // this->pump2->setSpa(spa); + +// ESP_LOGCONFIG( +// TAG, +// "hw_serial(%p) is &Serial(%p)? %s", +// this->get_hw_serial_(), +// &Serial, +// YESNO(this->get_hw_serial_() == &Serial) +// ); + +// ESP_LOGCONFIG(TAG, "Calling hp->connect(%p)", this->get_hw_serial_()); + +// if (hp->connect(this->get_hw_serial_(), this->baud_, -1, -1)) { +// hp->sync(); +// } +// else { +// ESP_LOGCONFIG( +// TAG, +// "Connection to HeatPump failed." +// " Marking BalboaGL component as failed." +// ); +// this->mark_failed(); +// } + +// // create various setpoint persistence: +// cool_storage = global_preferences->make_preference(this->get_object_id_hash() + 1); +// heat_storage = global_preferences->make_preference(this->get_object_id_hash() + 2); +// auto_storage = global_preferences->make_preference(this->get_object_id_hash() + 3); + +// // load values from storage: +// cool_setpoint = load(cool_storage); +// heat_setpoint = load(heat_storage); +// auto_setpoint = load(auto_storage); + + ESP_LOGCONFIG(TAG, "End of seutp"); + this->dump_config(); +} + +// /** +// * The ESP only has a few bytes of rtc storage, so instead +// * of storing floats directly, we'll store the number of +// * TEMPERATURE_STEPs from MIN_TEMPERATURE. +// **/ +// void BalboaGL::save(float value, ESPPreferenceObject& storage) { +// uint8_t steps = (value - ESPMHP_MIN_TEMPERATURE) / ESPMHP_TEMPERATURE_STEP; +// storage.save(&steps); +// } + +// optional BalboaGL::load(ESPPreferenceObject& storage) { +// uint8_t steps = 0; +// if (!storage.load(&steps)) { +// return {}; +// } +// return ESPMHP_MIN_TEMPERATURE + (steps * ESPMHP_TEMPERATURE_STEP); +// } + +void BalboaGL::dump_config() { + // this->banner(); + ESP_LOGI(TAG, " rx,tx = %u,%u", this->rx_pin, this->tx_pin); + ESP_LOGI(TAG, " rts_pin = %u", this->rts_pin); + ESP_LOGI(TAG, " panel_select_pin = %u", this->panel_select_pin); +// ESP_LOGI(TAG, " Supports HEAT: %s", YESNO(true)); +// ESP_LOGI(TAG, " Supports COOL: %s", YESNO(true)); +// ESP_LOGI(TAG, " Supports AWAY mode: %s", YESNO(false)); +// ESP_LOGI(TAG, " Saved heat: %.1f", heat_setpoint.value_or(-1)); +// ESP_LOGI(TAG, " Saved cool: %.1f", cool_setpoint.value_or(-1)); +// ESP_LOGI(TAG, " Saved auto: %.1f", auto_setpoint.value_or(-1)); +} + +// void BalboaGL::dump_state() { +// LOG_CLIMATE("", "BalboaGL Climate", this); +// ESP_LOGI(TAG, "HELLO"); +// } + +void BalboaGL::set_rx_pin(int pin) { + this->rx_pin = pin; +} + +void BalboaGL::set_tx_pin(int pin) { + this->tx_pin = pin; +} +void BalboaGL::set_rts_pin(int pin) { + this->rts_pin = pin; +} + +void BalboaGL::set_panel_select_pin(int pin) { + this->panel_select_pin = pin; +} diff --git a/components/ESPBalboaGL.h b/components/ESPBalboaGL.h new file mode 100755 index 0000000..b12269f --- /dev/null +++ b/components/ESPBalboaGL.h @@ -0,0 +1,116 @@ +#ifndef ESPMHP_H +#define ESPMHP_H + +#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" + +#include "BalboaGLSelect.h" +#include "BalboaGLSwitch.h" +#include "ESPBalboaGL.h" + +static const char* TAG = "BalboaGL"; // Logging tag + +// // Perform measurements or read nameplate values on your tub to define the power [kW] +// // for each device in order to calculate tub power usage +// const float POWER_HEATER = 2.8; +// const float POWER_PUMP_CIRCULATION = 0.3; +// const float POWER_PUMP1_LOW = 0.31; +// const float POWER_PUMP1_HIGH = 1.3; +// const float POWER_PUMP2_LOW = 0.3; +// const float POWER_PUMP2_HIGH = 0.6; + +// // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc +// const int MINUTES_PER_DEGC = 45; + +const uint32_t POLL_INTERVAL_DEFAULT = 10000; + +#include "balboaGL.h" + +using namespace esphome; + +class BalboaGL : public PollingComponent, public climate::Climate { + public: + BalboaGL( + HardwareSerial* hw_serial + ); + + // print the current configuration + void dump_config() override; + + // // handle a change in settings as detected by the HeatPump library. + // void hpSettingsChanged(); + + // // Handle a change in status as detected by the HeatPump library. + // void hpStatusChanged(heatpumpStatus currentStatus); + + // Set up the component, initializing the balboaGL object. + void setup() override; + + // This is called every poll_interval. + void update() override; + + // Configure the climate object with traits that we support. + climate::ClimateTraits traits() override; + + // Get a mutable reference to the traits that we support. + climate::ClimateTraits& config_traits(); + + // Debugging function to print the object's state. + // void dump_state(); + + // Handle a request from the user to change settings. + void control(const climate::ClimateCall &call) override; + + // // Use the temperature from an external sensor. Use + // // set_remote_temp(0) to switch back to the internal sensor. + // void set_remote_temperature(float); + + void set_rx_pin(int pin); + + void set_tx_pin(int pin); + + void set_rts_pin(int pin); + + void set_panel_select_pin(int pin); + + float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } + + protected: + // The ClimateTraits supported by this HeatPump. + climate::ClimateTraits traits_; + + //Accessor method for the HardwareSerial pointer + HardwareSerial* get_hw_serial_() { + return this->hw_serial_; + } + + //Print a warning message if we're using the sole hardware UART on an + //ESP8266 or UART0 on ESP32 + void check_logger_conflict_(); + + esphome::balboa_select::BalboaGLPump1Select* pump1; + esphome::balboa_select::BalboaGLPump2Select* pump2; + + esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; + + esphome::text_sensor::TextSensor* stateSensor; + esphome::text_sensor::TextSensor* rawSensor; + // esphome::text_sensor::TextSensor* lcdSensor; + + int rx_pin = -1; + int tx_pin = -1; + int rts_pin = -1; + int panel_select_pin = -1; + + private: + // Retrieve the HardwareSerial pointer from friend and subclasses. + HardwareSerial *hw_serial_; + + balboaGL* spa; +}; +#endif \ No newline at end of file From 4dadf6f1fddf2ec0056941f98a49595cb696e24a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 22:29:27 +0100 Subject: [PATCH 201/378] Sepparate climate from main component --- .../{ESPBalboaGL.h => BalboaGLClimate.h} | 45 +--------- components/BalboaGL/climate/ESPBalboaGL.cpp | 88 ++----------------- components/ESPBalboaGL.h | 20 +---- 3 files changed, 9 insertions(+), 144 deletions(-) rename components/BalboaGL/climate/{ESPBalboaGL.h => BalboaGLClimate.h} (62%) diff --git a/components/BalboaGL/climate/ESPBalboaGL.h b/components/BalboaGL/climate/BalboaGLClimate.h similarity index 62% rename from components/BalboaGL/climate/ESPBalboaGL.h rename to components/BalboaGL/climate/BalboaGLClimate.h index b12269f..e081117 100644 --- a/components/BalboaGL/climate/ESPBalboaGL.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -9,10 +9,6 @@ #include "esphome/core/log.h" #include "esp_log.h" -#include "BalboaGLSelect.h" -#include "BalboaGLSwitch.h" -#include "ESPBalboaGL.h" - static const char* TAG = "BalboaGL"; // Logging tag // // Perform measurements or read nameplate values on your tub to define the power [kW] @@ -33,11 +29,8 @@ const uint32_t POLL_INTERVAL_DEFAULT = 10000; using namespace esphome; -class BalboaGL : public PollingComponent, public climate::Climate { +class BalboaGLClimate : public PollingComponent, public climate::Climate { public: - BalboaGL( - HardwareSerial* hw_serial - ); // print the current configuration void dump_config() override; @@ -70,47 +63,11 @@ class BalboaGL : public PollingComponent, public climate::Climate { // // set_remote_temp(0) to switch back to the internal sensor. // void set_remote_temperature(float); - void set_rx_pin(int pin); - - void set_tx_pin(int pin); - - void set_rts_pin(int pin); - - void set_panel_select_pin(int pin); - - float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } - protected: // The ClimateTraits supported by this HeatPump. climate::ClimateTraits traits_; - //Accessor method for the HardwareSerial pointer - HardwareSerial* get_hw_serial_() { - return this->hw_serial_; - } - - //Print a warning message if we're using the sole hardware UART on an - //ESP8266 or UART0 on ESP32 - void check_logger_conflict_(); - - esphome::balboa_select::BalboaGLPump1Select* pump1; - esphome::balboa_select::BalboaGLPump2Select* pump2; - - esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; - - esphome::text_sensor::TextSensor* stateSensor; - esphome::text_sensor::TextSensor* rawSensor; - // esphome::text_sensor::TextSensor* lcdSensor; - - int rx_pin = -1; - int tx_pin = -1; - int rts_pin = -1; - int panel_select_pin = -1; - private: - // Retrieve the HardwareSerial pointer from friend and subclasses. - HardwareSerial *hw_serial_; - balboaGL* spa; }; #endif \ No newline at end of file diff --git a/components/BalboaGL/climate/ESPBalboaGL.cpp b/components/BalboaGL/climate/ESPBalboaGL.cpp index f74b996..0e952ff 100644 --- a/components/BalboaGL/climate/ESPBalboaGL.cpp +++ b/components/BalboaGL/climate/ESPBalboaGL.cpp @@ -2,49 +2,8 @@ #include "ESPBalboaGL.h" using namespace esphome; -void telnetSend(String msg) { - ESP_LOGI(TAG, msg.c_str()); -} -/** - * Create a new BalboaGL object - * - * Args: - * hw_serial: pointer to an Arduino HardwareSerial instance - * poll_interval: polling interval in milliseconds - */ -BalboaGL::BalboaGL( - HardwareSerial* hw_serial -) : - hw_serial_{hw_serial} -{ - this->traits_.set_supports_action(false); - this->traits_.set_supports_current_temperature(true); - this->traits_.set_supports_two_point_target_temperature(false); - this->traits_.set_visual_min_temperature(26); - this->traits_.set_visual_max_temperature(40); - this->traits_.set_visual_temperature_step(0.5); - - this->rawSensor = new text_sensor::TextSensor(); - this->stateSensor = new text_sensor::TextSensor(); - - this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); - - // this->pump1 = new balboa_select::BalboaGLPump1Select(); - // this->pump2 = new balboa_select::BalboaGLPump12elect(); -} -void BalboaGL::check_logger_conflict_() { -#ifdef USE_LOGGER - if (this->get_hw_serial_() == logger::global_logger->get_hw_serial()) { - ESP_LOGW(TAG, " You're using the same serial port for logging" - " and the BalboaGL component. Please disable" - " logging over the serial port by setting" - " logger:baud_rate to 0."); - } -#endif -} - -void BalboaGL::update() { +void BalboaGLClimate::update() { // This will be called every "update_interval" milliseconds. ESP_LOGV(TAG, "Update called."); size_t len = this->spa->readSerial(); @@ -132,7 +91,7 @@ climate::ClimateTraits& BalboaGL::config_traits() { * * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. */ -void BalboaGL::control(const climate::ClimateCall &call) { +void BalboaGLClimate::control(const climate::ClimateCall &call) { ESP_LOGV(TAG, "Control called."); bool updated = false; @@ -385,35 +344,18 @@ void BalboaGL::control(const climate::ClimateCall &call) { // this->hp->setRemoteTemperature(temp); // } -void BalboaGL::setup() { +void BalboaGLClimate::setup() { // This will be called by App.setup() // this->banner(); - ESP_LOGCONFIG(TAG, "Setting up UART..."); - if (!this->get_hw_serial_()) { - ESP_LOGCONFIG( - TAG, - "No HardwareSerial was provided. " - "Software serial ports are unsupported by this component." - ); - this->mark_failed(); - return; - } - this->check_logger_conflict_(); + + ESP_LOGCONFIG(TAG, "Initialize new balboaGLCliamte object."); - ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - - ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); - hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->current_temperature = NAN; this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; this->action = climate::CLIMATE_ACTION_FAN; - this->lightSwitch->setSpa(spa); - - // ESP_LOGCONFIG( // TAG, // "hw_serial(%p) is &Serial(%p)? %s", @@ -468,11 +410,8 @@ void BalboaGL::setup() { // return ESPMHP_MIN_TEMPERATURE + (steps * ESPMHP_TEMPERATURE_STEP); // } -void BalboaGL::dump_config() { +void BalboaGLClimate::dump_config() { // this->banner(); - ESP_LOGI(TAG, " rx,tx = %u,%u", this->rx_pin, this->tx_pin); - ESP_LOGI(TAG, " rts_pin = %u", this->rts_pin); - ESP_LOGI(TAG, " panel_select_pin = %u", this->panel_select_pin); // ESP_LOGI(TAG, " Supports HEAT: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports COOL: %s", YESNO(true)); // ESP_LOGI(TAG, " Supports AWAY mode: %s", YESNO(false)); @@ -485,18 +424,3 @@ void BalboaGL::dump_config() { // LOG_CLIMATE("", "BalboaGL Climate", this); // ESP_LOGI(TAG, "HELLO"); // } - -void BalboaGL::set_rx_pin(int pin) { - this->rx_pin = pin; -} - -void BalboaGL::set_tx_pin(int pin) { - this->tx_pin = pin; -} -void BalboaGL::set_rts_pin(int pin) { - this->rts_pin = pin; -} - -void BalboaGL::set_panel_select_pin(int pin) { - this->panel_select_pin = pin; -} diff --git a/components/ESPBalboaGL.h b/components/ESPBalboaGL.h index b12269f..355ae37 100755 --- a/components/ESPBalboaGL.h +++ b/components/ESPBalboaGL.h @@ -5,7 +5,6 @@ #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" @@ -33,7 +32,7 @@ const uint32_t POLL_INTERVAL_DEFAULT = 10000; using namespace esphome; -class BalboaGL : public PollingComponent, public climate::Climate { +class BalboaGL : public PollingComponent { public: BalboaGL( HardwareSerial* hw_serial @@ -54,22 +53,9 @@ class BalboaGL : public PollingComponent, public climate::Climate { // This is called every poll_interval. void update() override; - // Configure the climate object with traits that we support. - climate::ClimateTraits traits() override; - - // Get a mutable reference to the traits that we support. - climate::ClimateTraits& config_traits(); - // Debugging function to print the object's state. // void dump_state(); - // Handle a request from the user to change settings. - void control(const climate::ClimateCall &call) override; - - // // Use the temperature from an external sensor. Use - // // set_remote_temp(0) to switch back to the internal sensor. - // void set_remote_temperature(float); - void set_rx_pin(int pin); void set_tx_pin(int pin); @@ -81,9 +67,7 @@ class BalboaGL : public PollingComponent, public climate::Climate { float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } protected: - // The ClimateTraits supported by this HeatPump. - climate::ClimateTraits traits_; - + //Accessor method for the HardwareSerial pointer HardwareSerial* get_hw_serial_() { return this->hw_serial_; From a19ea1c73a6a8f98017af6da3ee8cafa71fdce19 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 22:35:15 +0100 Subject: [PATCH 202/378] Move files --- components/{ => BalboaGL}/ESPBalboaGL.cpp | 0 components/{ => BalboaGL}/ESPBalboaGL.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename components/{ => BalboaGL}/ESPBalboaGL.cpp (100%) rename components/{ => BalboaGL}/ESPBalboaGL.h (100%) diff --git a/components/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp similarity index 100% rename from components/ESPBalboaGL.cpp rename to components/BalboaGL/ESPBalboaGL.cpp diff --git a/components/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h similarity index 100% rename from components/ESPBalboaGL.h rename to components/BalboaGL/ESPBalboaGL.h From 92abf29ddd517263d17e279043fd4f7da86ef953 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 22:45:39 +0100 Subject: [PATCH 203/378] Move files --- components/BalboaGL/ESPBalboaGL.cpp | 187 ++++------------------------ components/BalboaGL/ESPBalboaGL.h | 14 +-- 2 files changed, 34 insertions(+), 167 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index ed8ebf5..8a107f1 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -17,17 +17,11 @@ BalboaGL::BalboaGL( ) : hw_serial_{hw_serial} { - this->traits_.set_supports_action(false); - this->traits_.set_supports_current_temperature(true); - this->traits_.set_supports_two_point_target_temperature(false); - this->traits_.set_visual_min_temperature(26); - this->traits_.set_visual_max_temperature(40); - this->traits_.set_visual_temperature_step(0.5); + + // this->rawSensor = new text_sensor::TextSensor(); + // this->stateSensor = new text_sensor::TextSensor(); - this->rawSensor = new text_sensor::TextSensor(); - this->stateSensor = new text_sensor::TextSensor(); - - this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); + // this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); // this->pump1 = new balboa_select::BalboaGLPump1Select(); // this->pump2 = new balboa_select::BalboaGLPump12elect(); @@ -60,29 +54,23 @@ void BalboaGL::update() { ESP_LOGD(TAG, "Current Temp: %f", status.temp); ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); - this->current_temperature = status.temp; - this->target_temperature = status.targetTemp; - switch(status.mode) { - case MODE_IDX_STD: - this->custom_preset = std::string("STD"); - break; - case MODE_IDX_ECO: - this->custom_preset = std::string("ECO"); - break; - case MODE_IDX_SLP: - this->custom_preset = std::string("Sleep"); - break; - default: - this->custom_preset = std::string("UNKNOWN"); - break; - } + // this->current_temperature = status.temp; + // this->target_temperature = status.targetTemp; + // switch(status.mode) { + // case MODE_IDX_STD: + // this->custom_preset = std::string("STD"); + // break; + // case MODE_IDX_ECO: + // this->custom_preset = std::string("ECO"); + // break; + // case MODE_IDX_SLP: + // this->custom_preset = std::string("Sleep"); + // break; + // default: + // this->custom_preset = std::string("UNKNOWN"); + // break; + // } - if(status.heater) { - this->mode = climate::CLIMATE_MODE_HEAT; - } - else { - this->mode = climate::CLIMATE_MODE_AUTO; - } static String lastRaw = "0"; if(status.rawData != lastRaw) { @@ -92,133 +80,15 @@ void BalboaGL::update() { // this->pump1->publish_state(pump_mode[status.pump1]); // this->pump2->publish_state(pump_mode[status.pump2]); - this->lightSwitch->publish_state(status.light); + // this->lightSwitch->publish_state(status.light); - this->stateSensor->publish_state("testing"); // status.state.c_str()); - this->rawSensor->publish_state(status.rawData.c_str()); + // this->stateSensor->publish_state("testing"); // status.state.c_str()); + // this->rawSensor->publish_state(status.rawData.c_str()); // this->lcdSensor->update(); - this->publish_state(); - } - -} - -/** - * Get our supported traits. - * - * Note: - * Many of the following traits are only available in the 1.5.0 dev train of - * ESPHome, particularly the Dry operation mode, and several of the fan modes. - * - * Returns: - * This class' supported climate::ClimateTraits. - */ -climate::ClimateTraits BalboaGL::traits() { - return traits_; -} - -/** - * Modify our supported traits. - * - * Returns: - * A reference to this class' supported climate::ClimateTraits. - */ -climate::ClimateTraits& BalboaGL::config_traits() { - return traits_; -} - -/** - * Implement control of a BalboaGL. - * - * Maps HomeAssistant/ESPHome modes to Mitsubishi modes. - */ -void BalboaGL::control(const climate::ClimateCall &call) { - ESP_LOGV(TAG, "Control called."); - - bool updated = false; -// bool has_mode = call.get_mode().has_value(); - bool has_temp = call.get_target_temperature().has_value(); -// if (has_mode){ -// this->mode = *call.get_mode(); -// } -// switch (this->mode) { -// case climate::CLIMATE_MODE_COOL: -// hp->setModeSetting("COOL"); -// hp->setPowerSetting("ON"); - -// if (has_mode){ -// if (cool_setpoint.has_value() && !has_temp) { -// hp->setTemperature(cool_setpoint.value()); -// this->target_temperature = cool_setpoint.value(); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// updated = true; -// } -// break; -// case climate::CLIMATE_MODE_HEAT: -// hp->setModeSetting("HEAT"); -// hp->setPowerSetting("ON"); -// if (has_mode){ -// if (heat_setpoint.has_value() && !has_temp) { -// hp->setTemperature(heat_setpoint.value()); -// this->target_temperature = heat_setpoint.value(); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// updated = true; -// } -// break; -// case climate::CLIMATE_MODE_DRY: -// hp->setModeSetting("DRY"); -// hp->setPowerSetting("ON"); -// if (has_mode){ -// this->action = climate::CLIMATE_ACTION_DRYING; -// updated = true; -// } -// break; -// case climate::CLIMATE_MODE_HEAT_COOL: -// hp->setModeSetting("AUTO"); -// hp->setPowerSetting("ON"); -// if (has_mode){ -// if (auto_setpoint.has_value() && !has_temp) { -// hp->setTemperature(auto_setpoint.value()); -// this->target_temperature = auto_setpoint.value(); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// } -// updated = true; -// break; -// case climate::CLIMATE_MODE_FAN_ONLY: -// hp->setModeSetting("FAN"); -// hp->setPowerSetting("ON"); -// if (has_mode){ -// this->action = climate::CLIMATE_ACTION_FAN; -// updated = true; -// } -// break; -// case climate::CLIMATE_MODE_OFF: -// default: -// if (has_mode){ -// hp->setPowerSetting("OFF"); -// this->action = climate::CLIMATE_ACTION_OFF; -// updated = true; -// } -// break; -// } - - if (has_temp){ - ESP_LOGI( - "control", "Sending target temp: %.1f", - *call.get_target_temperature() - ); - this->spa->setTemp(*call.get_target_temperature()); - updated = true; + // this->publish_state(); } - -// ESP_LOGD(TAG, "control - Was SPA updated? %s", YESNO(updated)); - - // send the update back to esphome: - this->publish_state(); } // void BalboaGL::hpSettingsChanged() { @@ -405,13 +275,10 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); - this->current_temperature = NAN; - this->target_temperature = NAN; - this->fan_mode = climate::CLIMATE_FAN_OFF; - this->swing_mode = climate::CLIMATE_SWING_OFF; - this->action = climate::CLIMATE_ACTION_FAN; + // this->current_temperature = NAN; + // this->target_temperature = NAN; - this->lightSwitch->setSpa(spa); + // this->lightSwitch->setSpa(spa); // this->pump1->setSpa(spa); // this->pump2->setSpa(spa); diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 355ae37..98f9732 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,8 +8,8 @@ #include "esphome/core/log.h" #include "esp_log.h" -#include "BalboaGLSelect.h" -#include "BalboaGLSwitch.h" +// #include "BalboaGLSelect.h" +// #include "BalboaGLSwitch.h" #include "ESPBalboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag @@ -77,13 +77,13 @@ class BalboaGL : public PollingComponent { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - esphome::balboa_select::BalboaGLPump1Select* pump1; - esphome::balboa_select::BalboaGLPump2Select* pump2; + // esphome::balboa_select::BalboaGLPump1Select* pump1; + // esphome::balboa_select::BalboaGLPump2Select* pump2; - esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; + // esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; - esphome::text_sensor::TextSensor* stateSensor; - esphome::text_sensor::TextSensor* rawSensor; + // esphome::text_sensor::TextSensor* stateSensor; + // esphome::text_sensor::TextSensor* rawSensor; // esphome::text_sensor::TextSensor* lcdSensor; int rx_pin = -1; From 9ad5d260b465de5f010fac831b12551022fa3bf6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 22:51:49 +0100 Subject: [PATCH 204/378] Remove climate from top-level init.py --- components/BalboaGL/__init__.py | 35 +++++---------------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 59b8dff..2bfffde 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -1,14 +1,10 @@ import esphome.codegen as cg import esphome.config_validation as cv -from esphome.components import climate from esphome.components.logger import HARDWARE_UART_TO_SERIAL from esphome.const import ( CONF_ID, CONF_HARDWARE_UART, CONF_UPDATE_INTERVAL, - CONF_MODE, - CONF_FAN_MODE, - CONF_SWING_MODE, CONF_RX_PIN, CONF_TX_PIN, ) @@ -17,15 +13,12 @@ AUTO_LOAD = ["climate","switch","select","sensor","text_sensor"] CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] -DEFAULT_FAN_MODES = ["OFF"] -DEFAULT_SWING_MODES = ["OFF"] CONF_ENABLE_PIN = "enable_pin" CONF_PANEL_SELECT_PIN = "panel_select_pin" BalboaGL = cg.global_ns.class_( - "BalboaGL", climate.Climate, cg.PollingComponent + "BalboaGL", cg.PollingComponent ) @@ -38,7 +31,8 @@ def valid_uart(uart): return cv.one_of(*uarts, upper=True)(uart) -CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( +CONFIG_SCHEMA = ( + cv.Schema( { cv.GenerateID(): cv.declare_id(BalboaGL), cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, @@ -54,15 +48,9 @@ def valid_uart(uart): # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { - cv.Optional(CONF_MODE, default=DEFAULT_CLIMATE_MODES): - cv.ensure_list(climate.validate_climate_mode), - cv.Optional(CONF_FAN_MODE, default=DEFAULT_FAN_MODES): - cv.ensure_list(climate.validate_climate_fan_mode), - cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): - cv.ensure_list(climate.validate_climate_swing_mode), } ), - } + }) ).extend(cv.COMPONENT_SCHEMA) @@ -74,19 +62,6 @@ def to_code(config): supports = config[CONF_SUPPORTS] traits = var.config_traits() - for mode in supports[CONF_MODE]: - if mode == "OFF": - continue - cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) - - for mode in supports[CONF_FAN_MODE]: - cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) - - for mode in supports[CONF_SWING_MODE]: - cg.add(traits.add_supported_swing_mode( - climate.CLIMATE_SWING_MODES[mode] - )) - if CONF_RX_PIN in config: cg.add(var.set_rx_pin(config[CONF_RX_PIN])) @@ -101,7 +76,7 @@ def to_code(config): yield cg.register_component(var, config) - yield climate.register_climate(var, config) + cg.add_library( name="ArduinoQueue", repository="https://github.com/EinarArnason/ArduinoQueue.git", From bdcd886a63fc6ff1deb846aba95fb48bd86c252f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Wed, 18 Oct 2023 23:07:59 +0100 Subject: [PATCH 205/378] Add init for climate --- components/BalboaGL/climate/__init__.py | 87 +++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 components/BalboaGL/climate/__init__.py diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py new file mode 100644 index 0000000..25fbed4 --- /dev/null +++ b/components/BalboaGL/climate/__init__.py @@ -0,0 +1,87 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import climate +from esphome.components.logger import HARDWARE_UART_TO_SERIAL +from esphome.const import ( + CONF_ID, + CONF_HARDWARE_UART, + CONF_UPDATE_INTERVAL, + CONF_MODE, + CONF_FAN_MODE, + CONF_SWING_MODE, +) +from esphome.core import CORE, coroutine + +AUTO_LOAD = ["climate"] + +DEPENDENCIES = ["BalboaGL"] + + +CONF_SUPPORTS = "supports" +DEFAULT_CLIMATE_MODES = ["HEAT","AUTO"] +DEFAULT_FAN_MODES = ["OFF"] +DEFAULT_SWING_MODES = ["OFF"] + +BalboaGL = cg.global_ns.class_( + "BalboaGL", climate.Climate, cg.PollingComponent +) + + +def valid_uart(uart): + if CORE.is_esp32: + uarts = [ "UART1", "UART2"] + else: + raise NotImplementedError + + return cv.one_of(*uarts, upper=True)(uart) + + +CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(BalboaGL), + cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, + # If polling interval is greater than 9 seconds, the HeatPump library + # reconnects, but doesn't then follow up with our data request. + cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( + cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) + ), + # Optionally override the supported ClimateTraits. + cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( + { + cv.Optional(CONF_MODE, default=DEFAULT_CLIMATE_MODES): + cv.ensure_list(climate.validate_climate_mode), + cv.Optional(CONF_FAN_MODE, default=DEFAULT_FAN_MODES): + cv.ensure_list(climate.validate_climate_fan_mode), + cv.Optional(CONF_SWING_MODE, default=DEFAULT_SWING_MODES): + cv.ensure_list(climate.validate_climate_swing_mode), + } + ), + } +).extend(cv.COMPONENT_SCHEMA) + + +@coroutine +def to_code(config): + serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] + var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) + + supports = config[CONF_SUPPORTS] + traits = var.config_traits() + + for mode in supports[CONF_MODE]: + if mode == "OFF": + continue + cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) + + for mode in supports[CONF_FAN_MODE]: + cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) + + for mode in supports[CONF_SWING_MODE]: + cg.add(traits.add_supported_swing_mode( + climate.CLIMATE_SWING_MODES[mode] + )) + + + + yield cg.register_component(var, config) + yield climate.register_climate(var, config) From 24216e7148a2f3f5d2058a020b8a80680c68c1a3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 10:09:39 +0100 Subject: [PATCH 206/378] Add switch python config --- components/BalboaGL/__init__.py | 8 +++++--- components/BalboaGL/switch/switch.py | 30 +++++++++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 2bfffde..2b01445 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -12,11 +12,14 @@ AUTO_LOAD = ["climate","switch","select","sensor","text_sensor"] +CODEOWNERS = ["@netmindz"] + CONF_SUPPORTS = "supports" CONF_ENABLE_PIN = "enable_pin" CONF_PANEL_SELECT_PIN = "panel_select_pin" +balboagl_ns = cg.esphome_ns.namespace("balboagl") BalboaGL = cg.global_ns.class_( "BalboaGL", cg.PollingComponent ) @@ -31,6 +34,8 @@ def valid_uart(uart): return cv.one_of(*uarts, upper=True)(uart) +CONF_BALBOA_ID = "balboa_id" + CONFIG_SCHEMA = ( cv.Schema( { @@ -59,9 +64,6 @@ def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) - supports = config[CONF_SUPPORTS] - traits = var.config_traits() - if CONF_RX_PIN in config: cg.add(var.set_rx_pin(config[CONF_RX_PIN])) diff --git a/components/BalboaGL/switch/switch.py b/components/BalboaGL/switch/switch.py index 7fd1a2e..faa5379 100644 --- a/components/BalboaGL/switch/switch.py +++ b/components/BalboaGL/switch/switch.py @@ -3,14 +3,26 @@ from esphome.components import switch from esphome.const import CONF_ID -empty_switch_ns = cg.esphome_ns.namespace('balboa_switch') -LightSwitch = empty_switch_ns.class_('BalboaGLLightSwitch', switch.Switch, cg.Component) +from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL -CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(LightSwitch) -}).extend(cv.COMPONENT_SCHEMA) +DEPENDENCIES = ["BalboaGL"] + +LightSwitch = balboa_ns.class_('LightSwitch', switch.Switch, cg.Component) + +CONFIG_SCHEMA = ( + switch.switch_schema(LightSwitch) + .extend( + { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + } + ) + .extend(cv.COMPONENT_SCHEMA) +) + +async def to_code(config): + var = await switch.new_switch(config) + await cg.register_component(var, config) + + paren = await cg.get_variable(config[CONF_BALBOA_ID]) + cg.add(var.set_balboa_parent(paren)) -def to_code(config): - var = cg.new_Pvariable(config[CONF_ID]) - yield cg.register_component(var, config) - yield switch.register_switch(var, config) From 57cc2abd7a20d44afa9f81cb7cbf7d4c02ed29e4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:03:12 +0100 Subject: [PATCH 207/378] 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 From c83ece44da4bea87ec9c06f772cf6f693aa5663a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:07:27 +0100 Subject: [PATCH 208/378] ns --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index a58ad46..2f36088 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -23,7 +23,7 @@ DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] -BalboaGL = cg.global_ns.class_( +BalboaGL = balboa_ns.class_( "BalboaGLClimate", climate.Climate, cg.PollingComponent ) From d7935ffac9c0568bb937829d32d97b2db7bfb291 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:08:48 +0100 Subject: [PATCH 209/378] ns --- components/BalboaGL/climate/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 2f36088..8162a4e 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -11,7 +11,7 @@ CONF_SWING_MODE, ) from esphome.core import CORE, coroutine -from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL AUTO_LOAD = ["climate"] @@ -23,7 +23,7 @@ DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] -BalboaGL = balboa_ns.class_( +BalboaGL = balboagl_ns.class_( "BalboaGLClimate", climate.Climate, cg.PollingComponent ) From 15d33522d421e06fe0a6430cf0eecd6c18d86c7c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:12:25 +0100 Subject: [PATCH 210/378] ns --- components/BalboaGL/climate/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 8162a4e..6091268 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -10,7 +10,7 @@ CONF_FAN_MODE, CONF_SWING_MODE, ) -from esphome.core import CORE, coroutine +from esphome.core import CORE from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL AUTO_LOAD = ["climate"] @@ -23,7 +23,7 @@ DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] -BalboaGL = balboagl_ns.class_( +BalboaGLClimate = balboagl_ns.class_( "BalboaGLClimate", climate.Climate, cg.PollingComponent ) @@ -39,7 +39,7 @@ def valid_uart(uart): CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { - cv.GenerateID(): cv.declare_id(BalboaGL), + cv.GenerateID(): cv.declare_id(BalboaGLClimate), cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. From 170aeebed57457b661b4911f9809f9b327cb631c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:15:50 +0100 Subject: [PATCH 211/378] await --- components/BalboaGL/climate/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 6091268..fe63b6c 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -83,8 +83,8 @@ async def to_code(config): - yield cg.register_component(var, config) - yield climate.register_climate(var, config) + await cg.register_component(var, config) + await 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 From d077a9368041402768a922216e15a0bbb1488b1c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:18:43 +0100 Subject: [PATCH 212/378] CONF_BALBOA_ID --- components/BalboaGL/climate/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index fe63b6c..36aeafb 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -40,6 +40,7 @@ def valid_uart(uart): CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(BalboaGLClimate), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. From ef480903001dcca5e1d54208b5ab88637900441f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:21:20 +0100 Subject: [PATCH 213/378] fix naming --- .../BalboaGL/climate/{ESPBalboaGL.cpp => BalboaGLClimate.cpp} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename components/BalboaGL/climate/{ESPBalboaGL.cpp => BalboaGLClimate.cpp} (99%) diff --git a/components/BalboaGL/climate/ESPBalboaGL.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp similarity index 99% rename from components/BalboaGL/climate/ESPBalboaGL.cpp rename to components/BalboaGL/climate/BalboaGLClimate.cpp index 0e952ff..e5b7beb 100644 --- a/components/BalboaGL/climate/ESPBalboaGL.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -1,5 +1,5 @@ #include -#include "ESPBalboaGL.h" +#include "BalboaGLClimate.h" using namespace esphome; From d8f93c76adba9555be68e70df8716ff06a4a8f76 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:22:41 +0100 Subject: [PATCH 214/378] fix incldue --- components/BalboaGL/climate/BalboaGLClimate.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index e5b7beb..7209762 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -1,5 +1,6 @@ #include #include "BalboaGLClimate.h" +#include "../ESPBalboaGL.h" using namespace esphome; From 0f3c5288031f52fd23062ec77a676486115e518f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:24:42 +0100 Subject: [PATCH 215/378] cleanup climate --- components/BalboaGL/climate/BalboaGLClimate.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 7209762..6fbdda8 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -47,17 +47,7 @@ void BalboaGLClimate::update() { static String lastRaw = "0"; if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); - lastRaw = status.rawData; - - // this->pump1->publish_state(pump_mode[status.pump1]); - // this->pump2->publish_state(pump_mode[status.pump2]); - - this->lightSwitch->publish_state(status.light); - - this->stateSensor->publish_state("testing"); // status.state.c_str()); - this->rawSensor->publish_state(status.rawData.c_str()); - // this->lcdSensor->update(); - + lastRaw = status.rawData; this->publish_state(); } From 452e75d322e511b4e467d045c70ec344d799d207 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:42:11 +0100 Subject: [PATCH 216/378] cleanup climate --- components/BalboaGL/climate/BalboaGLClimate.cpp | 4 ++-- components/BalboaGL/climate/BalboaGLClimate.h | 7 ++++--- components/BalboaGL/climate/__init__.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 6fbdda8..91480b3 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -63,7 +63,7 @@ void BalboaGLClimate::update() { * Returns: * This class' supported climate::ClimateTraits. */ -climate::ClimateTraits BalboaGL::traits() { +climate::ClimateTraits BalboaGLClimate::traits() { return traits_; } @@ -73,7 +73,7 @@ climate::ClimateTraits BalboaGL::traits() { * Returns: * A reference to this class' supported climate::ClimateTraits. */ -climate::ClimateTraits& BalboaGL::config_traits() { +climate::ClimateTraits& BalboaGLClimate::config_traits() { return traits_; } diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index e94d033..e57343c 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -6,6 +6,7 @@ #include "esphome/components/climate/climate.h" #include "esphome/core/log.h" #include "esp_log.h" +#include "../ESPBalboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag @@ -29,9 +30,9 @@ using namespace esphome; class BalboaGLClimate : public PollingComponent, public climate::Climate { public: - void set_balboa_parent(BalboaGL* balboaGL) { - this->spa = balboaGL->get_spa(); - } + // void set_balboa_parent(BalboaGL* balboaGL) { + // this->spa = balboaGL->get_spa(); + // } void setSpa(balboaGL* spa) { this->spa = spa; } diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 36aeafb..e76b913 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -88,4 +88,4 @@ async def to_code(config): await 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 + # cg.add(var.set_balboa_parent(paren)) \ No newline at end of file From 27c9c64c43665543c430054b39b30fc77e5a2e7f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:45:48 +0100 Subject: [PATCH 217/378] cleanup climate --- components/BalboaGL/climate/__init__.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index e76b913..8d1e605 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -4,7 +4,6 @@ from esphome.components.logger import HARDWARE_UART_TO_SERIAL from esphome.const import ( CONF_ID, - CONF_HARDWARE_UART, CONF_UPDATE_INTERVAL, CONF_MODE, CONF_FAN_MODE, @@ -28,20 +27,10 @@ ) -def valid_uart(uart): - if CORE.is_esp32: - uarts = [ "UART1", "UART2"] - else: - raise NotImplementedError - - return cv.one_of(*uarts, upper=True)(uart) - - CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( { cv.GenerateID(): cv.declare_id(BalboaGLClimate), cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( @@ -63,8 +52,7 @@ def valid_uart(uart): 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}")) + var = cg.new_Pvariable(config[CONF_ID]) supports = config[CONF_SUPPORTS] traits = var.config_traits() From a56fb8bcf4dd3bf34ab9ed216f33adff2650ecfe Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 21:52:44 +0100 Subject: [PATCH 218/378] cleanup climate --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 8d1e605..36e78de 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -22,7 +22,7 @@ DEFAULT_FAN_MODES = ["OFF"] DEFAULT_SWING_MODES = ["OFF"] -BalboaGLClimate = balboagl_ns.class_( +BalboaGLClimate = cg.esphome_ns.class_( "BalboaGLClimate", climate.Climate, cg.PollingComponent ) From 68a92219d7302a7c0f566ac49c4dcfa8791abe1f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 22:00:13 +0100 Subject: [PATCH 219/378] cleanup climate --- components/BalboaGL/climate/BalboaGLClimate.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index e57343c..36d1fb3 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -1,5 +1,3 @@ -#ifndef ESPMHP_H -#define ESPMHP_H #include "esphome.h" #include "esphome/core/preferences.h" @@ -74,4 +72,3 @@ class BalboaGLClimate : public PollingComponent, public climate::Climate { private: balboaGL* spa; }; -#endif \ No newline at end of file From ed968d29a4e816548753db31d64a45792752b663 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 22:01:21 +0100 Subject: [PATCH 220/378] cleanup climate --- components/BalboaGL/climate/BalboaGLClimate.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index 36d1fb3..2e0a06d 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -6,7 +6,6 @@ #include "esp_log.h" #include "../ESPBalboaGL.h" -static const char* TAG = "BalboaGL"; // Logging tag // // Perform measurements or read nameplate values on your tub to define the power [kW] // // for each device in order to calculate tub power usage @@ -20,7 +19,6 @@ static const char* TAG = "BalboaGL"; // Logging tag // // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc // const int MINUTES_PER_DEGC = 45; -const uint32_t POLL_INTERVAL_DEFAULT = 10000; #include "balboaGL.h" From d67a98178e24d703d87d72c51f3acb5ca6b576fc Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 22:03:27 +0100 Subject: [PATCH 221/378] cleanup climate --- components/BalboaGL/climate/BalboaGLClimate.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index 2e0a06d..2c32bb0 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -1,3 +1,5 @@ +#ifndef GLCLIMATE_H +#define GLCLIMATE_H #include "esphome.h" #include "esphome/core/preferences.h" @@ -70,3 +72,5 @@ class BalboaGLClimate : public PollingComponent, public climate::Climate { private: balboaGL* spa; }; + +#endif \ No newline at end of file From cb8c595cfd012d27b1ce3799d692af3eef379bbf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 19 Oct 2023 22:16:26 +0100 Subject: [PATCH 222/378] cleanup climate --- .../BalboaGL/climate/BalboaGLClimate.cpp | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 91480b3..94e18a8 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -7,46 +7,36 @@ using namespace esphome; void BalboaGLClimate::update() { // This will be called every "update_interval" milliseconds. ESP_LOGV(TAG, "Update called."); - size_t len = this->spa->readSerial(); - ESP_LOGV(TAG, "Read %u bytes", len); - bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); - if(panelSelect == HIGH) { - ESP_LOGV(TAG, "PanelSelect == HIGH"); - return; - } - else { - ESP_LOGD(TAG, "PanelSelect == LOW"); - } - - ESP_LOGD(TAG, "Current Temp: %f", status.temp); - ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); - this->current_temperature = status.temp; - this->target_temperature = status.targetTemp; - switch(status.mode) { - case MODE_IDX_STD: - this->custom_preset = std::string("STD"); - break; - case MODE_IDX_ECO: - this->custom_preset = std::string("ECO"); - break; - case MODE_IDX_SLP: - this->custom_preset = std::string("Sleep"); - break; - default: - this->custom_preset = std::string("UNKNOWN"); - break; - } - - if(status.heater) { - this->mode = climate::CLIMATE_MODE_HEAT; - } - else { - this->mode = climate::CLIMATE_MODE_AUTO; - } static String lastRaw = "0"; if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); + ESP_LOGD(TAG, "Current Temp: %f", status.temp); + ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); + this->current_temperature = status.temp; + this->target_temperature = status.targetTemp; + switch(status.mode) { + case MODE_IDX_STD: + this->custom_preset = std::string("STD"); + break; + case MODE_IDX_ECO: + this->custom_preset = std::string("ECO"); + break; + case MODE_IDX_SLP: + this->custom_preset = std::string("Sleep"); + break; + default: + this->custom_preset = std::string("UNKNOWN"); + break; + } + + if(status.heater) { + this->mode = climate::CLIMATE_MODE_HEAT; + } + else { + this->mode = climate::CLIMATE_MODE_AUTO; + } + lastRaw = status.rawData; this->publish_state(); } From d4eba89f56954d95451b65169e0c9326f2c0c17a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 22:22:52 +0100 Subject: [PATCH 223/378] Heat only for STD mode --- components/BalboaGL/climate/BalboaGLClimate.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 94e18a8..5fa1b62 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -30,11 +30,16 @@ void BalboaGLClimate::update() { break; } - if(status.heater) { - this->mode = climate::CLIMATE_MODE_HEAT; + if(status.mode == MODE_IDX_STD) { + if(status.heater) { + this->mode = climate::CLIMATE_MODE_HEAT; + } + else { + this->mode = climate::CLIMATE_MODE_AUTO; + } } else { - this->mode = climate::CLIMATE_MODE_AUTO; + this->mode = climate::CLIMATE_MODE_OFF; } lastRaw = status.rawData; From 77feba19a20d3733a3d300415d0edcf121c6ed2c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 22:57:47 +0100 Subject: [PATCH 224/378] Text sensor update --- components/BalboaGL/sensor/BalboaGLSesnor.h | 23 ++++++++++ components/BalboaGL/sensor/__init__.py | 48 +++++++++++++++++++++ components/BalboaGL/sensor/text_sensor.py | 40 ----------------- 3 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 components/BalboaGL/sensor/BalboaGLSesnor.h delete mode 100644 components/BalboaGL/sensor/text_sensor.py diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h new file mode 100644 index 0000000..c45370d --- /dev/null +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -0,0 +1,23 @@ +#pragma once + +#include "esphom.h" + +#include "balboaGL.h" + +namespace esphome { + namespace balboa_sensor { + + class BalboaGLStateSensor : public Component, public TextSensor { + public: + void setSpa(balboaGL* spa) { + this->spa = spa; + } + void update() override { + publish_state(status.state.c_ctr()); + } + private: + balboaGL* spa; + + }; + +} \ No newline at end of file diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index e69de29..1777328 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -0,0 +1,48 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import text_sensor +from esphome.const import CONF_ID +from esphome.core import coroutine + +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL + +AUTO_LOAD = ["text_sensor"] + +DEPENDENCIES = ["BalboaGL"] + +CONF_STATE = "state" +CONF_RAW = "raw" +CONF_LCD = "lcd" + + +balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') +StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) +# RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) +# LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) + +CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( + { + + cv.GenerateID(): cv.declare_id(StateInfo), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + + # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(RawInfo), + # }), + # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(LCDInfo), + # }), +}) + +@coroutine +def setup_conf(config, key): + if key in config: + conf = config[key] + var = cg.new_Pvariable(conf[CONF_ID]) + yield cg.register_component(var, conf) + yield text_sensor.register_text_sensor(var, conf) + +def to_code(config): + yield setup_conf(config, CONF_STATE) + # yield setup_conf(config, CONF_RAW) + # yield setup_conf(config, CONF_LCD) diff --git a/components/BalboaGL/sensor/text_sensor.py b/components/BalboaGL/sensor/text_sensor.py deleted file mode 100644 index ad3b4b9..0000000 --- a/components/BalboaGL/sensor/text_sensor.py +++ /dev/null @@ -1,40 +0,0 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import text_sensor -from esphome.const import CONF_ID -from esphome.core import coroutine - -CONF_STATE = "state" -CONF_RAW = "raw" -CONF_LCD = "lcd" - - -balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') -StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) - -CONFIG_SCHEMA = cv.Schema({ - cv.Optional(CONF_STATE): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(StateInfo), - }), - cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(RawInfo), - }), - cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(LCDInfo), - }), -}) - -@coroutine -def setup_conf(config, key): - if key in config: - conf = config[key] - var = cg.new_Pvariable(conf[CONF_ID]) - yield cg.register_component(var, conf) - yield text_sensor.register_text_sensor(var, conf) - -def to_code(config): - yield setup_conf(config, CONF_STATE) - yield setup_conf(config, CONF_RAW) - yield setup_conf(config, CONF_LCD) From 4bc0c7d633fc997d6e8f4213344ab92e1490a0bd Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:00:49 +0100 Subject: [PATCH 225/378] Text sensor update --- components/BalboaGL/sensor/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index 1777328..e3585d0 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -15,8 +15,7 @@ CONF_LCD = "lcd" -balboa_sensor_ns = cg.esphome_ns.namespace('balboa_sensor') -StateInfo = balboa_sensor_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) +StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) # RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) # LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) From 813c80cd848d57c3f9d57346ee393335cdc921eb Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:02:16 +0100 Subject: [PATCH 226/378] Text sensor update --- components/BalboaGL/sensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index e3585d0..0e1b10d 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -31,7 +31,7 @@ # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ # cv.GenerateID(): cv.declare_id(LCDInfo), # }), -}) +}).extend(cv.COMPONENT_SCHEMA) @coroutine def setup_conf(config, key): From a2304854ba493b3d9b25024d314b111c24245366 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:03:23 +0100 Subject: [PATCH 227/378] Text sensor update --- components/BalboaGL/{sensor => text_sensor}/BalboaGLSesnor.h | 0 components/BalboaGL/{sensor => text_sensor}/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename components/BalboaGL/{sensor => text_sensor}/BalboaGLSesnor.h (100%) rename components/BalboaGL/{sensor => text_sensor}/__init__.py (100%) diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h similarity index 100% rename from components/BalboaGL/sensor/BalboaGLSesnor.h rename to components/BalboaGL/text_sensor/BalboaGLSesnor.h diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py similarity index 100% rename from components/BalboaGL/sensor/__init__.py rename to components/BalboaGL/text_sensor/__init__.py From dd9a56e36f782de52f3dbe8bbc03c5ac5e7b721d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:04:54 +0100 Subject: [PATCH 228/378] Text sensor update --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index c45370d..b9deca9 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -1,6 +1,6 @@ #pragma once -#include "esphom.h" +#include "esphome.h" #include "balboaGL.h" From 5edff31b9be348d11571d263f571e4c2ae9c7ff1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:10:17 +0100 Subject: [PATCH 229/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index b9deca9..4262e10 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -7,7 +7,7 @@ namespace esphome { namespace balboa_sensor { - class BalboaGLStateSensor : public Component, public TextSensor { + class BalboaGLStateSensor : public Component, public text_sensor::TextSensor { public: void setSpa(balboaGL* spa) { this->spa = spa; From d8df67f225ebe26bce21a273bf6c4afecfc9c954 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:12:13 +0100 Subject: [PATCH 230/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index 4262e10..25b79c5 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -1,6 +1,7 @@ #pragma once #include "esphome.h" +#include "esphome/components/text_sesnor/text_sensor.h" #include "balboaGL.h" From 7b1199c6eb9cd83cc75c30a7a7300553df086e48 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:13:47 +0100 Subject: [PATCH 231/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index 25b79c5..189d269 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -1,7 +1,7 @@ #pragma once #include "esphome.h" -#include "esphome/components/text_sesnor/text_sensor.h" +#include "esphome/components/text_sensor/text_sensor.h" #include "balboaGL.h" From cab31c33ab2b9bee07c81bd10c51218d002d66c1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:17:00 +0100 Subject: [PATCH 232/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index 189d269..06b30b0 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -8,13 +8,13 @@ namespace esphome { namespace balboa_sensor { - class BalboaGLStateSensor : public Component, public text_sensor::TextSensor { + class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { public: void setSpa(balboaGL* spa) { this->spa = spa; } void update() override { - publish_state(status.state.c_ctr()); + publish_state(status.state.c_str()); } private: balboaGL* spa; From 3df3f754712035fe668c05aba8b4c079fbd13497 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:24:42 +0100 Subject: [PATCH 233/378] text sesnor --- .../BalboaGL/text_sensor/BalboaGLSesnor.h | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index 06b30b0..b6633b0 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -3,22 +3,20 @@ #include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" -#include "balboaGL.h" +// #include "balboaGL.h" -namespace esphome { - namespace balboa_sensor { +using namespace esphome; - class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { - public: - void setSpa(balboaGL* spa) { - this->spa = spa; - } - void update() override { - publish_state(status.state.c_str()); - } - private: - balboaGL* spa; - - }; +class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { + public: + // void setSpa(balboaGL* spa) { + // this->spa = spa; + // } + void update() override { + publish_state(status.state.c_str()); + } + // private: + // balboaGL* spa; + +}; -} \ No newline at end of file From 9b535db62217759227c29f79100ba5ef2819a856 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:34:18 +0100 Subject: [PATCH 234/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index b6633b0..78994cf 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -7,12 +7,12 @@ using namespace esphome; -class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { +class BalboaGLStateSensor : public Component, public text_sensor::TextSensor { public: // void setSpa(balboaGL* spa) { // this->spa = spa; // } - void update() override { + void loop() override { publish_state(status.state.c_str()); } // private: From 389b21fa89bd127ef7c31d6364b7bf98d01b2db8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 22 Oct 2023 23:47:21 +0100 Subject: [PATCH 235/378] text sesnor --- components/BalboaGL/text_sensor/BalboaGLSesnor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLSesnor.h index 78994cf..b6633b0 100644 --- a/components/BalboaGL/text_sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLSesnor.h @@ -7,12 +7,12 @@ using namespace esphome; -class BalboaGLStateSensor : public Component, public text_sensor::TextSensor { +class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { public: // void setSpa(balboaGL* spa) { // this->spa = spa; // } - void loop() override { + void update() override { publish_state(status.state.c_str()); } // private: From f2bfca25f902222d5c2ddfd54341a28f2dc1cc8c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 26 Oct 2023 19:03:41 +0100 Subject: [PATCH 236/378] Remove unused reference to UART --- components/BalboaGL/climate/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 36e78de..8a32712 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -1,7 +1,6 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import climate -from esphome.components.logger import HARDWARE_UART_TO_SERIAL from esphome.const import ( CONF_ID, CONF_UPDATE_INTERVAL, From b7389aef6cd0fd167e35d8222b8badf087cca121 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 13:47:17 +0100 Subject: [PATCH 237/378] set_spa --- components/BalboaGL/climate/BalboaGLClimate.h | 7 ++----- components/BalboaGL/climate/__init__.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index 2c32bb0..562cb6c 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -28,12 +28,9 @@ 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) { + void set_spa(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 8a32712..8c4a9e7 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,4 +75,4 @@ async def to_code(config): await 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 + cg.add(var.set_spa(paren) + "->get_spa()") \ No newline at end of file From 0ec182e3bbdd20e69d25de0d758cd0f3bb2b4f9e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 13:50:01 +0100 Subject: [PATCH 238/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 8c4a9e7..6b4e0fd 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,4 +75,4 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(var.set_spa(paren) + "->get_spa()") \ No newline at end of file + cg.add(var.set_spa(paren->get_spa())) \ No newline at end of file From d25eccf1e325b11f33d54b280a63338068aba9bf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 13:52:07 +0100 Subject: [PATCH 239/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 6b4e0fd..1b3eae9 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,4 +75,4 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(var.set_spa(paren->get_spa())) \ No newline at end of file + cg.add(var.set_spa(paren+ "->get_spa()")) \ No newline at end of file From 21eb63e6c829db2e69e325566f5f809a135a8c2d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 13:56:27 +0100 Subject: [PATCH 240/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 1b3eae9..6b4e0fd 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,4 +75,4 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(var.set_spa(paren+ "->get_spa()")) \ No newline at end of file + cg.add(var.set_spa(paren->get_spa())) \ No newline at end of file From f163f8b2d7b327fb02b2d9777c9aeecf7f1f90d7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:01:52 +0100 Subject: [PATCH 241/378] set_spa --- components/BalboaGL/climate/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 6b4e0fd..87a8879 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,4 +75,6 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(var.set_spa(paren->get_spa())) \ No newline at end of file + spa = await cg.add_global("balboaGL* spa") + # cg.add(spa = paren->get_spa()) + cg.add(var.set_spa(spa)) \ No newline at end of file From c369c91738d06c109d6e3876d77275d7b22512ca Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:02:36 +0100 Subject: [PATCH 242/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 87a8879..9659157 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,6 +75,6 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = await cg.add_global("balboaGL* spa") + spa = await cg.add_global(spa) # cg.add(spa = paren->get_spa()) cg.add(var.set_spa(spa)) \ No newline at end of file From 89575a17c9e52d2d01328b9edb44282d942061b2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:04:49 +0100 Subject: [PATCH 243/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 9659157..3cfc4a9 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,6 +75,6 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = await cg.add_global(spa) + spa = await cg.add_define("balboaGL* spa") # cg.add(spa = paren->get_spa()) cg.add(var.set_spa(spa)) \ No newline at end of file From 37d4c933e62339871c3c0362287f3d6fb7185519 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:05:19 +0100 Subject: [PATCH 244/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 3cfc4a9..755dd3c 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,6 +75,6 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = await cg.add_define("balboaGL* spa") + spa = cg.add_define("balboaGL* spa") # cg.add(spa = paren->get_spa()) cg.add(var.set_spa(spa)) \ No newline at end of file From 9d88d593d27dab576c00972f9f892d8647d3d49a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:06:28 +0100 Subject: [PATCH 245/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 755dd3c..7bb8a0f 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,6 +75,6 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = cg.add_define("balboaGL* spa") + spa = cg.add_global(balboaGL* spa) # cg.add(spa = paren->get_spa()) cg.add(var.set_spa(spa)) \ No newline at end of file From bc8afd0fadf88ae4792ed136eba9b5221d04286c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:11:18 +0100 Subject: [PATCH 246/378] set_spa --- components/BalboaGL/climate/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 7bb8a0f..ec08b43 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,6 +75,5 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = cg.add_global(balboaGL* spa) - # cg.add(spa = paren->get_spa()) - cg.add(var.set_spa(spa)) \ No newline at end of file + spa = cg.add_global(cg.RawExpression("balboaGL* spa")) + cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl.get_spa()")) \ No newline at end of file From 86a9b84adfc96d0f416f5f144d1ece95be7644e2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:12:07 +0100 Subject: [PATCH 247/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index ec08b43..0848452 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -76,4 +76,4 @@ async def to_code(config): paren = await cg.get_variable(config[CONF_BALBOA_ID]) spa = cg.add_global(cg.RawExpression("balboaGL* spa")) - cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl.get_spa()")) \ No newline at end of file + cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl->get_spa()")) \ No newline at end of file From f739513c19f5f92f26486c466f2f4b42014ac08e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:12:48 +0100 Subject: [PATCH 248/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 0848452..e9f6f80 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -76,4 +76,4 @@ async def to_code(config): paren = await cg.get_variable(config[CONF_BALBOA_ID]) spa = cg.add_global(cg.RawExpression("balboaGL* spa")) - cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl->get_spa()")) \ No newline at end of file + cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl->get_spa());")) \ No newline at end of file From 45a22d2cad538c7ebe9701f7536aaf0dd205988f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:14:15 +0100 Subject: [PATCH 249/378] set_spa --- components/BalboaGL/climate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index e9f6f80..81125aa 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -76,4 +76,4 @@ async def to_code(config): paren = await cg.get_variable(config[CONF_BALBOA_ID]) spa = cg.add_global(cg.RawExpression("balboaGL* spa")) - cg.add(cg.RawExpression("balboaglclimate.set_spa(balboagl->get_spa());")) \ No newline at end of file + cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) \ No newline at end of file From a4455ff298f3dff0a0f90c2b73eecdde50d3c4c6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:16:59 +0100 Subject: [PATCH 250/378] define tubUART --- components/BalboaGL/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 2b01445..7f7731e 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -64,6 +64,8 @@ def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) + cg.add_define("tubUART=1") # TODO make dynamic + if CONF_RX_PIN in config: cg.add(var.set_rx_pin(config[CONF_RX_PIN])) From 87b01189288f3cea49bb67a380db7eac5f73252e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:17:20 +0100 Subject: [PATCH 251/378] define tubUART --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 7f7731e..e4f46a7 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -64,7 +64,7 @@ def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) - cg.add_define("tubUART=1") # TODO make dynamic + cg.add_define("tubUART 1") # TODO make dynamic if CONF_RX_PIN in config: cg.add(var.set_rx_pin(config[CONF_RX_PIN])) From eb5071ed9ece0671b63be2837dc5d27bd374a784 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:21:12 +0100 Subject: [PATCH 252/378] define tubUART --- components/BalboaGL/ESPBalboaGL.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 438e645..735b58c 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,8 +8,7 @@ #include "esphome/core/log.h" #include "esp_log.h" -// #include "BalboaGLSelect.h" -// #include "BalboaGLSwitch.h" +#define tubUART 1 #include "ESPBalboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag From b1f0567ce0a628ff2cf59ee1574262ae6bea544e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 14:57:47 +0100 Subject: [PATCH 253/378] twek switch python --- components/BalboaGL/switch/__init__.py | 29 ++++++++++++++++++++++++++ components/BalboaGL/switch/switch.py | 28 ------------------------- 2 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 components/BalboaGL/switch/switch.py diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index e69de29..00bc3be 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -0,0 +1,29 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import switch +from esphome.const import CONF_ID + +from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL + +DEPENDENCIES = ["BalboaGL"] + +LightSwitch = cg.esphome_ns.class_('LightSwitch', switch.Switch, cg.Component) + +CONFIG_SCHEMA = ( + switch.switch_schema(LightSwitch) + .extend( + { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + } + ) + .extend(cv.COMPONENT_SCHEMA) +) + +async def to_code(config): + var = await switch.new_switch(config) + await cg.register_component(var, config) + + paren = await cg.get_variable(config[CONF_BALBOA_ID]) +# cg.add(var.set_balboa_parent(paren)) +# cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) + diff --git a/components/BalboaGL/switch/switch.py b/components/BalboaGL/switch/switch.py deleted file mode 100644 index faa5379..0000000 --- a/components/BalboaGL/switch/switch.py +++ /dev/null @@ -1,28 +0,0 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import switch -from esphome.const import CONF_ID - -from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL - -DEPENDENCIES = ["BalboaGL"] - -LightSwitch = balboa_ns.class_('LightSwitch', switch.Switch, cg.Component) - -CONFIG_SCHEMA = ( - switch.switch_schema(LightSwitch) - .extend( - { - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - } - ) - .extend(cv.COMPONENT_SCHEMA) -) - -async def to_code(config): - var = await switch.new_switch(config) - await cg.register_component(var, config) - - paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(var.set_balboa_parent(paren)) - From 9c0e8923928fe79c9f09802dc3d7cab69eb62dd7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:04:36 +0100 Subject: [PATCH 254/378] twek switch python --- components/BalboaGL/switch/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index 00bc3be..82269c6 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -9,15 +9,12 @@ LightSwitch = cg.esphome_ns.class_('LightSwitch', switch.Switch, cg.Component) -CONFIG_SCHEMA = ( - switch.switch_schema(LightSwitch) - .extend( - { - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - } - ) - .extend(cv.COMPONENT_SCHEMA) -) +CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( + { + cv.GenerateID(): cv.declare_id(LightSwitch), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + } +).extend(cv.COMPONENT_SCHEMA) async def to_code(config): var = await switch.new_switch(config) From 1dfdba899bae97f59a4f3cf5290b2d310985e185 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:05:35 +0100 Subject: [PATCH 255/378] twek switch python --- components/BalboaGL/switch/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index 82269c6..67fc88a 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -3,7 +3,7 @@ from esphome.components import switch from esphome.const import CONF_ID -from .. import balboa_ns, CONF_BALBOA_ID, BalboaGL +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL DEPENDENCIES = ["BalboaGL"] From 7636667f83702677984cf693b64f0ebc3e6508c7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:06:22 +0100 Subject: [PATCH 256/378] twek switch python --- components/BalboaGL/switch/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index 67fc88a..7ed5a94 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -7,7 +7,7 @@ DEPENDENCIES = ["BalboaGL"] -LightSwitch = cg.esphome_ns.class_('LightSwitch', switch.Switch, cg.Component) +LightSwitch = cg.esphome_ns.class_('BalboaGLLightSwitch', switch.Switch, cg.Component) CONFIG_SCHEMA = switch.SWITCH_SCHEMA.extend( { From 4d31798b05e94b28ae5ea9143f4432a8771f0358 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:08:50 +0100 Subject: [PATCH 257/378] remove namespace --- components/BalboaGL/switch/BalboaGLSwitch.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 88a411e..c131525 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -5,8 +5,7 @@ #include "balboaGL.h" -namespace esphome { - namespace balboa_switch { +using namespace esphome; class BalboaGLLightSwitch : public Component, public switch_::Switch { public: @@ -23,7 +22,4 @@ namespace esphome { } private: balboaGL* spa; - }; - - } -} \ No newline at end of file + }; \ No newline at end of file From a7afec97bfc3180d14525c14bc21ef7edfc0bf12 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:11:07 +0100 Subject: [PATCH 258/378] set spa --- components/BalboaGL/switch/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index 7ed5a94..6edf985 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -22,5 +22,5 @@ async def to_code(config): paren = await cg.get_variable(config[CONF_BALBOA_ID]) # cg.add(var.set_balboa_parent(paren)) -# cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) + cg.add(cg.RawExpression("balboagllightswitch->set_spa(balboagl->get_spa())")) From 59353a2a776787addff0397761a953e8956ad1c4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 15:11:56 +0100 Subject: [PATCH 259/378] set spa --- components/BalboaGL/switch/BalboaGLSwitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index c131525..7c05d87 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -9,7 +9,7 @@ using namespace esphome; class BalboaGLLightSwitch : public Component, public switch_::Switch { public: - void setSpa(balboaGL* spa) { + void set_spa(balboaGL* spa) { this->spa = spa; } void write_state(bool state) override { From 1a8a3c4662f8a492d46290ab6cafe6a51c657ad3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 18:04:19 +0100 Subject: [PATCH 260/378] attachPanelInterrupt --- components/BalboaGL/ESPBalboaGL.cpp | 8 +++++++- components/BalboaGL/ESPBalboaGL.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 8a107f1..f967c27 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -274,7 +274,8 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); + this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); + this->spa-attachPanelInterrupt(); // this->current_temperature = NAN; // this->target_temperature = NAN; @@ -319,6 +320,11 @@ void BalboaGL::setup() { this->dump_config(); } +void BalboaGL::pause() { + ESP_LOGI(TAG, "pause"); + this->spa-detachPanelInterrupt(); +} + // /** // * The ESP only has a few bytes of rtc storage, so instead // * of storing floats directly, we'll store the number of diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 735b58c..05ad05d 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -65,6 +65,8 @@ class BalboaGL : public PollingComponent { float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } + void pause(); + balboaGL* get_spa() { return spa; } From e3f4d76e2d7912d70e45e221506b442e49836c06 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 18:16:58 +0100 Subject: [PATCH 261/378] attachPanelInterrupt --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f967c27..653e4af 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -275,7 +275,7 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); - this->spa-attachPanelInterrupt(); + this->spa->attachPanelInterrupt(); // this->current_temperature = NAN; // this->target_temperature = NAN; @@ -322,7 +322,7 @@ void BalboaGL::setup() { void BalboaGL::pause() { ESP_LOGI(TAG, "pause"); - this->spa-detachPanelInterrupt(); + this->spa->detachPanelInterrupt(); } // /** From 8ea825d57ccac3e67ff8226b0dbc7a1ea8c88565 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 18:48:31 +0100 Subject: [PATCH 262/378] CommandQueue sensor --- components/BalboaGL/sensor/BalboaGLSesnor.h | 22 +++++++++ components/BalboaGL/sensor/__init__.py | 47 +++++++++++++++++++ ...{BalboaGLSesnor.h => BalboaGLTextSesnor.h} | 0 3 files changed, 69 insertions(+) create mode 100644 components/BalboaGL/sensor/BalboaGLSesnor.h create mode 100644 components/BalboaGL/sensor/__init__.py rename components/BalboaGL/text_sensor/{BalboaGLSesnor.h => BalboaGLTextSesnor.h} (100%) diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h new file mode 100644 index 0000000..a8cb172 --- /dev/null +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -0,0 +1,22 @@ +#pragma once + +#include "esphome.h" +#include "esphome/components/sensor/sensor.h" + +// #include "balboaGL.h" + +using namespace esphome; + +class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::TextSensor { + public: + // void setSpa(balboaGL* spa) { + // this->spa = spa; + // } + void update() override { + publish_state(status.commandQueue); + } + // private: + // balboaGL* spa; + +}; + diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py new file mode 100644 index 0000000..5b0f9a8 --- /dev/null +++ b/components/BalboaGL/sensor/__init__.py @@ -0,0 +1,47 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import sensor +from esphome.const import CONF_ID +from esphome.core import coroutine + +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL + +AUTO_LOAD = ["text_sensor"] + +DEPENDENCIES = ["BalboaGL"] + +CONF_STATE = "state" +CONF_RAW = "raw" +CONF_LCD = "lcd" + + +CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) +# RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) +# LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) + +CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( + { + + cv.GenerateID(): cv.declare_id(CommandQueueInfo), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + + # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(RawInfo), + # }), + # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(LCDInfo), + # }), +}).extend(cv.COMPONENT_SCHEMA) + +@coroutine +def setup_conf(config, key): + if key in config: + conf = config[key] + var = cg.new_Pvariable(conf[CONF_ID]) + yield cg.register_component(var, conf) + yield sensor.register_sensor(var, conf) + +def to_code(config): + yield setup_conf(config, CONF_STATE) + # yield setup_conf(config, CONF_RAW) + # yield setup_conf(config, CONF_LCD) diff --git a/components/BalboaGL/text_sensor/BalboaGLSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h similarity index 100% rename from components/BalboaGL/text_sensor/BalboaGLSesnor.h rename to components/BalboaGL/text_sensor/BalboaGLTextSesnor.h From 017d0ba1bda1769756aeef14d6395af2d58d70a8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 18:51:54 +0100 Subject: [PATCH 263/378] CommandQueue sensor --- components/BalboaGL/sensor/BalboaGLSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h index a8cb172..bdceca3 100644 --- a/components/BalboaGL/sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -7,7 +7,7 @@ using namespace esphome; -class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::TextSensor { +class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::Sensor { public: // void setSpa(balboaGL* spa) { // this->spa = spa; From eac0f662a14ff8eeb53d587eb921e7859ff1c651 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:07:13 +0100 Subject: [PATCH 264/378] CommandQueue sensor --- components/BalboaGL/sensor/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index 5b0f9a8..2995c76 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -10,20 +10,25 @@ DEPENDENCIES = ["BalboaGL"] +CONF_QUEUE = "commandQueue" CONF_STATE = "state" CONF_RAW = "raw" CONF_LCD = "lcd" +CommandQueueInfo = balboagl_ns.class_( + "BalboaGLCommandQueueSensor", sensor.TextSensor, cg.PollingComponent +) + CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) # RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) # LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) -CONFIG_SCHEMA = sensor.SENSOR_SCHEMA.extend( +CONFIG_SCHEMA = cv.Schema( { - - cv.GenerateID(): cv.declare_id(CommandQueueInfo), - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + cv.Optional(CONF_QUEUE): sensor.sensor_schema( + CommandQueueInfo, + ).extend(cv.polling_component_schema("1s")), # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ # cv.GenerateID(): cv.declare_id(RawInfo), @@ -31,7 +36,8 @@ # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ # cv.GenerateID(): cv.declare_id(LCDInfo), # }), -}).extend(cv.COMPONENT_SCHEMA) + } +) @coroutine def setup_conf(config, key): From f70950f9afcb3e74885bee8003b466125af1ce0e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:13:08 +0100 Subject: [PATCH 265/378] CommandQueue sensor --- components/BalboaGL/sensor/__init__.py | 30 ++++++--------------- components/BalboaGL/text_sensor/__init__.py | 4 +-- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index 2995c76..2c35875 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -11,23 +11,13 @@ DEPENDENCIES = ["BalboaGL"] CONF_QUEUE = "commandQueue" -CONF_STATE = "state" -CONF_RAW = "raw" -CONF_LCD = "lcd" -CommandQueueInfo = balboagl_ns.class_( - "BalboaGLCommandQueueSensor", sensor.TextSensor, cg.PollingComponent -) - -CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) -# RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -# LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) +CommandQueueInfo = balboagl_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) CONFIG_SCHEMA = cv.Schema( { - cv.Optional(CONF_QUEUE): sensor.sensor_schema( - CommandQueueInfo, + cv.Optional(CONF_QUEUE): sensor.sensor_schema(CommandQueueInfo, ).extend(cv.polling_component_schema("1s")), # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ @@ -39,15 +29,11 @@ } ) -@coroutine -def setup_conf(config, key): +async def setup_conf(config, key): if key in config: conf = config[key] - var = cg.new_Pvariable(conf[CONF_ID]) - yield cg.register_component(var, conf) - yield sensor.register_sensor(var, conf) - -def to_code(config): - yield setup_conf(config, CONF_STATE) - # yield setup_conf(config, CONF_RAW) - # yield setup_conf(config, CONF_LCD) + var = await sensor.new_sensor(conf) + await cg.register_component(var, conf) + +async def to_code(config): + await setup_conf(config, CONF_QUEUE) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 0e1b10d..ffeec2d 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -16,8 +16,8 @@ StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -# RawInfo = balboa_sensor_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -# LCDInfo = balboa_sensor_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) +# RawInfo = balboagl_ns.class_('BalboaGLRawSensor', sensor.Sensor, cg.Component) +# LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', sensor.Sensor, cg.Component) CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( { From dd57c2a31cd050af9ede65b5c98755818056239d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:18:51 +0100 Subject: [PATCH 266/378] CommandQueue sensor --- components/BalboaGL/sensor/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index 2c35875..ace861e 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -12,8 +12,9 @@ CONF_QUEUE = "commandQueue" +info_ns = cg.esphome_ns.namespace("balboa_info") -CommandQueueInfo = balboagl_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) +CommandQueueInfo = info_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) CONFIG_SCHEMA = cv.Schema( { From 6ea2ee4f20437f3141421438e607aa32553f321d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:23:12 +0100 Subject: [PATCH 267/378] CommandQueue sensor --- components/BalboaGL/sensor/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index ace861e..5409cc0 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -12,9 +12,17 @@ CONF_QUEUE = "commandQueue" -info_ns = cg.esphome_ns.namespace("balboa_info") - -CommandQueueInfo = info_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) +CommandQueueInfo = balboagl_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) + +CONFIG_SCHEMA = ( + sensor.sensor_schema(CommandQueueInfo) + .extend( + { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + } + ) + .extend(cv.COMPONENT_SCHEMA) +) CONFIG_SCHEMA = cv.Schema( { From 0b4eb7ac5dc8dd087a6755a5f96c0d91b7066952 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:36:08 +0100 Subject: [PATCH 268/378] CommandQueue sensor --- components/BalboaGL/sensor/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index 5409cc0..c0fd4a4 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -6,13 +6,13 @@ from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL -AUTO_LOAD = ["text_sensor"] +AUTO_LOAD = ["sensor"] DEPENDENCIES = ["BalboaGL"] CONF_QUEUE = "commandQueue" -CommandQueueInfo = balboagl_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) +CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) CONFIG_SCHEMA = ( sensor.sensor_schema(CommandQueueInfo) From b83768a5988109ae2231fb817a2e891f5c7b21a6 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:39:32 +0100 Subject: [PATCH 269/378] State sensor --- components/BalboaGL/text_sensor/__init__.py | 40 +++++++++------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index ffeec2d..ec0930e 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -19,29 +19,21 @@ # RawInfo = balboagl_ns.class_('BalboaGLRawSensor', sensor.Sensor, cg.Component) # LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', sensor.Sensor, cg.Component) -CONFIG_SCHEMA = text_sensor.TEXT_SENSOR_SCHEMA.extend( - { - - cv.GenerateID(): cv.declare_id(StateInfo), - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - - # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - # cv.GenerateID(): cv.declare_id(RawInfo), - # }), - # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - # cv.GenerateID(): cv.declare_id(LCDInfo), - # }), -}).extend(cv.COMPONENT_SCHEMA) - -@coroutine -def setup_conf(config, key): +CONFIG_SCHEMA = ( + text_sensor.text_sensor_schema(StateInfo) + .extend( + { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + } + ) + .extend(cv.COMPONENT_SCHEMA) +) + +async def setup_conf(config, key): if key in config: conf = config[key] - var = cg.new_Pvariable(conf[CONF_ID]) - yield cg.register_component(var, conf) - yield text_sensor.register_text_sensor(var, conf) - -def to_code(config): - yield setup_conf(config, CONF_STATE) - # yield setup_conf(config, CONF_RAW) - # yield setup_conf(config, CONF_LCD) + var = await text_sensor.new_text_sensor(conf) + await cg.register_component(var, conf) + +async def to_code(config): + await setup_conf(config, CONF_STATE) From 7351257e57579929c772a574fed208b4f7e345ea Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:59:32 +0100 Subject: [PATCH 270/378] Remove tubUART define --- components/BalboaGL/ESPBalboaGL.h | 1 - components/BalboaGL/text_sensor/__init__.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 05ad05d..55df34f 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -8,7 +8,6 @@ #include "esphome/core/log.h" #include "esp_log.h" -#define tubUART 1 #include "ESPBalboaGL.h" static const char* TAG = "BalboaGL"; // Logging tag diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index ec0930e..752d51a 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -29,6 +29,20 @@ .extend(cv.COMPONENT_SCHEMA) ) +CONFIG_SCHEMA = cv.Schema( + { + cv.Optional(CONF_STATE): text_sensor.text_sensor_schema(StateInfo, + ).extend(cv.polling_component_schema("1s")), + + # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(RawInfo), + # }), + # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ + # cv.GenerateID(): cv.declare_id(LCDInfo), + # }), + } +) + async def setup_conf(config, key): if key in config: conf = config[key] From 672cd6df18596679366cf40a44fdf87f88b0362e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 19:59:43 +0100 Subject: [PATCH 271/378] fix setter name --- components/BalboaGL/select/BalboaGLSelect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/select/BalboaGLSelect.h b/components/BalboaGL/select/BalboaGLSelect.h index d3ca36a..8c7b61b 100644 --- a/components/BalboaGL/select/BalboaGLSelect.h +++ b/components/BalboaGL/select/BalboaGLSelect.h @@ -10,7 +10,7 @@ namespace esphome { class BalboaGLPump1Select : public Component, public select::Select { public: - void setSpa(balboaGL* spa) { + void set_spa(balboaGL* spa) { this->spa = spa; } private: @@ -21,7 +21,7 @@ namespace esphome { class BalboaGLPump2Select : public Component, public select::Select { public: - void setSpa(balboaGL* spa) { + void set_spa(balboaGL* spa) { this->spa = spa; } private: From 1252b6cc291459c19dc6c42d0c66a8daab27a806 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 20:03:54 +0100 Subject: [PATCH 272/378] Add sensors --- components/BalboaGL/text_sensor/__init__.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 752d51a..8990dde 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -16,8 +16,8 @@ StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -# RawInfo = balboagl_ns.class_('BalboaGLRawSensor', sensor.Sensor, cg.Component) -# LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', sensor.Sensor, cg.Component) +RawInfo = balboagl_ns.class_('BalboaGLRawSensor', text_sensor.Sensor, cg.Component) +LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', text_sensor.Sensor, cg.Component) CONFIG_SCHEMA = ( text_sensor.text_sensor_schema(StateInfo) @@ -34,12 +34,11 @@ cv.Optional(CONF_STATE): text_sensor.text_sensor_schema(StateInfo, ).extend(cv.polling_component_schema("1s")), - # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - # cv.GenerateID(): cv.declare_id(RawInfo), - # }), - # cv.Optional(CONF_LCD): text_sensor.TEXT_SENSOR_SCHEMA.extend({ - # cv.GenerateID(): cv.declare_id(LCDInfo), - # }), + cv.Optional(CONF_RAW): text_sensor.text_sensor_schema(RawInfo, + ).extend(cv.polling_component_schema("1s")), + + cv.Optional(CONF_LCD): text_sensor.text_sensor_schema(LCDInfo, + ).extend(cv.polling_component_schema("1s")), } ) From 265be1fcd5275b2c3dcc8dcf31bc36615901a85b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 20:04:37 +0100 Subject: [PATCH 273/378] Add sensors --- components/BalboaGL/text_sensor/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 8990dde..e2fba8e 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -16,8 +16,8 @@ StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -RawInfo = balboagl_ns.class_('BalboaGLRawSensor', text_sensor.Sensor, cg.Component) -LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', text_sensor.Sensor, cg.Component) +RawInfo = balboagl_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) +LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) CONFIG_SCHEMA = ( text_sensor.text_sensor_schema(StateInfo) From a9da2035197310a822a92c1aa6afe664e379d1e3 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 20:09:33 +0100 Subject: [PATCH 274/378] Add sensors --- .../BalboaGL/text_sensor/BalboaGLTextSesnor.h | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index b6633b0..931cb13 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -20,3 +20,29 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen }; +class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSensor { + public: + // void setSpa(balboaGL* spa) { + // this->spa = spa; + // } + void update() override { + publish_state(status.rawData.c_str()); + } + // private: + // balboaGL* spa; + +}; + +class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSensor { + public: + // void setSpa(balboaGL* spa) { + // this->spa = spa; + // } + void update() override { + publish_state(status.lcd); + } + // private: + // balboaGL* spa; + +}; + From b806ab0306c6210531d9a554add2a3334eb8a48c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 27 Oct 2023 20:13:55 +0100 Subject: [PATCH 275/378] Update example config --- component.yaml | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/component.yaml b/component.yaml index dfd61a0..3435708 100644 --- a/component.yaml +++ b/component.yaml @@ -7,10 +7,58 @@ external_components: refresh: 0s BalboaGL: - name: Temp + # name: Temp hardware_uart: UART1 rx_pin: 3 tx_pin: 10 enable_pin: 5 panel_select_pin: 6 - update_interval: 220ms + update_interval: 220ms + +climate: + - platform: BalboaGL + name: Temp + update_interval: 220ms + +# # Text sensors with general information. +text_sensor: + # Expose ESPHome version as sensor. + - platform: version + name: ESPHome Version + # Expose WiFi information as sensors. + - platform: wifi_info + ip_address: + name: IP + ssid: + name: SSID + bssid: + name: BSSID + + - platform: BalboaGL + state: + name: State + raw: + name: Raw Data + lcd: + name: LCD Display + +# Sensors with general information. +sensor: + # Uptime sensor. + - platform: uptime + name: Uptime + + - platform: BalboaGL + commandQueue: + name: Command Queue + + # WiFi Signal sensor. + - platform: wifi_signal + name: WiFi Signal + update_interval: 60s + +switch: + - platform: BalboaGL + name: Light + + From b5562f7e57c5797c70973226d3436e42cfc203a4 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 13:02:57 +0100 Subject: [PATCH 276/378] entity category --- components/BalboaGL/sensor/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index c0fd4a4..b503ed4 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -3,6 +3,9 @@ from esphome.components import sensor from esphome.const import CONF_ID from esphome.core import coroutine +from esphome.const import ( + ENTITY_CATEGORY_DIAGNOSTIC, +) from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL @@ -27,6 +30,8 @@ CONFIG_SCHEMA = cv.Schema( { cv.Optional(CONF_QUEUE): sensor.sensor_schema(CommandQueueInfo, + entity_category=ENTITY_CATEGORY_DIAGNOSTIC + ).extend(cv.polling_component_schema("1s")), # cv.Optional(CONF_RAW): text_sensor.TEXT_SENSOR_SCHEMA.extend({ From 864bfc183a9037eb4c1a4860e67a42dd22ef549b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:05:00 +0100 Subject: [PATCH 277/378] Add unique_id --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 931cb13..a33cd1a 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -15,6 +15,7 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen void update() override { publish_state(status.state.c_str()); } + std::string unique_id() override { return "state"; } // private: // balboaGL* spa; @@ -28,6 +29,7 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso void update() override { publish_state(status.rawData.c_str()); } + std::string unique_id() override { return "raw"; } // private: // balboaGL* spa; @@ -41,6 +43,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso void update() override { publish_state(status.lcd); } + std::string unique_id() override { return "lcd"; } // private: // balboaGL* spa; From 34afc36bee9c9d7ee9edaf72af67cf5fd410fd81 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:43:12 +0100 Subject: [PATCH 278/378] Convert from polling to regular component --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- components/BalboaGL/ESPBalboaGL.h | 4 ++-- components/BalboaGL/__init__.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 653e4af..c100e6f 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -38,9 +38,9 @@ void BalboaGL::check_logger_conflict_() { #endif } -void BalboaGL::update() { +void BalboaGL::loop() { // This will be called every "update_interval" milliseconds. - ESP_LOGV(TAG, "Update called."); + // ESP_LOGV(TAG, "Loop called."); size_t len = this->spa->readSerial(); ESP_LOGV(TAG, "Read %u bytes", len); bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 55df34f..3bd969e 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -30,7 +30,7 @@ const uint32_t POLL_INTERVAL_DEFAULT = 10000; using namespace esphome; -class BalboaGL : public PollingComponent { +class BalboaGL : public Component { public: BalboaGL( HardwareSerial* hw_serial @@ -49,7 +49,7 @@ class BalboaGL : public PollingComponent { void setup() override; // This is called every poll_interval. - void update() override; + void loop() override; // Debugging function to print the object's state. // void dump_state(); diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index e4f46a7..4aa4d72 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -21,7 +21,7 @@ balboagl_ns = cg.esphome_ns.namespace("balboagl") BalboaGL = cg.global_ns.class_( - "BalboaGL", cg.PollingComponent + "BalboaGL", cg.Component ) @@ -43,9 +43,9 @@ def valid_uart(uart): cv.Optional(CONF_HARDWARE_UART, default="UART1"): valid_uart, # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. - cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( - cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) - ), + # cv.Optional(CONF_UPDATE_INTERVAL, default="100ms"): cv.All( + # cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) + # ), cv.Required(CONF_RX_PIN): cv.int_range(), cv.Required(CONF_TX_PIN): cv.int_range(), cv.Required(CONF_PANEL_SELECT_PIN): cv.int_range(), From 466d4a7ff12d2e8e9e2020704e64ceddff9698e7 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:48:30 +0100 Subject: [PATCH 279/378] Cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 41 +---------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index c100e6f..3d33381 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -42,50 +42,11 @@ void BalboaGL::loop() { // This will be called every "update_interval" milliseconds. // ESP_LOGV(TAG, "Loop called."); size_t len = this->spa->readSerial(); - ESP_LOGV(TAG, "Read %u bytes", len); - bool panelSelect = digitalRead(this->spa->getPanelSelectPin()); - if(panelSelect == HIGH) { - ESP_LOGV(TAG, "PanelSelect == HIGH"); - return; - } - else { - ESP_LOGD(TAG, "PanelSelect == LOW"); - } - - ESP_LOGD(TAG, "Current Temp: %f", status.temp); - ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); - // this->current_temperature = status.temp; - // this->target_temperature = status.targetTemp; - // switch(status.mode) { - // case MODE_IDX_STD: - // this->custom_preset = std::string("STD"); - // break; - // case MODE_IDX_ECO: - // this->custom_preset = std::string("ECO"); - // break; - // case MODE_IDX_SLP: - // this->custom_preset = std::string("Sleep"); - // break; - // default: - // this->custom_preset = std::string("UNKNOWN"); - // break; - // } - - + // ESP_LOGV(TAG, "Read %u bytes", len); static String lastRaw = "0"; if(status.rawData != lastRaw) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); lastRaw = status.rawData; - - // this->pump1->publish_state(pump_mode[status.pump1]); - // this->pump2->publish_state(pump_mode[status.pump2]); - - // this->lightSwitch->publish_state(status.light); - - // this->stateSensor->publish_state("testing"); // status.state.c_str()); - // this->rawSensor->publish_state(status.rawData.c_str()); - // this->lcdSensor->update(); - // this->publish_state(); } From 2f2c2a3a62d0b66bd0114647bf103329f5eaf497 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:55:35 +0100 Subject: [PATCH 280/378] Selective update --- .../BalboaGL/text_sensor/BalboaGLTextSesnor.h | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index a33cd1a..a0747b0 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -13,11 +13,14 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen // this->spa = spa; // } void update() override { - publish_state(status.state.c_str()); + if(status.state ! = last_value) { + last_value = status.state + publish_state(last_value.c_str()); + } } std::string unique_id() override { return "state"; } - // private: - // balboaGL* spa; + private: + String last_value; }; @@ -27,11 +30,14 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - publish_state(status.rawData.c_str()); + if(status.rawData ! = last_value) { + last_value = status.rawData + publish_state(last_value.c_str()); + } } std::string unique_id() override { return "raw"; } - // private: - // balboaGL* spa; + private: + String last_value; }; @@ -41,11 +47,14 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - publish_state(status.lcd); + if(status.lcd ! = last_value) { + last_value = status.lcd + publish_state(last_value.c_str()); + } } std::string unique_id() override { return "lcd"; } - // private: - // balboaGL* spa; + private: + String last_value; }; From 281dfbfa2e40edde0e43fea610c6b57616275e5c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:56:16 +0100 Subject: [PATCH 281/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index a0747b0..3a722e3 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -13,7 +13,7 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen // this->spa = spa; // } void update() override { - if(status.state ! = last_value) { + if(status.state != last_value) { last_value = status.state publish_state(last_value.c_str()); } @@ -30,7 +30,7 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - if(status.rawData ! = last_value) { + if(status.rawData != last_value) { last_value = status.rawData publish_state(last_value.c_str()); } @@ -47,7 +47,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - if(status.lcd ! = last_value) { + if(status.lcd != last_value) { last_value = status.lcd publish_state(last_value.c_str()); } From 24914a0aac8b271b87d0ff7fc20738240237ee43 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:56:54 +0100 Subject: [PATCH 282/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 3a722e3..4e9dfbc 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -14,7 +14,7 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen // } void update() override { if(status.state != last_value) { - last_value = status.state + last_value = status.state; publish_state(last_value.c_str()); } } @@ -31,7 +31,7 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso // } void update() override { if(status.rawData != last_value) { - last_value = status.rawData + last_value = status.rawData; publish_state(last_value.c_str()); } } @@ -48,7 +48,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // } void update() override { if(status.lcd != last_value) { - last_value = status.lcd + last_value = status.lcd; publish_state(last_value.c_str()); } } From 4239004f25c8435631437649d8eac93ffc26d643 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:58:35 +0100 Subject: [PATCH 283/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 4e9dfbc..bc9c983 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -13,8 +13,8 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen // this->spa = spa; // } void update() override { - if(status.state != last_value) { - last_value = status.state; + if(status.state != this->last_value) { + this->last_value = status.state; publish_state(last_value.c_str()); } } @@ -30,8 +30,8 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - if(status.rawData != last_value) { - last_value = status.rawData; + if(status.rawData != this->last_value) { + this->last_value = status.rawData; publish_state(last_value.c_str()); } } @@ -47,8 +47,8 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - if(status.lcd != last_value) { - last_value = status.lcd; + if(status.lcd != this->last_value) { + this->last_value = status.lcd; publish_state(last_value.c_str()); } } From 7738ca9a795211209c50d388f8e887ef11806e4c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 14:59:24 +0100 Subject: [PATCH 284/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index bc9c983..8cd839f 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -54,7 +54,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso } std::string unique_id() override { return "lcd"; } private: - String last_value; + char[5] last_value; }; From 48be5561655183dd3d80936e6eef0c8539f3af86 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:03:58 +0100 Subject: [PATCH 285/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 8cd839f..67886df 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -54,7 +54,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso } std::string unique_id() override { return "lcd"; } private: - char[5] last_value; + char last_value[5]; }; From cf307e0085c8a796ab327fdec7476b11029033ab Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:04:48 +0100 Subject: [PATCH 286/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 67886df..178b0fb 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -49,7 +49,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso void update() override { if(status.lcd != this->last_value) { this->last_value = status.lcd; - publish_state(last_value.c_str()); + publish_state(last_value); } } std::string unique_id() override { return "lcd"; } From 0a9308b5647fd638ad2f6ed783e9742adc885423 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:07:37 +0100 Subject: [PATCH 287/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index 178b0fb..c53b10b 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -48,13 +48,13 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // } void update() override { if(status.lcd != this->last_value) { - this->last_value = status.lcd; - publish_state(last_value); + this->last_value = String(status.lcd); + publish_state(last_value.c_str()); } } std::string unique_id() override { return "lcd"; } private: - char last_value[5]; + String last_value; }; From 36406021900ed2fc8ebd309dc2609c276f1103fa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:08:23 +0100 Subject: [PATCH 288/378] Selective update --- components/BalboaGL/text_sensor/BalboaGLTextSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index c53b10b..b9d6e6a 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -47,7 +47,7 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // this->spa = spa; // } void update() override { - if(status.lcd != this->last_value) { + if(String(status.lcd) != this->last_value) { this->last_value = String(status.lcd); publish_state(last_value.c_str()); } From 5ed4f1bc678275264b61a460d1b38639a775197a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:11:47 +0100 Subject: [PATCH 289/378] Selective update --- components/BalboaGL/sensor/BalboaGLSesnor.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h index bdceca3..5c7f1ca 100644 --- a/components/BalboaGL/sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -13,9 +13,13 @@ class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::Senso // this->spa = spa; // } void update() override { - publish_state(status.commandQueue); + if(status.commandQueue != this->last_value) { + this->last_value = status.commandQueue + publish_state(status.commandQueue); + } } - // private: + private: + u_int8_t last_value; // balboaGL* spa; }; From 54cfead1d6d1bacefc04af34511959ebb0cf87ad Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:12:15 +0100 Subject: [PATCH 290/378] Selective update --- components/BalboaGL/sensor/BalboaGLSesnor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h index 5c7f1ca..bb7c2ce 100644 --- a/components/BalboaGL/sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -14,7 +14,7 @@ class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::Senso // } void update() override { if(status.commandQueue != this->last_value) { - this->last_value = status.commandQueue + this->last_value = status.commandQueue; publish_state(status.commandQueue); } } From 0ec727f8bc2505edbc05f9d3834000af58605fed Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:22:52 +0100 Subject: [PATCH 291/378] switch loggers --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- components/BalboaGL/switch/BalboaGLSwitch.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 5fa1b62..ccee38e 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -6,7 +6,7 @@ using namespace esphome; void BalboaGLClimate::update() { // This will be called every "update_interval" milliseconds. - ESP_LOGV(TAG, "Update called."); + ESP_LOGV(TAG, "BalboaGLClimate Update called."); static String lastRaw = "0"; if(status.rawData != lastRaw) { diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 7c05d87..47ef69d 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -13,12 +13,19 @@ using namespace esphome; this->spa = spa; } void write_state(bool state) override { + if(state) { + ESP_LOGI(TAG, "BalboaGLLightSwitch write_state(true)"); + } + else { + ESP_LOGI(TAG, "BalboaGLLightSwitch write_state(false)"); + } // This will be called every time the user requests a state change. spa->setLight(state); // Acknowledge new state by publishing it // publish_state(state); + ESP_LOGD(TAG, "BalboaGLLightSwitch write_state complete"); } private: balboaGL* spa; From efa4498bd3986f99f47f34dd8a0da59dbbd7f121 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:24:14 +0100 Subject: [PATCH 292/378] switch loggers --- components/BalboaGL/switch/BalboaGLSwitch.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 47ef69d..6e518d3 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -5,6 +5,8 @@ #include "balboaGL.h" +static const char* TAG = "BalboaGL"; // Logging tag + using namespace esphome; class BalboaGLLightSwitch : public Component, public switch_::Switch { From 4c1ca7cb5448c026529b2db3e2bdd36bf36e02d1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:25:09 +0100 Subject: [PATCH 293/378] switch loggers --- components/BalboaGL/switch/BalboaGLSwitch.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 6e518d3..0f0e7bd 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -5,7 +5,7 @@ #include "balboaGL.h" -static const char* TAG = "BalboaGL"; // Logging tag +static const char* SWITCH_TAG = "BalboaGLSwitch"; // Logging tag using namespace esphome; @@ -16,10 +16,10 @@ using namespace esphome; } void write_state(bool state) override { if(state) { - ESP_LOGI(TAG, "BalboaGLLightSwitch write_state(true)"); + ESP_LOGI(SWITCH_TAG, "BalboaGLLightSwitch write_state(true)"); } else { - ESP_LOGI(TAG, "BalboaGLLightSwitch write_state(false)"); + ESP_LOGI(SWITCH_TAG, "BalboaGLLightSwitch write_state(false)"); } // This will be called every time the user requests a state change. @@ -27,7 +27,7 @@ using namespace esphome; // Acknowledge new state by publishing it // publish_state(state); - ESP_LOGD(TAG, "BalboaGLLightSwitch write_state complete"); + ESP_LOGD(SWITCH_TAG, "BalboaGLLightSwitch write_state complete"); } private: balboaGL* spa; From 807941c7658867f071b54e7858b900376734e89b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 15:36:54 +0100 Subject: [PATCH 294/378] logger tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- components/BalboaGL/switch/BalboaGLSwitch.h | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 3d33381..fec59c9 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -235,7 +235,7 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); + this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); this->spa->attachPanelInterrupt(); // this->current_temperature = NAN; // this->target_temperature = NAN; diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index ccee38e..e8851ff 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -6,7 +6,7 @@ using namespace esphome; void BalboaGLClimate::update() { // This will be called every "update_interval" milliseconds. - ESP_LOGV(TAG, "BalboaGLClimate Update called."); + // ESP_LOGV(TAG, "BalboaGLClimate Update called."); static String lastRaw = "0"; if(status.rawData != lastRaw) { diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 0f0e7bd..b506b37 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -16,10 +16,10 @@ using namespace esphome; } void write_state(bool state) override { if(state) { - ESP_LOGI(SWITCH_TAG, "BalboaGLLightSwitch write_state(true)"); + ESP_LOGI(SWITCH_TAG, "LightSwitch write_state(true)"); } else { - ESP_LOGI(SWITCH_TAG, "BalboaGLLightSwitch write_state(false)"); + ESP_LOGI(SWITCH_TAG, "LightSwitch write_state(false)"); } // This will be called every time the user requests a state change. @@ -27,7 +27,7 @@ using namespace esphome; // Acknowledge new state by publishing it // publish_state(state); - ESP_LOGD(SWITCH_TAG, "BalboaGLLightSwitch write_state complete"); + ESP_LOGD(SWITCH_TAG, "LightSwitch write_state complete"); } private: balboaGL* spa; From ba924a3245b43ca80db5900426be9584df81d617 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 16:03:30 +0100 Subject: [PATCH 295/378] light state --- components/BalboaGL/switch/BalboaGLSwitch.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index b506b37..ce2dc0f 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -29,6 +29,14 @@ using namespace esphome; // publish_state(state); ESP_LOGD(SWITCH_TAG, "LightSwitch write_state complete"); } + void update() override { + if(status.light != this->last_state) { + this->last_state = status.light; + publish_state(this->last_state); + } + } + private: balboaGL* spa; + bool last_state; }; \ No newline at end of file From 69e67fb30d689e382c785f5297922016e5cff608 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 16:04:59 +0100 Subject: [PATCH 296/378] light state --- components/BalboaGL/switch/BalboaGLSwitch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index ce2dc0f..7f5d829 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -29,7 +29,7 @@ using namespace esphome; // publish_state(state); ESP_LOGD(SWITCH_TAG, "LightSwitch write_state complete"); } - void update() override { + void loop() override { if(status.light != this->last_state) { this->last_state = status.light; publish_state(this->last_state); From 0f00f7d489e90dc5120b641ae6a68919e667f5af Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 28 Oct 2023 16:39:14 +0100 Subject: [PATCH 297/378] add logger --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index fec59c9..16697c3 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -5,6 +5,10 @@ using namespace esphome; void telnetSend(String msg) { ESP_LOGI(TAG, msg.c_str()); } + +void log(const char *format, ...) { + ESP_LOGI(TAG, format); +} /** * Create a new BalboaGL object * From b289febec2e8cebabd2654b1c7447aba6a32de85 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 09:09:29 +0000 Subject: [PATCH 298/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 14 -------------- components/BalboaGL/ESPBalboaGL.h | 9 --------- 2 files changed, 23 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 16697c3..2de73af 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -22,13 +22,6 @@ BalboaGL::BalboaGL( hw_serial_{hw_serial} { - // this->rawSensor = new text_sensor::TextSensor(); - // this->stateSensor = new text_sensor::TextSensor(); - - // this->lightSwitch = new balboa_switch::BalboaGLLightSwitch(); - - // this->pump1 = new balboa_select::BalboaGLPump1Select(); - // this->pump2 = new balboa_select::BalboaGLPump12elect(); } void BalboaGL::check_logger_conflict_() { @@ -241,13 +234,6 @@ void BalboaGL::setup() { hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); this->spa->attachPanelInterrupt(); - // this->current_temperature = NAN; - // this->target_temperature = NAN; - - // this->lightSwitch->setSpa(spa); - - // this->pump1->setSpa(spa); - // this->pump2->setSpa(spa); // ESP_LOGCONFIG( // TAG, diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 3bd969e..6302333 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -81,15 +81,6 @@ class BalboaGL : public Component { //ESP8266 or UART0 on ESP32 void check_logger_conflict_(); - // esphome::balboa_select::BalboaGLPump1Select* pump1; - // esphome::balboa_select::BalboaGLPump2Select* pump2; - - // esphome::balboa_switch::BalboaGLLightSwitch* lightSwitch; - - // esphome::text_sensor::TextSensor* stateSensor; - // esphome::text_sensor::TextSensor* rawSensor; - // esphome::text_sensor::TextSensor* lcdSensor; - int rx_pin = -1; int tx_pin = -1; int rts_pin = -1; From 56141751149ee613ff7f1829c7613249cb499d76 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 09:11:38 +0000 Subject: [PATCH 299/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 164 ---------------------------- 1 file changed, 164 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 2de73af..3e89a06 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -49,170 +49,6 @@ void BalboaGL::loop() { } -// void BalboaGL::hpSettingsChanged() { -// heatpumpSettings currentSettings = hp->getSettings(); - -// if (currentSettings.power == NULL) { -// /* -// * We should always get a valid pointer here once the HeatPump -// * component fully initializes. If HeatPump hasn't read the settings -// * from the unit yet (hp->connect() doesn't do this, sadly), we'll need -// * to punt on the update. Likely not an issue when run in callback -// * mode, but that isn't working right yet. -// */ -// ESP_LOGW(TAG, "Waiting for HeatPump to read the settings the first time."); -// esphome::delay(10); -// return; -// } - -// /* -// * ************ HANDLE POWER AND MODE CHANGES *********** -// * https://github.com/geoffdavis/HeatPump/blob/stream/src/HeatPump.h#L125 -// * const char* POWER_MAP[2] = {"OFF", "ON"}; -// * const char* MODE_MAP[5] = {"HEAT", "DRY", "COOL", "FAN", "AUTO"}; -// */ -// if (strcmp(currentSettings.power, "ON") == 0) { -// if (strcmp(currentSettings.mode, "HEAT") == 0) { -// this->mode = climate::CLIMATE_MODE_HEAT; -// if (heat_setpoint != currentSettings.temperature) { -// heat_setpoint = currentSettings.temperature; -// save(currentSettings.temperature, heat_storage); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// } else if (strcmp(currentSettings.mode, "DRY") == 0) { -// this->mode = climate::CLIMATE_MODE_DRY; -// this->action = climate::CLIMATE_ACTION_DRYING; -// } else if (strcmp(currentSettings.mode, "COOL") == 0) { -// this->mode = climate::CLIMATE_MODE_COOL; -// if (cool_setpoint != currentSettings.temperature) { -// cool_setpoint = currentSettings.temperature; -// save(currentSettings.temperature, cool_storage); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// } else if (strcmp(currentSettings.mode, "FAN") == 0) { -// this->mode = climate::CLIMATE_MODE_FAN_ONLY; -// this->action = climate::CLIMATE_ACTION_FAN; -// } else if (strcmp(currentSettings.mode, "AUTO") == 0) { -// this->mode = climate::CLIMATE_MODE_HEAT_COOL; -// if (auto_setpoint != currentSettings.temperature) { -// auto_setpoint = currentSettings.temperature; -// save(currentSettings.temperature, auto_storage); -// } -// this->action = climate::CLIMATE_ACTION_IDLE; -// } else { -// ESP_LOGW( -// TAG, -// "Unknown climate mode value %s received from HeatPump", -// currentSettings.mode -// ); -// } -// } else { -// this->mode = climate::CLIMATE_MODE_OFF; -// this->action = climate::CLIMATE_ACTION_OFF; -// } - -// ESP_LOGI(TAG, "Climate mode is: %i", this->mode); - -// /* -// * ******* HANDLE FAN CHANGES ******** -// * -// * const char* FAN_MAP[6] = {"AUTO", "QUIET", "1", "2", "3", "4"}; -// */ -// if (strcmp(currentSettings.fan, "QUIET") == 0) { -// this->fan_mode = climate::CLIMATE_FAN_DIFFUSE; -// } else if (strcmp(currentSettings.fan, "1") == 0) { -// this->fan_mode = climate::CLIMATE_FAN_LOW; -// } else if (strcmp(currentSettings.fan, "2") == 0) { -// this->fan_mode = climate::CLIMATE_FAN_MEDIUM; -// } else if (strcmp(currentSettings.fan, "3") == 0) { -// this->fan_mode = climate::CLIMATE_FAN_MIDDLE; -// } else if (strcmp(currentSettings.fan, "4") == 0) { -// this->fan_mode = climate::CLIMATE_FAN_HIGH; -// } else { //case "AUTO" or default: -// this->fan_mode = climate::CLIMATE_FAN_AUTO; -// } -// ESP_LOGI(TAG, "Fan mode is: %i", this->fan_mode); - -// /* ******** HANDLE MITSUBISHI VANE CHANGES ******** -// * const char* VANE_MAP[7] = {"AUTO", "1", "2", "3", "4", "5", "SWING"}; -// */ -// if (strcmp(currentSettings.vane, "SWING") == 0) { -// this->swing_mode = climate::CLIMATE_SWING_VERTICAL; -// } -// else { -// this->swing_mode = climate::CLIMATE_SWING_OFF; -// } -// ESP_LOGI(TAG, "Swing mode is: %i", this->swing_mode); - - - -// /* -// * ******** HANDLE TARGET TEMPERATURE CHANGES ******** -// */ -// this->target_temperature = currentSettings.temperature; -// ESP_LOGI(TAG, "Target temp is: %f", this->target_temperature); - -// /* -// * ******** Publish state back to ESPHome. ******** -// */ -// this->publish_state(); -// } - -// /** -// * Report changes in the current temperature sensed by the HeatPump. -// */ -// void BalboaGL::hpStatusChanged(heatpumpStatus currentStatus) { -// this->current_temperature = currentStatus.roomTemperature; -// switch (this->mode) { -// case climate::CLIMATE_MODE_HEAT: -// if (currentStatus.operating) { -// this->action = climate::CLIMATE_ACTION_HEATING; -// } -// else { -// this->action = climate::CLIMATE_ACTION_IDLE; -// } -// break; -// case climate::CLIMATE_MODE_COOL: -// if (currentStatus.operating) { -// this->action = climate::CLIMATE_ACTION_COOLING; -// } -// else { -// this->action = climate::CLIMATE_ACTION_IDLE; -// } -// break; -// case climate::CLIMATE_MODE_HEAT_COOL: -// this->action = climate::CLIMATE_ACTION_IDLE; -// if (currentStatus.operating) { -// if (this->current_temperature > this->target_temperature) { -// this->action = climate::CLIMATE_ACTION_COOLING; -// } else if (this->current_temperature < this->target_temperature) { -// this->action = climate::CLIMATE_ACTION_HEATING; -// } -// } -// break; -// case climate::CLIMATE_MODE_DRY: -// if (currentStatus.operating) { -// this->action = climate::CLIMATE_ACTION_DRYING; -// } -// else { -// this->action = climate::CLIMATE_ACTION_IDLE; -// } -// break; -// case climate::CLIMATE_MODE_FAN_ONLY: -// this->action = climate::CLIMATE_ACTION_FAN; -// break; -// default: -// this->action = climate::CLIMATE_ACTION_OFF; -// } - -// this->publish_state(); -// } - -// void BalboaGL::set_remote_temperature(float temp) { -// ESP_LOGD(TAG, "Setting remote temp: %.1f", temp); -// this->hp->setRemoteTemperature(temp); -// } - void BalboaGL::setup() { // This will be called by App.setup() // this->banner(); From da38eda6825cc9c2f09fc406a676ef03c3cf0232 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 09:40:17 +0000 Subject: [PATCH 300/378] Register LCD and raw --- components/BalboaGL/text_sensor/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index e2fba8e..b93f4ba 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -16,8 +16,8 @@ StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -RawInfo = balboagl_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -LCDInfo = balboagl_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) +RawInfo = cg.esphome_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) +LCDInfo = cg.esphome_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) CONFIG_SCHEMA = ( text_sensor.text_sensor_schema(StateInfo) @@ -50,3 +50,5 @@ async def setup_conf(config, key): async def to_code(config): await setup_conf(config, CONF_STATE) + await setup_conf(config, CONF_RAW) + await setup_conf(config, CONF_LCD) From 1b4262e2ba59c94ccb6a5c536dee1b275282eb41 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 10:08:24 +0000 Subject: [PATCH 301/378] CommandQueue = polling --- components/BalboaGL/sensor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index b503ed4..d4410dd 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -15,7 +15,7 @@ CONF_QUEUE = "commandQueue" -CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.Component) +CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.PollingComponent) CONFIG_SCHEMA = ( sensor.sensor_schema(CommandQueueInfo) From 4aa0337bc39bcfede866d6301067edc297f02c1c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 10:18:48 +0000 Subject: [PATCH 302/378] schema tweaks --- components/BalboaGL/sensor/__init__.py | 10 ---------- components/BalboaGL/text_sensor/__init__.py | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/components/BalboaGL/sensor/__init__.py b/components/BalboaGL/sensor/__init__.py index d4410dd..d607c67 100644 --- a/components/BalboaGL/sensor/__init__.py +++ b/components/BalboaGL/sensor/__init__.py @@ -17,16 +17,6 @@ CommandQueueInfo = cg.esphome_ns.class_('BalboaGLCommandQueueSensor', sensor.Sensor, cg.PollingComponent) -CONFIG_SCHEMA = ( - sensor.sensor_schema(CommandQueueInfo) - .extend( - { - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - } - ) - .extend(cv.COMPONENT_SCHEMA) -) - CONFIG_SCHEMA = cv.Schema( { cv.Optional(CONF_QUEUE): sensor.sensor_schema(CommandQueueInfo, diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index b93f4ba..95e62f3 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -19,16 +19,6 @@ RawInfo = cg.esphome_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) LCDInfo = cg.esphome_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) -CONFIG_SCHEMA = ( - text_sensor.text_sensor_schema(StateInfo) - .extend( - { - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - } - ) - .extend(cv.COMPONENT_SCHEMA) -) - CONFIG_SCHEMA = cv.Schema( { cv.Optional(CONF_STATE): text_sensor.text_sensor_schema(StateInfo, From 9fecbf2824e4eaf0a75b3113798255b31209f68d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 10:30:58 +0000 Subject: [PATCH 303/378] Update select --- components/BalboaGL/select/__init__.py | 44 +++++++++++++++++++++++++ components/BalboaGL/select/select.py | 45 -------------------------- 2 files changed, 44 insertions(+), 45 deletions(-) delete mode 100644 components/BalboaGL/select/select.py diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index e69de29..eadf0c3 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -0,0 +1,44 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import select +from esphome.const import ( + CONF_ID, + CONF_OPTIONS, +) + + +CONF_PUMP1 = "pump1" +CONF_PUMP2 = "pump2" + +select_ns = cg.esphome_ns.namespace('balboa_select') +Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) +Pump2Select = select_ns.class_('BalboaGLPump2Select', select.Select, cg.Component) + +CONFIG_SCHEMA = cv.Schema({ + cv.Optional(CONF_PUMP1): select.SELECT_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(Pump1Select), + cv.Required(CONF_OPTIONS): cv.All( + cv.ensure_list(cv.string_strict), cv.Length(min=1) + ), + }), + cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ + cv.GenerateID(): cv.declare_id(Pump2Select), + cv.Required(CONF_OPTIONS): cv.All( + cv.ensure_list(cv.string_strict), cv.Length(min=1) + ), + }), + +}) + +def setup_conf(config, key): + if key in config: + conf = config[key] + var = cg.new_Pvariable(conf[CONF_ID]) + await cg.register_component(var, conf) + await select.register_select(var, config, options=list()) + +def to_code(config): + await setup_conf(config, CONF_PUMP1) + await setup_conf(config, CONF_PUMP2) + # cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) + diff --git a/components/BalboaGL/select/select.py b/components/BalboaGL/select/select.py deleted file mode 100644 index 5f284ab..0000000 --- a/components/BalboaGL/select/select.py +++ /dev/null @@ -1,45 +0,0 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import select -from esphome.const import ( - CONF_ID, - CONF_OPTIONS, -) -from esphome.core import coroutine - - -CONF_PUMP1 = "pump1" -CONF_PUMP2 = "pump2" - -select_ns = cg.esphome_ns.namespace('balboa_select') -Pump1Select = select_ns.class_('BalboaGLPump1Select', select.Select, cg.Component) -Pump2Select = select_ns.class_('BalboaGLPump2Select', select.Select, cg.Component) - -CONFIG_SCHEMA = cv.Schema({ - cv.Optional(CONF_PUMP1): select.SELECT_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(Pump1Select), - cv.Required(CONF_OPTIONS): cv.All( - cv.ensure_list(cv.string_strict), cv.Length(min=1) - ), - }), - cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ - cv.GenerateID(): cv.declare_id(Pump2Select), - cv.Required(CONF_OPTIONS): cv.All( - cv.ensure_list(cv.string_strict), cv.Length(min=1) - ), - }), - -}) - -@coroutine -def setup_conf(config, key): - if key in config: - conf = config[key] - var = cg.new_Pvariable(conf[CONF_ID]) - yield cg.register_component(var, conf) - yield select.register_select(var, config, options=list()) - -def to_code(config): - yield setup_conf(config, CONF_PUMP1) - yield setup_conf(config, CONF_PUMP2) - From d74a9f4776a4ba2162db30ec67b1009f37a8d4aa Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 10:32:25 +0000 Subject: [PATCH 304/378] async --- components/BalboaGL/select/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index eadf0c3..aaf5203 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -30,14 +30,14 @@ }) -def setup_conf(config, key): +async def setup_conf(config, key): if key in config: conf = config[key] var = cg.new_Pvariable(conf[CONF_ID]) await cg.register_component(var, conf) await select.register_select(var, config, options=list()) -def to_code(config): +async def to_code(config): await setup_conf(config, CONF_PUMP1) await setup_conf(config, CONF_PUMP2) # cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) From eb9839cf16d0fc4adb1fd5e0400e16596c3c0f36 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 10:36:56 +0000 Subject: [PATCH 305/378] Update select --- components/BalboaGL/select/__init__.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index aaf5203..c18d88f 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -5,6 +5,8 @@ CONF_ID, CONF_OPTIONS, ) +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL + CONF_PUMP1 = "pump1" @@ -33,12 +35,24 @@ async def setup_conf(config, key): if key in config: conf = config[key] - var = cg.new_Pvariable(conf[CONF_ID]) + var = cg.new_Pvariable(conf[key]) await cg.register_component(var, conf) await select.register_select(var, config, options=list()) + # var = await select.new_select(config, options=list(options_map.values())) + # await cg.register_component(var, config) + async def to_code(config): await setup_conf(config, CONF_PUMP1) await setup_conf(config, CONF_PUMP2) # cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) +# async def to_code(config): +# options_map = config[CONF_OPTIONS] +# var = await select.new_select(config, options=list(options_map.values())) +# await cg.register_component(var, config) +# cg.add(var.set_select_mappings(list(options_map.keys()))) +# parent = await cg.get_variable(config[CONF_TUYA_ID]) +# cg.add(var.set_tuya_parent(parent)) +# cg.add(var.set_select_id(config[CONF_ENUM_DATAPOINT])) +# cg.add(var.set_optimistic(config[CONF_OPTIMISTIC])) From d87afd5ca15460e1a6ff88faa85abd302151872a Mon Sep 17 00:00:00 2001 From: netmindz Date: Thu, 2 Nov 2023 14:06:11 +0000 Subject: [PATCH 306/378] Update component.yaml --- component.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/component.yaml b/component.yaml index 3435708..db739f5 100644 --- a/component.yaml +++ b/component.yaml @@ -1,4 +1,11 @@ +ota: + password: "e82fe9bada398051d779151a591a1e2e" + on_begin: + then: + - lambda: balboagl->pause +# OTA pause needed to prevent interrupts blocking OTA + external_components: - source: type: git @@ -6,14 +13,14 @@ external_components: ref: ESPHome refresh: 0s + BalboaGL: - # name: Temp + # Example pins for T-RSC3 hardware_uart: UART1 rx_pin: 3 tx_pin: 10 enable_pin: 5 panel_select_pin: 6 - update_interval: 220ms climate: - platform: BalboaGL @@ -62,3 +69,9 @@ switch: name: Light +# select: +# - platform: BalboaGL +# pump1: +# name: Pump1 +# options: "HIGH" + From ebf4b2c22314cf72e4cf9341fe1a13f31ab6c348 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 14:21:58 +0000 Subject: [PATCH 307/378] try raw only --- components/BalboaGL/text_sensor/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 95e62f3..646375f 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -39,6 +39,6 @@ async def setup_conf(config, key): await cg.register_component(var, conf) async def to_code(config): - await setup_conf(config, CONF_STATE) + # await setup_conf(config, CONF_STATE) await setup_conf(config, CONF_RAW) - await setup_conf(config, CONF_LCD) + # await setup_conf(config, CONF_LCD) From eee9e93d4be99f29453a1d45937db75021ac2497 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 14:31:04 +0000 Subject: [PATCH 308/378] Polling text_sesnors --- components/BalboaGL/text_sensor/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 646375f..317e482 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -15,9 +15,9 @@ CONF_LCD = "lcd" -StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.Component) -RawInfo = cg.esphome_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.Component) -LCDInfo = cg.esphome_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.Component) +StateInfo = cg.esphome_ns.class_('BalboaGLStateSensor', text_sensor.TextSensor, cg.PollingComponent) +RawInfo = cg.esphome_ns.class_('BalboaGLRawSensor', text_sensor.TextSensor, cg.PollingComponent) +LCDInfo = cg.esphome_ns.class_('BalboaGLLCDSensor', text_sensor.TextSensor, cg.PollingComponent) CONFIG_SCHEMA = cv.Schema( { @@ -39,6 +39,6 @@ async def setup_conf(config, key): await cg.register_component(var, conf) async def to_code(config): - # await setup_conf(config, CONF_STATE) + await setup_conf(config, CONF_STATE) await setup_conf(config, CONF_RAW) - # await setup_conf(config, CONF_LCD) + await setup_conf(config, CONF_LCD) From 24906bb427db39d27ccd1d53c3f7ab6fbda2ca75 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 14:34:50 +0000 Subject: [PATCH 309/378] starting value and remove unqiue_id --- .../BalboaGL/text_sensor/BalboaGLTextSesnor.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index b9d6e6a..c76defb 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -12,13 +12,16 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen // void setSpa(balboaGL* spa) { // this->spa = spa; // } + void setup() override { + this->last_value = "Awaiting data"; + } void update() override { if(status.state != this->last_value) { this->last_value = status.state; publish_state(last_value.c_str()); } } - std::string unique_id() override { return "state"; } + // std::string unique_id() override { return "state"; } private: String last_value; @@ -29,13 +32,16 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso // void setSpa(balboaGL* spa) { // this->spa = spa; // } + void setup() override { + this->last_value = "no data"; + } void update() override { if(status.rawData != this->last_value) { this->last_value = status.rawData; publish_state(last_value.c_str()); } } - std::string unique_id() override { return "raw"; } + // std::string unique_id() override { return "raw"; } private: String last_value; @@ -46,13 +52,16 @@ class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSenso // void setSpa(balboaGL* spa) { // this->spa = spa; // } + void setup() override { + this->last_value = "unknown"; + } void update() override { if(String(status.lcd) != this->last_value) { this->last_value = String(status.lcd); publish_state(last_value.c_str()); } } - std::string unique_id() override { return "lcd"; } + // std::string unique_id() override { return "lcd"; } private: String last_value; From a3877e6ee2e0e18c8d3c81937b5e301c7004804d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 14:48:54 +0000 Subject: [PATCH 310/378] raw is diag --- components/BalboaGL/text_sensor/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/text_sensor/__init__.py b/components/BalboaGL/text_sensor/__init__.py index 317e482..7533a08 100644 --- a/components/BalboaGL/text_sensor/__init__.py +++ b/components/BalboaGL/text_sensor/__init__.py @@ -1,8 +1,10 @@ import esphome.codegen as cg import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import CONF_ID -from esphome.core import coroutine +from esphome.const import ( + CONF_ID, + ENTITY_CATEGORY_DIAGNOSTIC +) from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL @@ -25,6 +27,7 @@ ).extend(cv.polling_component_schema("1s")), cv.Optional(CONF_RAW): text_sensor.text_sensor_schema(RawInfo, + entity_category=ENTITY_CATEGORY_DIAGNOSTIC ).extend(cv.polling_component_schema("1s")), cv.Optional(CONF_LCD): text_sensor.text_sensor_schema(LCDInfo, From 42c71c883add710adf11fbb7c6dcdccb171f8bb8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:29:26 +0000 Subject: [PATCH 311/378] select --- components/BalboaGL/select/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index c18d88f..fd314f3 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -35,9 +35,9 @@ async def setup_conf(config, key): if key in config: conf = config[key] - var = cg.new_Pvariable(conf[key]) + options_map = config[CONF_OPTIONS] + var = await select.new_select(config, options=list(options_map.values())) await cg.register_component(var, conf) - await select.register_select(var, config, options=list()) # var = await select.new_select(config, options=list(options_map.values())) # await cg.register_component(var, config) From 121d70f97cf8f2673f4452fa962dc48fa0ef25c2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:30:53 +0000 Subject: [PATCH 312/378] select --- components/BalboaGL/select/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index fd314f3..f3cad2d 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -35,7 +35,7 @@ async def setup_conf(config, key): if key in config: conf = config[key] - options_map = config[CONF_OPTIONS] + options_map = conf[CONF_OPTIONS] var = await select.new_select(config, options=list(options_map.values())) await cg.register_component(var, conf) From 0c64f2bbfb039e96b8065ec1e30c01f698c0c78b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:32:39 +0000 Subject: [PATCH 313/378] select --- components/BalboaGL/select/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index f3cad2d..545d791 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -36,7 +36,7 @@ async def setup_conf(config, key): if key in config: conf = config[key] options_map = conf[CONF_OPTIONS] - var = await select.new_select(config, options=list(options_map.values())) + var = await select.new_select(conf, options=list(options_map.values())) await cg.register_component(var, conf) # var = await select.new_select(config, options=list(options_map.values())) From 77818d3e7a2d57d2be5c4e4a0e9b01b1b0b89a6d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:36:59 +0000 Subject: [PATCH 314/378] select --- components/BalboaGL/select/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index 545d791..0590afd 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -36,7 +36,7 @@ async def setup_conf(config, key): if key in config: conf = config[key] options_map = conf[CONF_OPTIONS] - var = await select.new_select(conf, options=list(options_map.values())) + var = await select.new_select(conf, options=["off","high"]) await cg.register_component(var, conf) # var = await select.new_select(config, options=list(options_map.values())) From f1cd72556d3e47e5cb99ba54faab559be334bb64 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:38:36 +0000 Subject: [PATCH 315/378] select --- components/BalboaGL/select/BalboaGLSelect.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/BalboaGL/select/BalboaGLSelect.h b/components/BalboaGL/select/BalboaGLSelect.h index 8c7b61b..32dc62b 100644 --- a/components/BalboaGL/select/BalboaGLSelect.h +++ b/components/BalboaGL/select/BalboaGLSelect.h @@ -12,6 +12,9 @@ namespace esphome { public: void set_spa(balboaGL* spa) { this->spa = spa; + } + void control(const std::string &value) override { + } private: balboaGL* spa; @@ -23,6 +26,9 @@ namespace esphome { public: void set_spa(balboaGL* spa) { this->spa = spa; + } + void control(const std::string &value) override { + } private: balboaGL* spa; From 4a09a6f784f0f32a367dabf7f27abcd2f2abbf69 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:42:16 +0000 Subject: [PATCH 316/378] select --- components/BalboaGL/select/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index 0590afd..926ffbf 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -38,9 +38,9 @@ async def setup_conf(config, key): options_map = conf[CONF_OPTIONS] var = await select.new_select(conf, options=["off","high"]) await cg.register_component(var, conf) - - # var = await select.new_select(config, options=list(options_map.values())) - # await cg.register_component(var, config) + paren = await cg.get_variable(config[CONF_BALBOA_ID]) + spa = cg.add_global(cg.RawExpression("balboaGL* spa")) + cg.add(cg.RawStatement("balboaglclimate->set_spa({paren}->get_spa())")) async def to_code(config): await setup_conf(config, CONF_PUMP1) From 6658b55befb0b16f4b6b0a8307b3b8dbd27ff8a8 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:43:34 +0000 Subject: [PATCH 317/378] select --- components/BalboaGL/select/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index 926ffbf..b60ed51 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -19,12 +19,14 @@ CONFIG_SCHEMA = cv.Schema({ cv.Optional(CONF_PUMP1): select.SELECT_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(Pump1Select), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Required(CONF_OPTIONS): cv.All( cv.ensure_list(cv.string_strict), cv.Length(min=1) ), }), cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(Pump2Select), + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Required(CONF_OPTIONS): cv.All( cv.ensure_list(cv.string_strict), cv.Length(min=1) ), From 67836423ea6f9c7459bb80ab9700ad5fa0d15933 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:44:34 +0000 Subject: [PATCH 318/378] select --- components/BalboaGL/select/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index b60ed51..ec870d7 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -17,16 +17,15 @@ Pump2Select = select_ns.class_('BalboaGLPump2Select', select.Select, cg.Component) CONFIG_SCHEMA = cv.Schema({ + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Optional(CONF_PUMP1): select.SELECT_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(Pump1Select), - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Required(CONF_OPTIONS): cv.All( cv.ensure_list(cv.string_strict), cv.Length(min=1) ), }), cv.Optional(CONF_PUMP2): select.SELECT_SCHEMA.extend({ cv.GenerateID(): cv.declare_id(Pump2Select), - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), cv.Required(CONF_OPTIONS): cv.All( cv.ensure_list(cv.string_strict), cv.Length(min=1) ), From 8034395e78f3daecd9a53af3c5109b5c99be3e2d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:50:49 +0000 Subject: [PATCH 319/378] select --- components/BalboaGL/select/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index ec870d7..39f1159 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -40,7 +40,6 @@ async def setup_conf(config, key): var = await select.new_select(conf, options=["off","high"]) await cg.register_component(var, conf) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = cg.add_global(cg.RawExpression("balboaGL* spa")) cg.add(cg.RawStatement("balboaglclimate->set_spa({paren}->get_spa())")) async def to_code(config): From 5ff4f3b739ffd5d02120d780dc1ceefaf86bec41 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 17:58:47 +0000 Subject: [PATCH 320/378] select --- components/BalboaGL/select/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index 39f1159..3661f84 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -39,8 +39,8 @@ async def setup_conf(config, key): options_map = conf[CONF_OPTIONS] var = await select.new_select(conf, options=["off","high"]) await cg.register_component(var, conf) - paren = await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(cg.RawStatement("balboaglclimate->set_spa({paren}->get_spa())")) + paren = "balboagl" #await cg.get_variable(config[CONF_BALBOA_ID]) + cg.add(cg.RawStatement(f"balboaglclimate->set_spa({paren}->get_spa())")) async def to_code(config): await setup_conf(config, CONF_PUMP1) From 7fb2ce8dafaa33616282d70854a71e7e758b7e29 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 18:00:24 +0000 Subject: [PATCH 321/378] select --- components/BalboaGL/select/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index 3661f84..fe9d293 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -39,8 +39,8 @@ async def setup_conf(config, key): options_map = conf[CONF_OPTIONS] var = await select.new_select(conf, options=["off","high"]) await cg.register_component(var, conf) - paren = "balboagl" #await cg.get_variable(config[CONF_BALBOA_ID]) - cg.add(cg.RawStatement(f"balboaglclimate->set_spa({paren}->get_spa())")) + paren = await cg.get_variable(config[CONF_BALBOA_ID]) + cg.add(cg.RawStatement(f"{var}->set_spa({paren}->get_spa());")) async def to_code(config): await setup_conf(config, CONF_PUMP1) From ac514b5c5df45f9b6bd333cca2be834d1ac40b9a Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 18:03:50 +0000 Subject: [PATCH 322/378] set spa --- components/BalboaGL/climate/__init__.py | 3 +-- components/BalboaGL/select/__init__.py | 11 ----------- components/BalboaGL/switch/__init__.py | 4 +--- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/components/BalboaGL/climate/__init__.py b/components/BalboaGL/climate/__init__.py index 81125aa..0e1e499 100644 --- a/components/BalboaGL/climate/__init__.py +++ b/components/BalboaGL/climate/__init__.py @@ -75,5 +75,4 @@ async def to_code(config): await climate.register_climate(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) - spa = cg.add_global(cg.RawExpression("balboaGL* spa")) - cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) \ No newline at end of file + cg.add(cg.RawStatement(f"{var}->set_spa({paren}->get_spa());")) \ No newline at end of file diff --git a/components/BalboaGL/select/__init__.py b/components/BalboaGL/select/__init__.py index fe9d293..c8e5c36 100644 --- a/components/BalboaGL/select/__init__.py +++ b/components/BalboaGL/select/__init__.py @@ -45,14 +45,3 @@ async def setup_conf(config, key): async def to_code(config): await setup_conf(config, CONF_PUMP1) await setup_conf(config, CONF_PUMP2) - # cg.add(cg.RawExpression("balboaglclimate->set_spa(balboagl->get_spa())")) - -# async def to_code(config): -# options_map = config[CONF_OPTIONS] -# var = await select.new_select(config, options=list(options_map.values())) -# await cg.register_component(var, config) -# cg.add(var.set_select_mappings(list(options_map.keys()))) -# parent = await cg.get_variable(config[CONF_TUYA_ID]) -# cg.add(var.set_tuya_parent(parent)) -# cg.add(var.set_select_id(config[CONF_ENUM_DATAPOINT])) -# cg.add(var.set_optimistic(config[CONF_OPTIMISTIC])) diff --git a/components/BalboaGL/switch/__init__.py b/components/BalboaGL/switch/__init__.py index 6edf985..47f0ec1 100644 --- a/components/BalboaGL/switch/__init__.py +++ b/components/BalboaGL/switch/__init__.py @@ -21,6 +21,4 @@ async def to_code(config): await cg.register_component(var, config) paren = await cg.get_variable(config[CONF_BALBOA_ID]) -# cg.add(var.set_balboa_parent(paren)) - cg.add(cg.RawExpression("balboagllightswitch->set_spa(balboagl->get_spa())")) - + cg.add(cg.RawStatement(f"{var}->set_spa({paren}->get_spa());")) From d0e5e80a640afe9a2c25b7272bc0473b4cba96d2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 18:51:45 +0000 Subject: [PATCH 323/378] buttons --- components/BalboaGL/button/BalboaGLButton.h | 23 ++++++++++ components/BalboaGL/button/__init__.py | 49 +++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 components/BalboaGL/button/BalboaGLButton.h create mode 100644 components/BalboaGL/button/__init__.py diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h new file mode 100644 index 0000000..bf50ad6 --- /dev/null +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -0,0 +1,23 @@ +#pragma once + +#include "esphome/components/button/button.h" + +using namespace esphome; + +class UpButton : public button::Button { + public: + void press_action() {} + +}; + +class DownButton : public button::Button { + public: + void press_action() {} + +}; + +class ModeButton : public button::Button { + public: + void press_action() {} + +}; diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py new file mode 100644 index 0000000..4cc69bc --- /dev/null +++ b/components/BalboaGL/button/__init__.py @@ -0,0 +1,49 @@ +import esphome.codegen as cg +from esphome.components import button +import esphome.config_validation as cv +from esphome.const import ( +) +from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL + +AUTO_LOAD = ["climate"] + +DEPENDENCIES = ["BalboaGL"] + +UpButton = cg.esphome_ns.class_("UpButton", button.Button) +DownButton = cg.esphome_ns.class_("DownButton", button.Button) +ModeButton = cg.esphome_ns.class_("ModeButton", button.Button) + +CONF_UP = "up" +CONF_DOWN = "down" +CONF_MODE = "mode" + +CONFIG_SCHEMA = { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + cv.Optional(CONF_UP): button.button_schema( + UpButton, + # icon=ICON_RESTART_ALERT, + ), + cv.Optional(CONF_DOWN): button.button_schema( + DownButton, + # device_class=DEVICE_CLASS_RESTART, + # entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + # icon=ICON_RESTART, + ), + cv.Optional(CONF_MODE): button.button_schema( + ModeButton, + # entity_category=ENTITY_CATEGORY_DIAGNOSTIC, + # icon=ICON_DATABASE, + ), +} + + +async def setup_conf(config, key): + if key in config: + conf = config[key] + var = await button.new_button(conf) + await cg.register_component(var, conf) + +async def to_code(config): + await setup_conf(config, CONF_UP) + await setup_conf(config, CONF_DOWN) + await setup_conf(config, CONF_MODE) \ No newline at end of file From 6bb1f85b18acf2b1791f899ead91e6522839caec Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 18:55:30 +0000 Subject: [PATCH 324/378] buttons --- components/BalboaGL/button/__init__.py | 32 +++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py index 4cc69bc..68a6080 100644 --- a/components/BalboaGL/button/__init__.py +++ b/components/BalboaGL/button/__init__.py @@ -17,25 +17,19 @@ CONF_DOWN = "down" CONF_MODE = "mode" -CONFIG_SCHEMA = { - cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), - cv.Optional(CONF_UP): button.button_schema( - UpButton, - # icon=ICON_RESTART_ALERT, - ), - cv.Optional(CONF_DOWN): button.button_schema( - DownButton, - # device_class=DEVICE_CLASS_RESTART, - # entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - # icon=ICON_RESTART, - ), - cv.Optional(CONF_MODE): button.button_schema( - ModeButton, - # entity_category=ENTITY_CATEGORY_DIAGNOSTIC, - # icon=ICON_DATABASE, - ), -} - +CONFIG_SCHEMA = cv.Schema( + { + cv.Optional(CONF_UP): button.button_schema(UpButton, + + ), + cv.Optional(CONF_DOWN): button.button_schema(DownButton, + + ), + cv.Optional(CONF_MODE): button.button_schema(ModeButton, + + ), + } +) async def setup_conf(config, key): if key in config: From 1af441e42e583bf9b968e7f4de4cafb6ffa8fcba Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 18:58:21 +0000 Subject: [PATCH 325/378] buttons --- components/BalboaGL/button/BalboaGLButton.h | 6 +++--- components/BalboaGL/button/__init__.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index bf50ad6..8d75564 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -4,19 +4,19 @@ using namespace esphome; -class UpButton : public button::Button { +class UpButton : public PollingComponent, public button::Button { public: void press_action() {} }; -class DownButton : public button::Button { +class DownButton : public PollingComponent, public button::Button { public: void press_action() {} }; -class ModeButton : public button::Button { +class ModeButton : public PollingComponent, public button::Button { public: void press_action() {} diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py index 68a6080..ce06fe6 100644 --- a/components/BalboaGL/button/__init__.py +++ b/components/BalboaGL/button/__init__.py @@ -5,13 +5,13 @@ ) from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL -AUTO_LOAD = ["climate"] +AUTO_LOAD = ["button"] DEPENDENCIES = ["BalboaGL"] -UpButton = cg.esphome_ns.class_("UpButton", button.Button) -DownButton = cg.esphome_ns.class_("DownButton", button.Button) -ModeButton = cg.esphome_ns.class_("ModeButton", button.Button) +UpButton = cg.esphome_ns.class_("UpButton", button.Button, cg.PollingComponent) +DownButton = cg.esphome_ns.class_("DownButton", button.Button, cg.PollingComponent) +ModeButton = cg.esphome_ns.class_("ModeButton", button.Button, cg.PollingComponent) CONF_UP = "up" CONF_DOWN = "down" From 35b934bd76f40b36a577fda51670cd0a49a4d982 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:00:23 +0000 Subject: [PATCH 326/378] buttons --- components/BalboaGL/button/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py index ce06fe6..6582443 100644 --- a/components/BalboaGL/button/__init__.py +++ b/components/BalboaGL/button/__init__.py @@ -2,6 +2,7 @@ from esphome.components import button import esphome.config_validation as cv from esphome.const import ( + ICON_LIGHTBULB ) from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL From 5fe2da710bd66f60a2c23de0b8bb430eed7f73eb Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:03:05 +0000 Subject: [PATCH 327/378] buttons --- components/BalboaGL/button/BalboaGLButton.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index 8d75564..e858030 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -7,17 +7,19 @@ using namespace esphome; class UpButton : public PollingComponent, public button::Button { public: void press_action() {} + void update() {} }; class DownButton : public PollingComponent, public button::Button { public: void press_action() {} - + void update() {} }; class ModeButton : public PollingComponent, public button::Button { public: void press_action() {} + void update() {} }; From 0be5eaa22c0937a5e5dc3e620a1dad3185b7ac33 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:08:51 +0000 Subject: [PATCH 328/378] button - set parent --- components/BalboaGL/button/BalboaGLButton.h | 16 ++++++++++++++++ components/BalboaGL/button/__init__.py | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index e858030..0362da8 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -6,20 +6,36 @@ using namespace esphome; class UpButton : public PollingComponent, public button::Button { public: + void set_spa(balboaGL* spa) { + this->spa = spa; + } void press_action() {} void update() {} + private: + balboaGL* spa; }; class DownButton : public PollingComponent, public button::Button { public: + void set_spa(balboaGL* spa) { + this->spa = spa; + } void press_action() {} void update() {} + private: + balboaGL* spa; + }; class ModeButton : public PollingComponent, public button::Button { public: + void set_spa(balboaGL* spa) { + this->spa = spa; + } void press_action() {} void update() {} + private: + balboaGL* spa; }; diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py index 6582443..753ac0b 100644 --- a/components/BalboaGL/button/__init__.py +++ b/components/BalboaGL/button/__init__.py @@ -2,7 +2,7 @@ from esphome.components import button import esphome.config_validation as cv from esphome.const import ( - ICON_LIGHTBULB + ICON_LIGHTBULB, ) from .. import balboagl_ns, CONF_BALBOA_ID, BalboaGL @@ -37,6 +37,8 @@ async def setup_conf(config, key): conf = config[key] var = await button.new_button(conf) await cg.register_component(var, conf) + paren = await cg.get_variable(config[CONF_BALBOA_ID]) + cg.add(cg.RawStatement(f"{var}->set_spa({paren}->get_spa());")) async def to_code(config): await setup_conf(config, CONF_UP) From 77b3eb61f2f42a464d40eec3883e2ed2e93532f5 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:10:16 +0000 Subject: [PATCH 329/378] button - set parent --- components/BalboaGL/button/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/BalboaGL/button/__init__.py b/components/BalboaGL/button/__init__.py index 753ac0b..437ca35 100644 --- a/components/BalboaGL/button/__init__.py +++ b/components/BalboaGL/button/__init__.py @@ -20,6 +20,8 @@ CONFIG_SCHEMA = cv.Schema( { + cv.GenerateID(CONF_BALBOA_ID): cv.use_id(BalboaGL), + cv.Optional(CONF_UP): button.button_schema(UpButton, ), From aabb6ad4ce3e0d6d94951dbb6450bfb450f726d1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:12:39 +0000 Subject: [PATCH 330/378] buttons - send command --- components/BalboaGL/button/BalboaGLButton.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index 0362da8..1eda157 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -1,6 +1,7 @@ #pragma once #include "esphome/components/button/button.h" +#include "constants.h" using namespace esphome; @@ -9,7 +10,9 @@ class UpButton : public PollingComponent, public button::Button { void set_spa(balboaGL* spa) { this->spa = spa; } - void press_action() {} + void press_action() { + this->spa->queueCommand(COMMAND_UP, 1); + } void update() {} private: balboaGL* spa; @@ -21,7 +24,9 @@ class DownButton : public PollingComponent, public button::Button { void set_spa(balboaGL* spa) { this->spa = spa; } - void press_action() {} + void press_action() { + this->spa->queueCommand(COMMAND_DOWN, 1); + } void update() {} private: balboaGL* spa; @@ -33,7 +38,9 @@ class ModeButton : public PollingComponent, public button::Button { void set_spa(balboaGL* spa) { this->spa = spa; } - void press_action() {} + void press_action() { + this->spa->queueCommand(COMMAND_MODE, 1); + } void update() {} private: balboaGL* spa; From de26ad67f9a63dc4f198cf7410007c94a7009f01 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:13:45 +0000 Subject: [PATCH 331/378] buttons - send command --- components/BalboaGL/button/BalboaGLButton.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index 1eda157..e87eb31 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -1,7 +1,7 @@ #pragma once #include "esphome/components/button/button.h" -#include "constants.h" +#include "balboaGL.h" using namespace esphome; From 115c15254646ae97d0c11831693ee03cab239944 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:14:20 +0000 Subject: [PATCH 332/378] buttons - send command --- components/BalboaGL/button/BalboaGLButton.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index e87eb31..ff5a6ef 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -2,6 +2,7 @@ #include "esphome/components/button/button.h" #include "balboaGL.h" +#include "constants.h" using namespace esphome; From 1ebb61cf8d82df06a8108a389abcd09f710e9557 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:19:05 +0000 Subject: [PATCH 333/378] buttons - send command --- components/BalboaGL/button/BalboaGLButton.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/BalboaGL/button/BalboaGLButton.h b/components/BalboaGL/button/BalboaGLButton.h index ff5a6ef..1df7877 100644 --- a/components/BalboaGL/button/BalboaGLButton.h +++ b/components/BalboaGL/button/BalboaGLButton.h @@ -2,7 +2,6 @@ #include "esphome/components/button/button.h" #include "balboaGL.h" -#include "constants.h" using namespace esphome; @@ -12,7 +11,7 @@ class UpButton : public PollingComponent, public button::Button { this->spa = spa; } void press_action() { - this->spa->queueCommand(COMMAND_UP, 1); + this->spa->buttonPressUp(); } void update() {} private: @@ -26,7 +25,7 @@ class DownButton : public PollingComponent, public button::Button { this->spa = spa; } void press_action() { - this->spa->queueCommand(COMMAND_DOWN, 1); + this->spa->buttonPressDown(); } void update() {} private: @@ -40,7 +39,7 @@ class ModeButton : public PollingComponent, public button::Button { this->spa = spa; } void press_action() { - this->spa->queueCommand(COMMAND_MODE, 1); + this->spa->buttonPressMode(); } void update() {} private: From ce67b9e7292e88a3c4ede7bdf3c44fc124dc7c5b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:20:08 +0000 Subject: [PATCH 334/378] buttons - send command --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 4aa4d72..5c3c87e 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -95,5 +95,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="ce3e1f8b9c6d3a0b141658432ed8751971b47fee", + version="23d1132fe3661a88c1b49966b338a6de7c248416", ) From a0dcac16dac85d11c45663cb6fcb3fb7ef86857d Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 19:31:15 +0000 Subject: [PATCH 335/378] Update example --- component.yaml | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/component.yaml b/component.yaml index db739f5..5b5ab02 100644 --- a/component.yaml +++ b/component.yaml @@ -1,11 +1,10 @@ - ota: password: "e82fe9bada398051d779151a591a1e2e" + # Needed to get round interrupt issue on_begin: then: - - lambda: balboagl->pause -# OTA pause needed to prevent interrupts blocking OTA - + - lambda: balboagl->pause(); + external_components: - source: type: git @@ -15,7 +14,7 @@ external_components: BalboaGL: - # Example pins for T-RSC3 + # Pin values for T-RSC3 hardware_uart: UART1 rx_pin: 3 tx_pin: 10 @@ -46,8 +45,8 @@ text_sensor: name: State raw: name: Raw Data - lcd: - name: LCD Display + # lcd: + # name: LCD Display # Sensors with general information. sensor: @@ -69,9 +68,22 @@ switch: name: Light -# select: -# - platform: BalboaGL -# pump1: -# name: Pump1 -# options: "HIGH" +select: + - platform: BalboaGL + pump1: + name: Pump1 + options: + "HIGH" + pump2: + name: Pump2 + options: + "HIGH" +button: + - platform: BalboaGL + up: + name: "UP" + down: + name: "Down" + mode: + name: "Mode" From ddb3c29f85997d850d58ab93337322d4c7ec6d0c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 20:15:08 +0000 Subject: [PATCH 336/378] prevent log crash --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 3e89a06..fec5851 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -7,7 +7,8 @@ void telnetSend(String msg) { } void log(const char *format, ...) { - ESP_LOGI(TAG, format); + // ESP_LOGI(TAG, format); + // TODO: fix this logger call } /** * Create a new BalboaGL object From 0860b5173c3552e824a52920ed6a110d2e032f72 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 21:01:02 +0000 Subject: [PATCH 337/378] logger --- components/BalboaGL/ESPBalboaGL.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index fec5851..53493ba 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -7,8 +7,31 @@ void telnetSend(String msg) { } void log(const char *format, ...) { - // ESP_LOGI(TAG, format); - // TODO: fix this logger call + char loc_buf[64]; + char * temp = loc_buf; + va_list arg; + va_list copy; + va_start(arg, format); + va_copy(copy, arg); + int len = vsnprintf(temp, sizeof(loc_buf), format, copy); + va_end(copy); + if(len < 0) { + va_end(arg); + }; + if(len >= sizeof(loc_buf)){ + temp = (char*) malloc(len+1); + if(temp == NULL) { + va_end(arg); + } + len = vsnprintf(temp, len+1, format, arg); + } + va_end(arg); + std::string str = reinterpret_cast(temp); + Serial.print(str.c_str()); + if(temp != loc_buf){ + free(temp); + } + } /** * Create a new BalboaGL object From 5c2c65a93b2538cbbff5b0605218964ea8b1343b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 21:12:56 +0000 Subject: [PATCH 338/378] logger --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 53493ba..870947e 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -27,7 +27,7 @@ void log(const char *format, ...) { } va_end(arg); std::string str = reinterpret_cast(temp); - Serial.print(str.c_str()); + ESP_LOGI(str.c_str()); if(temp != loc_buf){ free(temp); } From c7f3e536b2ce584e995a065f04af1da37802f598 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Thu, 2 Nov 2023 21:13:56 +0000 Subject: [PATCH 339/378] logger --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 870947e..6e59797 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -27,7 +27,7 @@ void log(const char *format, ...) { } va_end(arg); std::string str = reinterpret_cast(temp); - ESP_LOGI(str.c_str()); + ESP_LOGI(TAG, str.c_str()); if(temp != loc_buf){ free(temp); } From acd95ef869a7f02cfa4694b1402780b985e95b21 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 3 Nov 2023 18:22:43 +0000 Subject: [PATCH 340/378] No wait --- components/BalboaGL/ESPBalboaGL.cpp | 4 +++- components/BalboaGL/ESPBalboaGL.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 6e59797..f5656e4 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -93,7 +93,9 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); - this->spa->attachPanelInterrupt(); + this->spa->attachPanelInterrupt(); + + this->high_freq_.start(); // no wait on main loop // ESP_LOGCONFIG( // TAG, diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 6302333..13c443c 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -86,6 +86,8 @@ class BalboaGL : public Component { int rts_pin = -1; int panel_select_pin = -1; + HighFrequencyLoopRequester high_freq_; + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From 03ba436ae580e07fddbbe5fdb6d4dcd92fe1ee8b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 3 Nov 2023 18:29:49 +0000 Subject: [PATCH 341/378] Add delay_time --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++++ components/BalboaGL/ESPBalboaGL.h | 2 ++ components/BalboaGL/__init__.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f5656e4..6f638a6 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -188,3 +188,7 @@ void BalboaGL::set_rts_pin(int pin) { void BalboaGL::set_panel_select_pin(int pin) { this->panel_select_pin = pin; } + +void BalboaGL::set_delay_time(int delay) { + this->spa->set_delay_time(delay); +} \ No newline at end of file diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 13c443c..61da904 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -62,6 +62,8 @@ class BalboaGL : public Component { void set_panel_select_pin(int pin); + void set_delay_time(int delay); + float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } void pause(); diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 5c3c87e..146894b 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -19,6 +19,8 @@ CONF_ENABLE_PIN = "enable_pin" CONF_PANEL_SELECT_PIN = "panel_select_pin" +CONF_DELAY_TIME = "delay_time" + balboagl_ns = cg.esphome_ns.namespace("balboagl") BalboaGL = cg.global_ns.class_( "BalboaGL", cg.Component @@ -50,6 +52,7 @@ def valid_uart(uart): cv.Required(CONF_TX_PIN): cv.int_range(), cv.Required(CONF_PANEL_SELECT_PIN): cv.int_range(), cv.Optional(CONF_ENABLE_PIN): cv.int_range(), + cv.Optional(CONF_DELAY_TIME): cv.int_range(), # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { @@ -78,6 +81,9 @@ def to_code(config): if CONF_PANEL_SELECT_PIN in config: cg.add(var.set_panel_select_pin(config[CONF_PANEL_SELECT_PIN])) + if CONF_DELAY_TIME in config: + cg.add(var.set_delay_time(config[CONF_DELAY_TIME])) + yield cg.register_component(var, config) From 9c5cdb6977f3405117bad92d2961cf8b43bab5cf Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 3 Nov 2023 18:51:30 +0000 Subject: [PATCH 342/378] Delay setting delay --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- components/BalboaGL/ESPBalboaGL.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 6f638a6..674d033 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -94,6 +94,7 @@ void BalboaGL::setup() { hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); this->spa->attachPanelInterrupt(); + if(delay_time > -1) this->spa->set_delay_time(delay_time); this->high_freq_.start(); // no wait on main loop @@ -190,5 +191,5 @@ void BalboaGL::set_panel_select_pin(int pin) { } void BalboaGL::set_delay_time(int delay) { - this->spa->set_delay_time(delay); + this->delay_time; } \ No newline at end of file diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index 61da904..b711188 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -90,6 +90,8 @@ class BalboaGL : public Component { HighFrequencyLoopRequester high_freq_; + int delay_time = -1; + private: // Retrieve the HardwareSerial pointer from friend and subclasses. HardwareSerial *hw_serial_; From 398428545f4d79b6faf250ff4de21cb8c53f296e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 14:08:25 +0000 Subject: [PATCH 343/378] Set temp range --- components/BalboaGL/climate/BalboaGLClimate.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index e8851ff..7ef7a3d 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -341,6 +341,9 @@ void BalboaGLClimate::setup() { this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; this->action = climate::CLIMATE_ACTION_FAN; + this->visual_min_temperature_override_ = 26; + this->visual_max_temperature_override_ = 40; + this->visual_current_temperature_step_override_ = 0.5; // ESP_LOGCONFIG( // TAG, From db1ebbcb2faf24733d95dc4e0735b4372aa26be2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 14:11:03 +0000 Subject: [PATCH 344/378] Set temp range --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 7ef7a3d..3d91f57 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -343,7 +343,7 @@ void BalboaGLClimate::setup() { this->action = climate::CLIMATE_ACTION_FAN; this->visual_min_temperature_override_ = 26; this->visual_max_temperature_override_ = 40; - this->visual_current_temperature_step_override_ = 0.5; + this->visual_target_temperature_step_override_ = 0.5; // ESP_LOGCONFIG( // TAG, From 9d41c45300d039dddcaf525cdfa547331f26d44e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 14:21:13 +0000 Subject: [PATCH 345/378] No actions --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 3d91f57..0f9ef6a 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -340,7 +340,7 @@ void BalboaGLClimate::setup() { this->target_temperature = NAN; this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; - this->action = climate::CLIMATE_ACTION_FAN; + this->traits_.set_supports_action(false); this->visual_min_temperature_override_ = 26; this->visual_max_temperature_override_ = 40; this->visual_target_temperature_step_override_ = 0.5; From 3da62bb7afa211130cd6483ea474ee2322132142 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 14:25:17 +0000 Subject: [PATCH 346/378] update temp --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 0f9ef6a..36a1308 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -9,7 +9,7 @@ void BalboaGLClimate::update() { // ESP_LOGV(TAG, "BalboaGLClimate Update called."); static String lastRaw = "0"; - if(status.rawData != lastRaw) { + if(status.rawData != lastRaw || status.temp ! = this->current_temperature) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); ESP_LOGD(TAG, "Current Temp: %f", status.temp); ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); From d0c3a085eecd70bb94d200d3d0c38373fc44273e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 14:32:16 +0000 Subject: [PATCH 347/378] update temp --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 36a1308..c108a77 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -9,7 +9,7 @@ void BalboaGLClimate::update() { // ESP_LOGV(TAG, "BalboaGLClimate Update called."); static String lastRaw = "0"; - if(status.rawData != lastRaw || status.temp ! = this->current_temperature) { + if((status.rawData != lastRaw) || (status.temp != this->current_temperature)) { ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); ESP_LOGD(TAG, "Current Temp: %f", status.temp); ESP_LOGD(TAG, "Target Temp: %f", status.targetTemp); From f6e3cf6b8fe572e98357c103fea8042bf14253ef Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 16:31:34 +0000 Subject: [PATCH 348/378] Current temp and presets --- components/BalboaGL/climate/BalboaGLClimate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index c108a77..2669d3f 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -341,6 +341,12 @@ void BalboaGLClimate::setup() { this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; this->traits_.set_supports_action(false); + set_supports_current_temperature(true); + this->traits_.add_supported_custom_preset(std::string("STD")); + this->traits_.add_supported_custom_preset(std::string("ECO")); + this->traits_.add_supported_custom_preset(std::string("Sleep")); + this->traits_.add_supported_custom_preset(std::string("UNKNOWN")); + this->visual_min_temperature_override_ = 26; this->visual_max_temperature_override_ = 40; this->visual_target_temperature_step_override_ = 0.5; From ab8efc8c719d0e7d143b9b837a6caa20a1afd115 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 16:33:16 +0000 Subject: [PATCH 349/378] Current temp and presets --- components/BalboaGL/climate/BalboaGLClimate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/climate/BalboaGLClimate.cpp b/components/BalboaGL/climate/BalboaGLClimate.cpp index 2669d3f..ec55200 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.cpp +++ b/components/BalboaGL/climate/BalboaGLClimate.cpp @@ -341,7 +341,7 @@ void BalboaGLClimate::setup() { this->fan_mode = climate::CLIMATE_FAN_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF; this->traits_.set_supports_action(false); - set_supports_current_temperature(true); + this->traits_.set_supports_current_temperature(true); this->traits_.add_supported_custom_preset(std::string("STD")); this->traits_.add_supported_custom_preset(std::string("ECO")); this->traits_.add_supported_custom_preset(std::string("Sleep")); From 0cd52c3a40ce2327ffd21c4f3d347a0dd92636ce Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 18:31:47 +0000 Subject: [PATCH 350/378] Hold control while trying to send --- components/BalboaGL/ESPBalboaGL.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 674d033..7d97838 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -62,14 +62,17 @@ void BalboaGL::check_logger_conflict_() { void BalboaGL::loop() { // This will be called every "update_interval" milliseconds. // ESP_LOGV(TAG, "Loop called."); - size_t len = this->spa->readSerial(); - // ESP_LOGV(TAG, "Read %u bytes", len); - static String lastRaw = "0"; - if(status.rawData != lastRaw) { - ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); - lastRaw = status.rawData; - // this->publish_state(); + do { + size_t len = this->spa->readSerial(); + // ESP_LOGV(TAG, "Read %u bytes", len); + static String lastRaw = "0"; + if(status.rawData != lastRaw) { + ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); + lastRaw = status.rawData; + // this->publish_state(); + } } + while(status.commandQueue > 0) } From 225cc6a27f67dee4a3d15ca5c3354ead8000c4b2 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 18:33:33 +0000 Subject: [PATCH 351/378] Hold control while trying to send --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 7d97838..16a0941 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -72,7 +72,7 @@ void BalboaGL::loop() { // this->publish_state(); } } - while(status.commandQueue > 0) + while(status.commandQueue > 0); } From 143632576dd434d67955188c1d6c520991a5442f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 4 Nov 2023 18:35:18 +0000 Subject: [PATCH 352/378] Hold control while trying to send --- components/BalboaGL/ESPBalboaGL.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 16a0941..a41acc8 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -62,6 +62,7 @@ void BalboaGL::check_logger_conflict_() { void BalboaGL::loop() { // This will be called every "update_interval" milliseconds. // ESP_LOGV(TAG, "Loop called."); + int sanity = 0; do { size_t len = this->spa->readSerial(); // ESP_LOGV(TAG, "Read %u bytes", len); @@ -71,8 +72,9 @@ void BalboaGL::loop() { lastRaw = status.rawData; // this->publish_state(); } + sanity++; } - while(status.commandQueue > 0); + while((status.commandQueue > 0) && (sanity < 10)); } From e2a93cfadfcc52a4651cc6b8bd1f9807bb8df862 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 5 Nov 2023 14:30:34 +0000 Subject: [PATCH 353/378] Try invert --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index a41acc8..375166a 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -96,7 +96,8 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); - hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); + bool invert = true; + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin, invert); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From c3989432caccd1f91736754ba4f4cc8e05b95786 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sun, 5 Nov 2023 18:01:41 +0000 Subject: [PATCH 354/378] logger tweak --- components/BalboaGL/ESPBalboaGL.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 375166a..7e3c3c6 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -60,7 +60,6 @@ void BalboaGL::check_logger_conflict_() { } void BalboaGL::loop() { - // This will be called every "update_interval" milliseconds. // ESP_LOGV(TAG, "Loop called."); int sanity = 0; do { @@ -75,7 +74,7 @@ void BalboaGL::loop() { sanity++; } while((status.commandQueue > 0) && (sanity < 10)); - + ESP_LOGD(TAG, "q:%u s:%u", status.commandQueue, sanity); } void BalboaGL::setup() { From 4434929b8f9e270916c70606623d6910246e9565 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Mon, 6 Nov 2023 19:21:12 +0000 Subject: [PATCH 355/378] logger tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 7e3c3c6..128562d 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -74,7 +74,7 @@ void BalboaGL::loop() { sanity++; } while((status.commandQueue > 0) && (sanity < 10)); - ESP_LOGD(TAG, "q:%u s:%u", status.commandQueue, sanity); + if(status.commandQueue > 0) ESP_LOGD(TAG, "q:%u s:%u", status.commandQueue, sanity); } void BalboaGL::setup() { From 048aafa17021e61939ea1ffb6d72e7a5c0606863 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 10 Nov 2023 15:45:49 +0000 Subject: [PATCH 356/378] Cleanup merge --- sensor/src/sensor.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sensor/src/sensor.cpp b/sensor/src/sensor.cpp index 9268546..28a2a7b 100644 --- a/sensor/src/sensor.cpp +++ b/sensor/src/sensor.cpp @@ -176,12 +176,6 @@ void onTargetTemperatureCommand(HANumeric temperature, HAHVAC* sender) { Serial.println(temperatureFloat); spa.setTemp(temperatureFloat); -<<<<<<< HEAD - - // sender->setTargetTemperature(temperature); // report target temperature back to the HA panel - better to see what - // the control unit reports that assume our commands worked -======= ->>>>>>> library } void updateHAStatus() { From 53bba06efe5dffd998ce76039457c883b53364c1 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 11 Nov 2023 17:45:32 +0000 Subject: [PATCH 357/378] Revert "Try invert" This reverts commit e2a93cfadfcc52a4651cc6b8bd1f9807bb8df862. --- components/BalboaGL/ESPBalboaGL.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 128562d..f3d2dab 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -95,8 +95,7 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); - bool invert = true; - hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin, invert); + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From b793611ce7c6f8d28a9860ad5f4c1b31147fdf89 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 11 Nov 2023 17:56:32 +0000 Subject: [PATCH 358/378] Log level tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f3d2dab..226b9ba 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -74,7 +74,7 @@ void BalboaGL::loop() { sanity++; } while((status.commandQueue > 0) && (sanity < 10)); - if(status.commandQueue > 0) ESP_LOGD(TAG, "q:%u s:%u", status.commandQueue, sanity); + if(status.commandQueue > 0) ESP_LOGV(TAG, "q:%u s:%u", status.commandQueue, sanity); } void BalboaGL::setup() { From fadf1a674074357dec17544082fa8c60c9cc6720 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 11 Nov 2023 18:15:52 +0000 Subject: [PATCH 359/378] Log tweak --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 226b9ba..b7e9187 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -74,7 +74,7 @@ void BalboaGL::loop() { sanity++; } while((status.commandQueue > 0) && (sanity < 10)); - if(status.commandQueue > 0) ESP_LOGV(TAG, "q:%u s:%u", status.commandQueue, sanity); +// if(status.commandQueue > 0) ESP_LOGV(TAG, "q:%u s:%u", status.commandQueue, sanity); } void BalboaGL::setup() { From 639d8eada9e3204423e344e24cdc93706da45453 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 11 Nov 2023 18:59:23 +0000 Subject: [PATCH 360/378] Disable flow control --- components/BalboaGL/ESPBalboaGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index b7e9187..188ff36 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -96,7 +96,8 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin, ESP_LOG_VERBOSE); + hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); + this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From f5410b163178d915177c990610795a3fc4ade6ee Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 1 Dec 2023 19:58:21 +0000 Subject: [PATCH 361/378] Remove logger for raw change --- components/BalboaGL/ESPBalboaGL.cpp | 14 ++++++-------- components/BalboaGL/ESPBalboaGL.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 188ff36..eb974a0 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -63,14 +63,12 @@ void BalboaGL::loop() { // ESP_LOGV(TAG, "Loop called."); int sanity = 0; do { - size_t len = this->spa->readSerial(); - // ESP_LOGV(TAG, "Read %u bytes", len); - static String lastRaw = "0"; - if(status.rawData != lastRaw) { - ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); - lastRaw = status.rawData; - // this->publish_state(); - } + this->spa->readSerial(); + // if(status.rawData != lastRaw) { + // ESP_LOGD(TAG, "Raw: %s", status.rawData.c_str()); + // lastRaw = status.rawData; + // // this->publish_state(); + // } sanity++; } while((status.commandQueue > 0) && (sanity < 10)); diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index b711188..b58c40e 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -97,5 +97,6 @@ class BalboaGL : public Component { HardwareSerial *hw_serial_; balboaGL* spa; + String lastRaw = "0"; }; #endif \ No newline at end of file From bf5f862bb2184178baa66af1b0826399d4b9f20f Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 1 Dec 2023 20:12:34 +0000 Subject: [PATCH 362/378] Fast loop when sending --- components/BalboaGL/ESPBalboaGL.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index eb974a0..0372e4c 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -72,6 +72,13 @@ void BalboaGL::loop() { sanity++; } while((status.commandQueue > 0) && (sanity < 10)); + if(status.commandQueue > 0) { + this->high_freq_.start(); // no wait on main loop + } + else { + this->high_freq_.stop(); + } + // if(status.commandQueue > 0) ESP_LOGV(TAG, "q:%u s:%u", status.commandQueue, sanity); } @@ -99,8 +106,6 @@ void BalboaGL::setup() { this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); - this->high_freq_.start(); // no wait on main loop - // ESP_LOGCONFIG( // TAG, // "hw_serial(%p) is &Serial(%p)? %s", From 1e2dc292112ae96197613aed028ffa849be2ea0c Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 1 Dec 2023 20:27:43 +0000 Subject: [PATCH 363/378] cleanup --- components/BalboaGL/ESPBalboaGL.cpp | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 0372e4c..f29e90f 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -128,16 +128,6 @@ void BalboaGL::setup() { // this->mark_failed(); // } -// // create various setpoint persistence: -// cool_storage = global_preferences->make_preference(this->get_object_id_hash() + 1); -// heat_storage = global_preferences->make_preference(this->get_object_id_hash() + 2); -// auto_storage = global_preferences->make_preference(this->get_object_id_hash() + 3); - -// // load values from storage: -// cool_setpoint = load(cool_storage); -// heat_setpoint = load(heat_storage); -// auto_setpoint = load(auto_storage); - ESP_LOGCONFIG(TAG, "End of seutp"); this->dump_config(); } @@ -147,24 +137,6 @@ void BalboaGL::pause() { this->spa->detachPanelInterrupt(); } -// /** -// * The ESP only has a few bytes of rtc storage, so instead -// * of storing floats directly, we'll store the number of -// * TEMPERATURE_STEPs from MIN_TEMPERATURE. -// **/ -// void BalboaGL::save(float value, ESPPreferenceObject& storage) { -// uint8_t steps = (value - ESPMHP_MIN_TEMPERATURE) / ESPMHP_TEMPERATURE_STEP; -// storage.save(&steps); -// } - -// optional BalboaGL::load(ESPPreferenceObject& storage) { -// uint8_t steps = 0; -// if (!storage.load(&steps)) { -// return {}; -// } -// return ESPMHP_MIN_TEMPERATURE + (steps * ESPMHP_TEMPERATURE_STEP); -// } - void BalboaGL::dump_config() { // this->banner(); ESP_LOGI(TAG, " rx,tx = %u,%u", this->rx_pin, this->tx_pin); From 66056caae7ef58428b73b3036e9fb1e128a5e81e Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 1 Dec 2023 20:38:41 +0000 Subject: [PATCH 364/378] WARNING - new default pins --- sensor/src/sensor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensor/src/sensor.cpp b/sensor/src/sensor.cpp index bc0608f..3aa0b52 100644 --- a/sensor/src/sensor.cpp +++ b/sensor/src/sensor.cpp @@ -57,10 +57,10 @@ Adafruit_NeoPixel pixels(1, 4, NEO_GRB + NEO_KHZ800); #elif ESP32 #define tub Serial1 -#define RX_PIN 19 -#define TX_PIN 23 +#define RX_PIN 17 +#define TX_PIN 16 #define RTS_PIN_DEF 22 // RS485 direction control, RequestToSend TX or RX, required for MAX485 board. -#define PIN_5_PIN_DEF 18 +#define PIN_5_PIN_DEF 21 #else SoftwareSerial tub; #define RX_PIN D6 From 67c7be26390575f2a595dead9fefce301328988b Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Fri, 1 Dec 2023 22:04:23 +0000 Subject: [PATCH 365/378] Cleanup --- components/BalboaGL/ESPBalboaGL.h | 8 +------- components/BalboaGL/climate/BalboaGLClimate.h | 20 ------------------- components/BalboaGL/sensor/BalboaGLSesnor.h | 7 +------ components/BalboaGL/switch/BalboaGLSwitch.h | 2 +- .../BalboaGL/text_sensor/BalboaGLTextSesnor.h | 11 ---------- 5 files changed, 3 insertions(+), 45 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.h b/components/BalboaGL/ESPBalboaGL.h index b58c40e..0722b7e 100755 --- a/components/BalboaGL/ESPBalboaGL.h +++ b/components/BalboaGL/ESPBalboaGL.h @@ -39,12 +39,6 @@ class BalboaGL : public Component { // print the current configuration void dump_config() override; - // // handle a change in settings as detected by the HeatPump library. - // void hpSettingsChanged(); - - // // Handle a change in status as detected by the HeatPump library. - // void hpStatusChanged(heatpumpStatus currentStatus); - // Set up the component, initializing the balboaGL object. void setup() override; @@ -64,7 +58,7 @@ class BalboaGL : public Component { void set_delay_time(int delay); - float get_setup_priority() const override { return esphome::setup_priority::AFTER_WIFI; } + float get_setup_priority() const override { return esphome::setup_priority::HARDWARE; } void pause(); diff --git a/components/BalboaGL/climate/BalboaGLClimate.h b/components/BalboaGL/climate/BalboaGLClimate.h index 562cb6c..c3c5791 100644 --- a/components/BalboaGL/climate/BalboaGLClimate.h +++ b/components/BalboaGL/climate/BalboaGLClimate.h @@ -8,20 +8,6 @@ #include "esp_log.h" #include "../ESPBalboaGL.h" - -// // Perform measurements or read nameplate values on your tub to define the power [kW] -// // for each device in order to calculate tub power usage -// const float POWER_HEATER = 2.8; -// const float POWER_PUMP_CIRCULATION = 0.3; -// const float POWER_PUMP1_LOW = 0.31; -// const float POWER_PUMP1_HIGH = 1.3; -// const float POWER_PUMP2_LOW = 0.3; -// const float POWER_PUMP2_HIGH = 0.6; - -// // Tweak for your tub - would be nice to auto-learn in the future to allow for outside temp etc -// const int MINUTES_PER_DEGC = 45; - - #include "balboaGL.h" using namespace esphome; @@ -34,12 +20,6 @@ class BalboaGLClimate : public PollingComponent, public climate::Climate { // print the current configuration void dump_config() override; - // // handle a change in settings as detected by the HeatPump library. - // void hpSettingsChanged(); - - // // Handle a change in status as detected by the HeatPump library. - // void hpStatusChanged(heatpumpStatus currentStatus); - // Set up the component, initializing the balboaGL object. void setup() override; diff --git a/components/BalboaGL/sensor/BalboaGLSesnor.h b/components/BalboaGL/sensor/BalboaGLSesnor.h index bb7c2ce..4e3e04c 100644 --- a/components/BalboaGL/sensor/BalboaGLSesnor.h +++ b/components/BalboaGL/sensor/BalboaGLSesnor.h @@ -9,9 +9,6 @@ using namespace esphome; class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::Sensor { public: - // void setSpa(balboaGL* spa) { - // this->spa = spa; - // } void update() override { if(status.commandQueue != this->last_value) { this->last_value = status.commandQueue; @@ -19,8 +16,6 @@ class BalboaGLCommandQueueSensor : public PollingComponent, public sensor::Senso } } private: - u_int8_t last_value; - // balboaGL* spa; - + u_int8_t last_value; }; diff --git a/components/BalboaGL/switch/BalboaGLSwitch.h b/components/BalboaGL/switch/BalboaGLSwitch.h index 7f5d829..dd42f95 100644 --- a/components/BalboaGL/switch/BalboaGLSwitch.h +++ b/components/BalboaGL/switch/BalboaGLSwitch.h @@ -36,7 +36,7 @@ using namespace esphome; } } - private: + private: balboaGL* spa; bool last_state; }; \ No newline at end of file diff --git a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h index c76defb..2e7bd20 100644 --- a/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h +++ b/components/BalboaGL/text_sensor/BalboaGLTextSesnor.h @@ -3,15 +3,10 @@ #include "esphome.h" #include "esphome/components/text_sensor/text_sensor.h" -// #include "balboaGL.h" - using namespace esphome; class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSensor { public: - // void setSpa(balboaGL* spa) { - // this->spa = spa; - // } void setup() override { this->last_value = "Awaiting data"; } @@ -29,9 +24,6 @@ class BalboaGLStateSensor : public PollingComponent, public text_sensor::TextSen class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSensor { public: - // void setSpa(balboaGL* spa) { - // this->spa = spa; - // } void setup() override { this->last_value = "no data"; } @@ -49,9 +41,6 @@ class BalboaGLRawSensor : public PollingComponent, public text_sensor::TextSenso class BalboaGLLCDSensor : public PollingComponent, public text_sensor::TextSensor { public: - // void setSpa(balboaGL* spa) { - // this->spa = spa; - // } void setup() override { this->last_value = "unknown"; } From 850479579311d0575bdf7b7b8830d7516db6e519 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:03:11 +0100 Subject: [PATCH 366/378] updated library - lastCmdTime update --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 146894b..c60f677 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -101,5 +101,5 @@ def to_code(config): cg.add_library( name="balboaGL", repository="https://github.com/netmindz/balboaGL.git", - version="23d1132fe3661a88c1b49966b338a6de7c248416", + version="af714231217e5f35be7c4bb77a3e417a2bcbff49", ) From d6fe4d5688b6a389f087920cf8db9c6938307c59 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:07:57 +0100 Subject: [PATCH 367/378] Update HARDWARE_UART_TO_SERIAL --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index c60f677..323e682 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -64,7 +64,7 @@ def valid_uart(uart): @coroutine def to_code(config): - serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] + serial = HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) cg.add_define("tubUART 1") # TODO make dynamic From cd6228164f36a0b934dcce9002066316f890926a Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:09:04 +0100 Subject: [PATCH 368/378] Add PLATFORM_ESP32 --- components/BalboaGL/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 323e682..5c6e8ff 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -7,6 +7,7 @@ CONF_UPDATE_INTERVAL, CONF_RX_PIN, CONF_TX_PIN, + PLATFORM_ESP32, ) from esphome.core import CORE, coroutine From a4325ae03af352acc47a78c0a3881b57b8534a7e Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:12:34 +0100 Subject: [PATCH 369/378] Update __init__.py --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index 5c6e8ff..b0945fe 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -65,7 +65,7 @@ def valid_uart(uart): @coroutine def to_code(config): - serial = HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] + # serial = HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) cg.add_define("tubUART 1") # TODO make dynamic From 0eb4971fc6e5c02cdc730d2240e3f6624304abc0 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:13:33 +0100 Subject: [PATCH 370/378] Update __init__.py --- components/BalboaGL/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index b0945fe..bb46c6f 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -65,7 +65,8 @@ def valid_uart(uart): @coroutine def to_code(config): - # serial = HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] + serial = "Serial" + # HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) cg.add_define("tubUART 1") # TODO make dynamic From ce3f956fe60c0f1473b632c23f4360f6c08e37f0 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 22:21:14 +0100 Subject: [PATCH 371/378] Update __init__.py --- components/BalboaGL/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/__init__.py b/components/BalboaGL/__init__.py index bb46c6f..b23bdac 100644 --- a/components/BalboaGL/__init__.py +++ b/components/BalboaGL/__init__.py @@ -65,7 +65,7 @@ def valid_uart(uart): @coroutine def to_code(config): - serial = "Serial" + serial = cg.global_ns.Serial1 # HARDWARE_UART_TO_SERIAL[PLATFORM_ESP32][config[CONF_HARDWARE_UART]] var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) From a4577751a3282c1ffc81ddb6233779881b05e559 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:02:18 +0100 Subject: [PATCH 372/378] Invert --- components/BalboaGL/ESPBalboaGL.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index f29e90f..79ae5c2 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -99,8 +99,8 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); - hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); + ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u and invert=true", this->rx_pin, this->tx_pin); + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin, true); hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); @@ -172,4 +172,4 @@ void BalboaGL::set_panel_select_pin(int pin) { void BalboaGL::set_delay_time(int delay) { this->delay_time; -} \ No newline at end of file +} From 9f5b2f089d10195de48da9b820c23415203f5cef Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:17:32 +0100 Subject: [PATCH 373/378] UART_MODE_RS485_HALF_DUPLEX --- components/BalboaGL/ESPBalboaGL.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 79ae5c2..d95589a 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -99,9 +99,11 @@ void BalboaGL::setup() { ESP_LOGCONFIG(TAG, "Initialize new balboaGL object."); - ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u and invert=true", this->rx_pin, this->tx_pin); - hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin, true); + ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); + hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); + hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin) + hw_serial->setMode(UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From 3615e97dd16f048f4fd7ab6bae56cd21461e4f7c Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:18:20 +0100 Subject: [PATCH 374/378] UART_MODE_RS485_HALF_DUPLEX --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index d95589a..a7539c6 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -102,7 +102,7 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); - hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin) + hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin); hw_serial->setMode(UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); From ca86dc316a59ca15ed40cde9f99a57661c958e68 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:18:59 +0100 Subject: [PATCH 375/378] Update ESPBalboaGL.cpp --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index a7539c6..4069c27 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -103,7 +103,7 @@ void BalboaGL::setup() { hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin); - hw_serial->setMode(UART_MODE_RS485_HALF_DUPLEX); + hw_serial_->setMode(UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From bc5af6e19b5a8d7e77347df6578c610191990807 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:24:15 +0100 Subject: [PATCH 376/378] SerialMode.UART_MODE_RS485_HALF_DUPLEX --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 4069c27..9747456 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -103,7 +103,7 @@ void BalboaGL::setup() { hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin); - hw_serial_->setMode(UART_MODE_RS485_HALF_DUPLEX); + hw_serial_->setMode(SerialMode.UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From e5702be42f4d50f0c1d17882ca67a22a7996324d Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:25:37 +0100 Subject: [PATCH 377/378] Update ESPBalboaGL.cpp --- components/BalboaGL/ESPBalboaGL.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 9747456..1fec656 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -101,9 +101,9 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - hw_serial_->setHwFlowCtrlMode(HW_FLOWCTRL_DISABLE); + hw_serial_->setHwFlowCtrlMode(UART_HW_FLOWCTRL_RTS); hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin); - hw_serial_->setMode(SerialMode.UART_MODE_RS485_HALF_DUPLEX); + // hw_serial_->setMode(UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin); this->spa->attachPanelInterrupt(); if(delay_time > -1) this->spa->set_delay_time(delay_time); From 050e3b9532e8f8e7107c34732869a80ffc564972 Mon Sep 17 00:00:00 2001 From: netmindz Date: Tue, 17 Sep 2024 23:28:48 +0100 Subject: [PATCH 378/378] Update ESPBalboaGL.cpp --- components/BalboaGL/ESPBalboaGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/BalboaGL/ESPBalboaGL.cpp b/components/BalboaGL/ESPBalboaGL.cpp index 1fec656..7063638 100755 --- a/components/BalboaGL/ESPBalboaGL.cpp +++ b/components/BalboaGL/ESPBalboaGL.cpp @@ -101,7 +101,7 @@ void BalboaGL::setup() { ESP_LOGI(TAG, "Serial begin rx,tx = %u,%u", this->rx_pin, this->tx_pin); hw_serial_->begin(115200, SERIAL_8N1, rx_pin, tx_pin); - hw_serial_->setHwFlowCtrlMode(UART_HW_FLOWCTRL_RTS); + // hw_serial_->setHwFlowCtrlMode(UART_HW_FLOWCTRL_RTS); hw_serial_->setPins(this->rx_pin, this->tx_pin, -1, this->rts_pin); // hw_serial_->setMode(UART_MODE_RS485_HALF_DUPLEX); this->spa = new balboaGL(hw_serial_, rts_pin, panel_select_pin);