Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESPHome support #48

Draft
wants to merge 384 commits into
base: library
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
384 commits
Select commit Hold shift + click to select a range
63a7e48
fix action
netmindz Sep 25, 2023
753c664
Add light switch
netmindz Sep 26, 2023
9743ebf
Add light switch
netmindz Sep 26, 2023
1874666
Add light switch
netmindz Sep 26, 2023
4cbb716
Add select for pump1
netmindz Sep 26, 2023
866be6a
Add select for pump1
netmindz Sep 26, 2023
407d539
Add select for pump1
netmindz Sep 26, 2023
72ac6cb
Add select for pump1
netmindz Sep 26, 2023
07db657
Add select for pump1
netmindz Sep 26, 2023
a1e4b12
Add select for pump1
netmindz Sep 26, 2023
43aade1
Add select for pump2
netmindz Sep 26, 2023
302f625
Add select for pump2
netmindz Sep 26, 2023
2c8b874
Add select for pump2
netmindz Sep 26, 2023
6fb18ad
Add select for pump2
netmindz Sep 26, 2023
2d618ad
Add LCD
netmindz Oct 7, 2023
496c8c8
Add explicit dep to CircularBuffer
netmindz Oct 7, 2023
f3c23ff
telnetSend
netmindz Oct 7, 2023
573c154
telnetSend
netmindz Oct 7, 2023
ede1bc1
debug raw
netmindz Oct 7, 2023
1f4f3b3
faster polling
netmindz Oct 7, 2023
c5531d0
Log level tweak
netmindz Oct 7, 2023
8e38ff1
setLight and setTemp
netmindz Oct 7, 2023
5d00a78
setLight and setTemp
netmindz Oct 7, 2023
d3df30a
Fix commenting
netmindz Oct 7, 2023
88426be
Merge branch 'library' into ESPHome
netmindz Oct 7, 2023
800cd0c
Cleanup
netmindz Oct 7, 2023
66d6957
logger tweak
netmindz Oct 7, 2023
16a6968
Fix library dep
netmindz Oct 7, 2023
1a7e736
require pins
netmindz Oct 7, 2023
3cccd2f
require pins
netmindz Oct 7, 2023
7db035c
extra pin config
netmindz Oct 7, 2023
81edcb3
extra pin config
netmindz Oct 7, 2023
c7b1631
extra pin config
netmindz Oct 7, 2023
fa557dd
extra pin config
netmindz Oct 7, 2023
6bb7ccb
extra pin config
netmindz Oct 7, 2023
5c616ba
Setup after WiFi
netmindz Oct 14, 2023
35b9a7d
Merge branch 'library' into ESPHome
netmindz Oct 14, 2023
0ee5ce7
Use libary version with correct send message size
netmindz Oct 14, 2023
c9f3dc9
No actions and tweak logger
netmindz Oct 14, 2023
ab084c7
raw logger
netmindz Oct 14, 2023
0e9f74a
tweak logger
netmindz Oct 14, 2023
e09173c
tweak logger
netmindz Oct 14, 2023
c0cbf08
ESPHome loggers
netmindz Oct 14, 2023
13be7d0
Swap to ESP_LOG
netmindz Oct 14, 2023
1d8efd1
Swap to ESP_LOG
netmindz Oct 14, 2023
ea804bc
library update
netmindz Oct 14, 2023
df61ba6
Set RX and TX if present
netmindz Oct 14, 2023
d8df5d8
Revert update to new logger
netmindz Oct 14, 2023
01c14ff
Revert update to new logger
netmindz Oct 14, 2023
1fd9208
Remove hard coded pins
netmindz Oct 14, 2023
9878cb4
Remove hard coded pins
netmindz Oct 14, 2023
c107f0b
Remove hard coded pins
netmindz Oct 14, 2023
897d75d
Remove hard coded pins
netmindz Oct 14, 2023
74a8b1d
library update
netmindz Oct 15, 2023
45edcf7
log inccludes
netmindz Oct 15, 2023
6f0e1ad
move config
netmindz Oct 15, 2023
35f66be
comment unused imports
netmindz Oct 15, 2023
b58fa84
Move into unified component
netmindz Oct 17, 2023
2e20380
Fix build
netmindz Oct 17, 2023
0550631
Push state
netmindz Oct 17, 2023
18d80e1
Push state
netmindz Oct 17, 2023
99bd64d
Auto load components
netmindz Oct 17, 2023
ff50d51
Auto load components
netmindz Oct 17, 2023
5f6bd74
Update example
netmindz Oct 17, 2023
22bbfc6
Create only state
netmindz Oct 17, 2023
f12f9de
Swap to basic TextSensor
netmindz Oct 18, 2023
be8fe55
Swap to basic TextSensor
netmindz Oct 18, 2023
1aba257
Switch
netmindz Oct 18, 2023
84b7248
Move files to new structure
netmindz Oct 18, 2023
4dadf6f
Sepparate climate from main component
netmindz Oct 18, 2023
a19ea1c
Move files
netmindz Oct 18, 2023
92abf29
Move files
netmindz Oct 18, 2023
9ad5d26
Remove climate from top-level init.py
netmindz Oct 18, 2023
bdcd886
Add init for climate
netmindz Oct 18, 2023
24216e7
Add switch python config
netmindz Oct 19, 2023
57cc2ab
Set parent
netmindz Oct 19, 2023
c83ece4
ns
netmindz Oct 19, 2023
d7935ff
ns
netmindz Oct 19, 2023
15d3352
ns
netmindz Oct 19, 2023
170aeeb
await
netmindz Oct 19, 2023
d077a93
CONF_BALBOA_ID
netmindz Oct 19, 2023
ef48090
fix naming
netmindz Oct 19, 2023
d8f93c7
fix incldue
netmindz Oct 19, 2023
0f3c528
cleanup climate
netmindz Oct 19, 2023
452e75d
cleanup climate
netmindz Oct 19, 2023
27c9c64
cleanup climate
netmindz Oct 19, 2023
a56fb8b
cleanup climate
netmindz Oct 19, 2023
68a9221
cleanup climate
netmindz Oct 19, 2023
ed968d2
cleanup climate
netmindz Oct 19, 2023
d67a981
cleanup climate
netmindz Oct 19, 2023
cb8c595
cleanup climate
netmindz Oct 19, 2023
d4eba89
Heat only for STD mode
netmindz Oct 22, 2023
77feba1
Text sensor update
netmindz Oct 22, 2023
4bc0c7d
Text sensor update
netmindz Oct 22, 2023
813c80c
Text sensor update
netmindz Oct 22, 2023
a230485
Text sensor update
netmindz Oct 22, 2023
dd9a56e
Text sensor update
netmindz Oct 22, 2023
5edff31
text sesnor
netmindz Oct 22, 2023
d8df67f
text sesnor
netmindz Oct 22, 2023
7b1199c
text sesnor
netmindz Oct 22, 2023
cab31c3
text sesnor
netmindz Oct 22, 2023
3df3f75
text sesnor
netmindz Oct 22, 2023
9b535db
text sesnor
netmindz Oct 22, 2023
389b21f
text sesnor
netmindz Oct 22, 2023
f2bfca2
Remove unused reference to UART
netmindz Oct 26, 2023
b7389ae
set_spa
netmindz Oct 27, 2023
0ec182e
set_spa
netmindz Oct 27, 2023
d25eccf
set_spa
netmindz Oct 27, 2023
21eb63e
set_spa
netmindz Oct 27, 2023
f163f8b
set_spa
netmindz Oct 27, 2023
c369c91
set_spa
netmindz Oct 27, 2023
89575a1
set_spa
netmindz Oct 27, 2023
37d4c93
set_spa
netmindz Oct 27, 2023
9d88d59
set_spa
netmindz Oct 27, 2023
bc8afd0
set_spa
netmindz Oct 27, 2023
86a9b84
set_spa
netmindz Oct 27, 2023
f739513
set_spa
netmindz Oct 27, 2023
45a22d2
set_spa
netmindz Oct 27, 2023
a4455ff
define tubUART
netmindz Oct 27, 2023
87b0118
define tubUART
netmindz Oct 27, 2023
eb5071e
define tubUART
netmindz Oct 27, 2023
b1f0567
twek switch python
netmindz Oct 27, 2023
9c0e892
twek switch python
netmindz Oct 27, 2023
1dfdba8
twek switch python
netmindz Oct 27, 2023
7636667
twek switch python
netmindz Oct 27, 2023
4d31798
remove namespace
netmindz Oct 27, 2023
a7afec9
set spa
netmindz Oct 27, 2023
59353a2
set spa
netmindz Oct 27, 2023
1a8a3c4
attachPanelInterrupt
netmindz Oct 27, 2023
e3f4d76
attachPanelInterrupt
netmindz Oct 27, 2023
8ea825d
CommandQueue sensor
netmindz Oct 27, 2023
017d0ba
CommandQueue sensor
netmindz Oct 27, 2023
eac0f66
CommandQueue sensor
netmindz Oct 27, 2023
f70950f
CommandQueue sensor
netmindz Oct 27, 2023
dd57c2a
CommandQueue sensor
netmindz Oct 27, 2023
6ea2ee4
CommandQueue sensor
netmindz Oct 27, 2023
0b4eb7a
CommandQueue sensor
netmindz Oct 27, 2023
b83768a
State sensor
netmindz Oct 27, 2023
7351257
Remove tubUART define
netmindz Oct 27, 2023
672cd6d
fix setter name
netmindz Oct 27, 2023
1252b6c
Add sensors
netmindz Oct 27, 2023
265be1f
Add sensors
netmindz Oct 27, 2023
a9da203
Add sensors
netmindz Oct 27, 2023
b806ab0
Update example config
netmindz Oct 27, 2023
b5562f7
entity category
netmindz Oct 28, 2023
864bfc1
Add unique_id
netmindz Oct 28, 2023
34afc36
Convert from polling to regular component
netmindz Oct 28, 2023
466d4a7
Cleanup
netmindz Oct 28, 2023
2f2c2a3
Selective update
netmindz Oct 28, 2023
281dfbf
Selective update
netmindz Oct 28, 2023
24914a0
Selective update
netmindz Oct 28, 2023
4239004
Selective update
netmindz Oct 28, 2023
7738ca9
Selective update
netmindz Oct 28, 2023
48be556
Selective update
netmindz Oct 28, 2023
cf307e0
Selective update
netmindz Oct 28, 2023
0a9308b
Selective update
netmindz Oct 28, 2023
3640602
Selective update
netmindz Oct 28, 2023
5ed4f1b
Selective update
netmindz Oct 28, 2023
54cfead
Selective update
netmindz Oct 28, 2023
0ec727f
switch loggers
netmindz Oct 28, 2023
efa4498
switch loggers
netmindz Oct 28, 2023
4c1ca7c
switch loggers
netmindz Oct 28, 2023
807941c
logger tweak
netmindz Oct 28, 2023
ba924a3
light state
netmindz Oct 28, 2023
69e67fb
light state
netmindz Oct 28, 2023
0f00f7d
add logger
netmindz Oct 28, 2023
b289feb
cleanup
netmindz Nov 2, 2023
5614175
cleanup
netmindz Nov 2, 2023
da38eda
Register LCD and raw
netmindz Nov 2, 2023
1b4262e
CommandQueue = polling
netmindz Nov 2, 2023
4aa0337
schema tweaks
netmindz Nov 2, 2023
9fecbf2
Update select
netmindz Nov 2, 2023
d74a9f4
async
netmindz Nov 2, 2023
eb9839c
Update select
netmindz Nov 2, 2023
d87afd5
Update component.yaml
netmindz Nov 2, 2023
ebf4b2c
try raw only
netmindz Nov 2, 2023
eee9e93
Polling text_sesnors
netmindz Nov 2, 2023
24906bb
starting value and remove unqiue_id
netmindz Nov 2, 2023
a3877e6
raw is diag
netmindz Nov 2, 2023
42c71c8
select
netmindz Nov 2, 2023
121d70f
select
netmindz Nov 2, 2023
0c64f2b
select
netmindz Nov 2, 2023
77818d3
select
netmindz Nov 2, 2023
f1cd725
select
netmindz Nov 2, 2023
4a09a6f
select
netmindz Nov 2, 2023
6658b55
select
netmindz Nov 2, 2023
6783642
select
netmindz Nov 2, 2023
8034395
select
netmindz Nov 2, 2023
5ff4f3b
select
netmindz Nov 2, 2023
7fb2ce8
select
netmindz Nov 2, 2023
ac514b5
set spa
netmindz Nov 2, 2023
d0e5e80
buttons
netmindz Nov 2, 2023
6bb1f85
buttons
netmindz Nov 2, 2023
1af441e
buttons
netmindz Nov 2, 2023
35b934b
buttons
netmindz Nov 2, 2023
5fe2da7
buttons
netmindz Nov 2, 2023
0be5eaa
button - set parent
netmindz Nov 2, 2023
77b3eb6
button - set parent
netmindz Nov 2, 2023
aabb6ad
buttons - send command
netmindz Nov 2, 2023
de26ad6
buttons - send command
netmindz Nov 2, 2023
115c152
buttons - send command
netmindz Nov 2, 2023
1ebb61c
buttons - send command
netmindz Nov 2, 2023
ce67b9e
buttons - send command
netmindz Nov 2, 2023
a0dcac1
Update example
netmindz Nov 2, 2023
ddb3c29
prevent log crash
netmindz Nov 2, 2023
0860b51
logger
netmindz Nov 2, 2023
5c2c65a
logger
netmindz Nov 2, 2023
c7f3e53
logger
netmindz Nov 2, 2023
acd95ef
No wait
netmindz Nov 3, 2023
03ba436
Add delay_time
netmindz Nov 3, 2023
9c5cdb6
Delay setting delay
netmindz Nov 3, 2023
3984285
Set temp range
netmindz Nov 4, 2023
db1ebbc
Set temp range
netmindz Nov 4, 2023
9d41c45
No actions
netmindz Nov 4, 2023
3da62bb
update temp
netmindz Nov 4, 2023
d0c3a08
update temp
netmindz Nov 4, 2023
f6e3cf6
Current temp and presets
netmindz Nov 4, 2023
ab8efc8
Current temp and presets
netmindz Nov 4, 2023
0cd52c3
Hold control while trying to send
netmindz Nov 4, 2023
225cc6a
Hold control while trying to send
netmindz Nov 4, 2023
1436325
Hold control while trying to send
netmindz Nov 4, 2023
e2a93cf
Try invert
netmindz Nov 5, 2023
c398943
logger tweak
netmindz Nov 5, 2023
4434929
logger tweak
netmindz Nov 6, 2023
3c71b0a
Merge branch 'library' into ESPHome
netmindz Nov 10, 2023
048aafa
Cleanup merge
netmindz Nov 10, 2023
53bba06
Revert "Try invert"
netmindz Nov 11, 2023
b793611
Log level tweak
netmindz Nov 11, 2023
fadf1a6
Log tweak
netmindz Nov 11, 2023
639d8ea
Disable flow control
netmindz Nov 11, 2023
b2f2340
Merge branch 'library' into ESPHome
netmindz Nov 12, 2023
de6136d
Merge branch 'library' into ESPHome
netmindz Dec 1, 2023
f5410b1
Remove logger for raw change
netmindz Dec 1, 2023
bf5f862
Fast loop when sending
netmindz Dec 1, 2023
1e2dc29
cleanup
netmindz Dec 1, 2023
66056ca
WARNING - new default pins
netmindz Dec 1, 2023
67c7be2
Cleanup
netmindz Dec 1, 2023
8504795
updated library - lastCmdTime update
netmindz Sep 17, 2024
d6fe4d5
Update HARDWARE_UART_TO_SERIAL
netmindz Sep 17, 2024
cd62281
Add PLATFORM_ESP32
netmindz Sep 17, 2024
a4325ae
Update __init__.py
netmindz Sep 17, 2024
0eb4971
Update __init__.py
netmindz Sep 17, 2024
ce3f956
Update __init__.py
netmindz Sep 17, 2024
a457775
Invert
netmindz Sep 17, 2024
9f5b2f0
UART_MODE_RS485_HALF_DUPLEX
netmindz Sep 17, 2024
3615e97
UART_MODE_RS485_HALF_DUPLEX
netmindz Sep 17, 2024
ca86dc3
Update ESPBalboaGL.cpp
netmindz Sep 17, 2024
bc5af6e
SerialMode.UART_MODE_RS485_HALF_DUPLEX
netmindz Sep 17, 2024
e5702be
Update ESPBalboaGL.cpp
netmindz Sep 17, 2024
050e3b9
Update ESPBalboaGL.cpp
netmindz Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
ota:
password: "e82fe9bada398051d779151a591a1e2e"
# Needed to get round interrupt issue
on_begin:
then:
- lambda: balboagl->pause();

external_components:
- source:
type: git
url: https://github.com/netmindz/balboa_GL_ML_spa_control.git
ref: ESPHome
refresh: 0s


BalboaGL:
# Pin values for T-RSC3
hardware_uart: UART1
rx_pin: 3
tx_pin: 10
enable_pin: 5
panel_select_pin: 6

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


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"
177 changes: 177 additions & 0 deletions components/BalboaGL/ESPBalboaGL.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
#include <string>
#include "ESPBalboaGL.h"
using namespace esphome;

void telnetSend(String msg) {
ESP_LOGI(TAG, msg.c_str());
}

void log(const char *format, ...) {
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<char *>(temp);
ESP_LOGI(TAG, str.c_str());
if(temp != loc_buf){
free(temp);
}

}
/**
* 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}
{

}

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::loop() {
// ESP_LOGV(TAG, "Loop called.");
int sanity = 0;
do {
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));
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);
}

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);
// 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);
this->spa->attachPanelInterrupt();
if(delay_time > -1) this->spa->set_delay_time(delay_time);

// 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();
// }

ESP_LOGCONFIG(TAG, "End of seutp");
this->dump_config();
}

void BalboaGL::pause() {
ESP_LOGI(TAG, "pause");
this->spa->detachPanelInterrupt();
}

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;
}

void BalboaGL::set_delay_time(int delay) {
this->delay_time;
}
96 changes: 96 additions & 0 deletions components/BalboaGL/ESPBalboaGL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#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/core/log.h"
#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
// 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 Component {
public:
BalboaGL(
HardwareSerial* hw_serial
);

// print the current configuration
void dump_config() override;

// Set up the component, initializing the balboaGL object.
void setup() override;

// This is called every poll_interval.
void loop() override;

// Debugging function to print the object's state.
// void dump_state();

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);

void set_delay_time(int delay);

float get_setup_priority() const override { return esphome::setup_priority::HARDWARE; }

void pause();

balboaGL* get_spa() {
return spa;
}

protected:

//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_();

int rx_pin = -1;
int tx_pin = -1;
int rts_pin = -1;
int panel_select_pin = -1;

HighFrequencyLoopRequester high_freq_;

int delay_time = -1;

private:
// Retrieve the HardwareSerial pointer from friend and subclasses.
HardwareSerial *hw_serial_;

balboaGL* spa;
String lastRaw = "0";
};
#endif
Loading
Loading