esphome 2024.6.6__py3-none-any.whl → 2024.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/components/aht10/aht10.cpp +4 -2
- esphome/components/climate/climate.cpp +10 -6
- esphome/components/climate/climate_traits.h +3 -3
- esphome/components/cover/cover.h +2 -2
- esphome/components/esp32_camera/__init__.py +6 -3
- esphome/components/esp32_can/canbus.py +3 -0
- esphome/components/ethernet/ethernet_component.cpp +8 -3
- esphome/components/font/__init__.py +2 -28
- esphome/components/gree/climate.py +1 -0
- esphome/components/gree/gree.cpp +11 -3
- esphome/components/gree/gree.h +5 -1
- esphome/components/haier/binary_sensor/__init__.py +4 -4
- esphome/components/haier/button/__init__.py +1 -1
- esphome/components/haier/climate.py +43 -9
- esphome/components/haier/haier_base.cpp +4 -0
- esphome/components/haier/haier_base.h +11 -1
- esphome/components/haier/hon_climate.cpp +109 -55
- esphome/components/haier/hon_climate.h +7 -1
- esphome/components/haier/hon_packet.h +5 -0
- esphome/components/haier/sensor/__init__.py +5 -5
- esphome/components/haier/smartair2_climate.cpp +1 -0
- esphome/components/haier/text_sensor/__init__.py +4 -4
- esphome/components/heatpumpir/climate.py +12 -5
- esphome/components/heatpumpir/heatpumpir.cpp +11 -0
- esphome/components/heatpumpir/heatpumpir.h +11 -0
- esphome/components/http_request/http_request_arduino.cpp +7 -2
- esphome/components/http_request/update/http_request_update.cpp +6 -7
- esphome/components/http_request/update/http_request_update.h +0 -3
- esphome/components/i2s_audio/__init__.py +10 -0
- esphome/components/i2s_audio/microphone/__init__.py +7 -0
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +2 -3
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +3 -0
- esphome/components/image/__init__.py +2 -29
- esphome/components/improv_serial/improv_serial_component.cpp +9 -8
- esphome/components/ltr390/ltr390.cpp +44 -29
- esphome/components/ltr390/ltr390.h +9 -5
- esphome/components/ltr390/sensor.py +35 -5
- esphome/components/mdns/__init__.py +3 -3
- esphome/components/mdns/mdns_component.cpp +3 -1
- esphome/components/mdns/mdns_component.h +3 -1
- esphome/components/mdns/mdns_esp32.cpp +2 -1
- esphome/components/mdns/mdns_esp8266.cpp +2 -1
- esphome/components/mdns/mdns_host.cpp +2 -1
- esphome/components/mdns/mdns_libretiny.cpp +2 -1
- esphome/components/mdns/mdns_rp2040.cpp +2 -1
- esphome/components/micro_wake_word/__init__.py +205 -56
- esphome/components/micro_wake_word/micro_wake_word.cpp +225 -275
- esphome/components/micro_wake_word/micro_wake_word.h +77 -107
- esphome/components/micro_wake_word/preprocessor_settings.h +20 -0
- esphome/components/micro_wake_word/streaming_model.cpp +189 -0
- esphome/components/micro_wake_word/streaming_model.h +84 -0
- esphome/components/mitsubishi/mitsubishi.cpp +1 -0
- esphome/components/modbus_controller/text_sensor/__init__.py +2 -1
- esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +4 -1
- esphome/components/modbus_controller/text_sensor/modbus_textsensor.h +1 -1
- esphome/components/number/__init__.py +2 -0
- esphome/components/ota/ota_backend_arduino_esp32.cpp +22 -7
- esphome/components/ota/ota_backend_arduino_esp8266.cpp +23 -8
- esphome/components/ota/ota_backend_arduino_libretiny.cpp +22 -7
- esphome/components/ota/ota_backend_arduino_rp2040.cpp +22 -7
- esphome/components/pmsa003i/pmsa003i.cpp +9 -0
- esphome/components/qspi_amoled/display.py +16 -4
- esphome/components/qspi_amoled/qspi_amoled.cpp +16 -0
- esphome/components/qspi_amoled/qspi_amoled.h +0 -3
- esphome/components/remote_base/dooya_protocol.cpp +4 -4
- esphome/components/remote_base/rc_switch_protocol.cpp +1 -1
- esphome/components/restart/button/__init__.py +2 -0
- esphome/components/script/__init__.py +1 -1
- esphome/components/sensor/__init__.py +2 -0
- esphome/components/tuya/tuya.cpp +8 -2
- esphome/components/tuya/tuya.h +3 -1
- esphome/components/uart/__init__.py +72 -9
- esphome/components/uart/uart_component_esp32_arduino.cpp +18 -4
- esphome/components/uart/uart_component_esp_idf.cpp +22 -2
- esphome/components/uart/uart_component_host.cpp +295 -0
- esphome/components/uart/uart_component_host.h +38 -0
- esphome/components/uptime/sensor.py +44 -11
- esphome/components/uptime/{uptime_sensor.cpp → uptime_seconds_sensor.cpp} +11 -7
- esphome/components/uptime/{uptime_sensor.h → uptime_seconds_sensor.h} +2 -2
- esphome/components/uptime/uptime_timestamp_sensor.cpp +39 -0
- esphome/components/uptime/uptime_timestamp_sensor.h +30 -0
- esphome/components/veml7700/veml7700.cpp +1 -1
- esphome/components/veml7700/veml7700.h +5 -5
- esphome/components/voice_assistant/voice_assistant.cpp +4 -2
- esphome/components/web_server/server_index_v2.h +42 -41
- esphome/components/web_server/server_index_v3.h +368 -367
- esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
- esphome/components/wifi/wifi_component_pico_w.cpp +18 -2
- esphome/components/wireguard/__init__.py +1 -1
- esphome/components/x9c/output.py +7 -1
- esphome/const.py +2 -1
- esphome/core/defines.h +1 -0
- esphome/core/helpers.cpp +2 -2
- esphome/core/helpers.h +1 -1
- esphome/external_files.py +26 -0
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/METADATA +1 -1
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/RECORD +101 -95
- esphome/components/micro_wake_word/audio_preprocessor_int8_model_data.h +0 -493
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/LICENSE +0 -0
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/WHEEL +0 -0
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/top_level.txt +0 -0
@@ -96,10 +96,24 @@ void ESP32ArduinoUARTComponent::setup() {
|
|
96
96
|
next_uart_num++;
|
97
97
|
} else {
|
98
98
|
#ifdef USE_LOGGER
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
if (logger::global_logger->
|
99
|
+
bool logger_uses_hardware_uart = true;
|
100
|
+
|
101
|
+
#ifdef USE_LOGGER_USB_CDC
|
102
|
+
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_CDC) {
|
103
|
+
// this is not a hardware UART, ignore it
|
104
|
+
logger_uses_hardware_uart = false;
|
105
|
+
}
|
106
|
+
#endif // USE_LOGGER_USB_CDC
|
107
|
+
|
108
|
+
#ifdef USE_LOGGER_USB_SERIAL_JTAG
|
109
|
+
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_SERIAL_JTAG) {
|
110
|
+
// this is not a hardware UART, ignore it
|
111
|
+
logger_uses_hardware_uart = false;
|
112
|
+
}
|
113
|
+
#endif // USE_LOGGER_USB_SERIAL_JTAG
|
114
|
+
|
115
|
+
if (logger_uses_hardware_uart && logger::global_logger->get_baud_rate() > 0 &&
|
116
|
+
logger::global_logger->get_uart() == next_uart_num) {
|
103
117
|
next_uart_num++;
|
104
118
|
}
|
105
119
|
#endif // USE_LOGGER
|
@@ -60,10 +60,30 @@ uart_config_t IDFUARTComponent::get_config_() {
|
|
60
60
|
|
61
61
|
void IDFUARTComponent::setup() {
|
62
62
|
static uint8_t next_uart_num = 0;
|
63
|
+
|
63
64
|
#ifdef USE_LOGGER
|
64
|
-
|
65
|
+
bool logger_uses_hardware_uart = true;
|
66
|
+
|
67
|
+
#ifdef USE_LOGGER_USB_CDC
|
68
|
+
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_CDC) {
|
69
|
+
// this is not a hardware UART, ignore it
|
70
|
+
logger_uses_hardware_uart = false;
|
71
|
+
}
|
72
|
+
#endif // USE_LOGGER_USB_CDC
|
73
|
+
|
74
|
+
#ifdef USE_LOGGER_USB_SERIAL_JTAG
|
75
|
+
if (logger::global_logger->get_uart() == logger::UART_SELECTION_USB_SERIAL_JTAG) {
|
76
|
+
// this is not a hardware UART, ignore it
|
77
|
+
logger_uses_hardware_uart = false;
|
78
|
+
}
|
79
|
+
#endif // USE_LOGGER_USB_SERIAL_JTAG
|
80
|
+
|
81
|
+
if (logger_uses_hardware_uart && logger::global_logger->get_baud_rate() > 0 &&
|
82
|
+
logger::global_logger->get_uart_num() == next_uart_num) {
|
65
83
|
next_uart_num++;
|
66
|
-
|
84
|
+
}
|
85
|
+
#endif // USE_LOGGER
|
86
|
+
|
67
87
|
if (next_uart_num >= UART_NUM_MAX) {
|
68
88
|
ESP_LOGW(TAG, "Maximum number of UART components created already.");
|
69
89
|
this->mark_failed();
|
@@ -0,0 +1,295 @@
|
|
1
|
+
#ifdef USE_HOST
|
2
|
+
#include "uart_component_host.h"
|
3
|
+
#include "esphome/core/application.h"
|
4
|
+
#include "esphome/core/defines.h"
|
5
|
+
#include "esphome/core/helpers.h"
|
6
|
+
#include "esphome/core/log.h"
|
7
|
+
|
8
|
+
#ifndef __linux__
|
9
|
+
#error This HostUartComponent implementation is only for Linux
|
10
|
+
#endif
|
11
|
+
|
12
|
+
#include <stdio.h>
|
13
|
+
#include <string.h>
|
14
|
+
#include <unistd.h>
|
15
|
+
#include <fcntl.h>
|
16
|
+
#include <errno.h>
|
17
|
+
#include <termios.h>
|
18
|
+
#include <sys/ioctl.h>
|
19
|
+
|
20
|
+
#ifdef USE_LOGGER
|
21
|
+
#include "esphome/components/logger/logger.h"
|
22
|
+
#endif
|
23
|
+
|
24
|
+
namespace {
|
25
|
+
|
26
|
+
speed_t get_baud(int baud) {
|
27
|
+
switch (baud) {
|
28
|
+
case 50:
|
29
|
+
return B50;
|
30
|
+
case 75:
|
31
|
+
return B75;
|
32
|
+
case 110:
|
33
|
+
return B110;
|
34
|
+
case 134:
|
35
|
+
return B134;
|
36
|
+
case 150:
|
37
|
+
return B150;
|
38
|
+
case 200:
|
39
|
+
return B200;
|
40
|
+
case 300:
|
41
|
+
return B300;
|
42
|
+
case 600:
|
43
|
+
return B600;
|
44
|
+
case 1200:
|
45
|
+
return B1200;
|
46
|
+
case 1800:
|
47
|
+
return B1800;
|
48
|
+
case 2400:
|
49
|
+
return B2400;
|
50
|
+
case 4800:
|
51
|
+
return B4800;
|
52
|
+
case 9600:
|
53
|
+
return B9600;
|
54
|
+
case 19200:
|
55
|
+
return B19200;
|
56
|
+
case 38400:
|
57
|
+
return B38400;
|
58
|
+
case 57600:
|
59
|
+
return B57600;
|
60
|
+
case 115200:
|
61
|
+
return B115200;
|
62
|
+
case 230400:
|
63
|
+
return B230400;
|
64
|
+
case 460800:
|
65
|
+
return B460800;
|
66
|
+
case 500000:
|
67
|
+
return B500000;
|
68
|
+
case 576000:
|
69
|
+
return B576000;
|
70
|
+
case 921600:
|
71
|
+
return B921600;
|
72
|
+
case 1000000:
|
73
|
+
return B1000000;
|
74
|
+
case 1152000:
|
75
|
+
return B1152000;
|
76
|
+
case 1500000:
|
77
|
+
return B1500000;
|
78
|
+
case 2000000:
|
79
|
+
return B2000000;
|
80
|
+
case 2500000:
|
81
|
+
return B2500000;
|
82
|
+
case 3000000:
|
83
|
+
return B3000000;
|
84
|
+
case 3500000:
|
85
|
+
return B3500000;
|
86
|
+
case 4000000:
|
87
|
+
return B4000000;
|
88
|
+
default:
|
89
|
+
return B0;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
} // namespace
|
94
|
+
|
95
|
+
namespace esphome {
|
96
|
+
namespace uart {
|
97
|
+
|
98
|
+
static const char *const TAG = "uart.host";
|
99
|
+
|
100
|
+
HostUartComponent::~HostUartComponent() {
|
101
|
+
if (this->file_descriptor_ != -1) {
|
102
|
+
close(this->file_descriptor_);
|
103
|
+
this->file_descriptor_ = -1;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
void HostUartComponent::setup() {
|
108
|
+
ESP_LOGCONFIG(TAG, "Opening UART port...");
|
109
|
+
speed_t baud = get_baud(this->baud_rate_);
|
110
|
+
if (baud == B0) {
|
111
|
+
ESP_LOGE(TAG, "Unsupported baud rate: %d", this->baud_rate_);
|
112
|
+
this->mark_failed();
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
this->file_descriptor_ = ::open(this->port_name_.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
|
116
|
+
if (this->file_descriptor_ == -1) {
|
117
|
+
this->update_error_(strerror(errno));
|
118
|
+
this->mark_failed();
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
fcntl(this->file_descriptor_, F_SETFL, 0);
|
122
|
+
struct termios options;
|
123
|
+
tcgetattr(this->file_descriptor_, &options);
|
124
|
+
options.c_cflag &= ~CRTSCTS;
|
125
|
+
options.c_cflag |= CREAD | CLOCAL;
|
126
|
+
options.c_lflag &= ~ICANON;
|
127
|
+
options.c_lflag &= ~ECHO;
|
128
|
+
options.c_lflag &= ~ECHOE;
|
129
|
+
options.c_lflag &= ~ECHONL;
|
130
|
+
options.c_lflag &= ~ISIG;
|
131
|
+
options.c_iflag &= ~(IXON | IXOFF | IXANY);
|
132
|
+
options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL);
|
133
|
+
options.c_oflag &= ~OPOST;
|
134
|
+
options.c_oflag &= ~ONLCR;
|
135
|
+
// Set data bits
|
136
|
+
options.c_cflag &= ~CSIZE; // Mask the character size bits
|
137
|
+
switch (this->data_bits_) {
|
138
|
+
case 5:
|
139
|
+
options.c_cflag |= CS5;
|
140
|
+
break;
|
141
|
+
case 6:
|
142
|
+
options.c_cflag |= CS6;
|
143
|
+
break;
|
144
|
+
case 7:
|
145
|
+
options.c_cflag |= CS7;
|
146
|
+
break;
|
147
|
+
case 8:
|
148
|
+
default:
|
149
|
+
options.c_cflag |= CS8;
|
150
|
+
break;
|
151
|
+
}
|
152
|
+
// Set parity
|
153
|
+
switch (this->parity_) {
|
154
|
+
case UART_CONFIG_PARITY_NONE:
|
155
|
+
options.c_cflag &= ~PARENB;
|
156
|
+
break;
|
157
|
+
case UART_CONFIG_PARITY_EVEN:
|
158
|
+
options.c_cflag |= PARENB;
|
159
|
+
options.c_cflag &= ~PARODD;
|
160
|
+
break;
|
161
|
+
case UART_CONFIG_PARITY_ODD:
|
162
|
+
options.c_cflag |= PARENB;
|
163
|
+
options.c_cflag |= PARODD;
|
164
|
+
break;
|
165
|
+
};
|
166
|
+
// Set stop bits
|
167
|
+
if (this->stop_bits_ == 2) {
|
168
|
+
options.c_cflag |= CSTOPB;
|
169
|
+
} else {
|
170
|
+
options.c_cflag &= ~CSTOPB;
|
171
|
+
}
|
172
|
+
cfsetispeed(&options, baud);
|
173
|
+
cfsetospeed(&options, baud);
|
174
|
+
tcsetattr(this->file_descriptor_, TCSANOW, &options);
|
175
|
+
}
|
176
|
+
|
177
|
+
void HostUartComponent::dump_config() {
|
178
|
+
ESP_LOGCONFIG(TAG, "UART:");
|
179
|
+
ESP_LOGCONFIG(TAG, " Port: %s", this->port_name_.c_str());
|
180
|
+
if (this->file_descriptor_ == -1) {
|
181
|
+
ESP_LOGCONFIG(TAG, " Port status: Not opened");
|
182
|
+
if (!this->first_error_.empty()) {
|
183
|
+
ESP_LOGCONFIG(TAG, " Error: %s", this->first_error_.c_str());
|
184
|
+
}
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
ESP_LOGCONFIG(TAG, " Port status: opened");
|
188
|
+
ESP_LOGCONFIG(TAG, " Baud Rate: %d", this->baud_rate_);
|
189
|
+
ESP_LOGCONFIG(TAG, " Data Bits: %d", this->data_bits_);
|
190
|
+
ESP_LOGCONFIG(TAG, " Parity: %s",
|
191
|
+
this->parity_ == UART_CONFIG_PARITY_NONE ? "None"
|
192
|
+
: this->parity_ == UART_CONFIG_PARITY_EVEN ? "Even"
|
193
|
+
: "Odd");
|
194
|
+
ESP_LOGCONFIG(TAG, " Stop Bits: %d", this->stop_bits_);
|
195
|
+
this->check_logger_conflict();
|
196
|
+
}
|
197
|
+
|
198
|
+
void HostUartComponent::write_array(const uint8_t *data, size_t len) {
|
199
|
+
if (this->file_descriptor_ == -1) {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
size_t written = ::write(this->file_descriptor_, data, len);
|
203
|
+
if (written != len) {
|
204
|
+
this->update_error_(strerror(errno));
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
#ifdef USE_UART_DEBUGGER
|
208
|
+
for (size_t i = 0; i < len; i++) {
|
209
|
+
this->debug_callback_.call(UART_DIRECTION_TX, data[i]);
|
210
|
+
}
|
211
|
+
#endif
|
212
|
+
return;
|
213
|
+
}
|
214
|
+
|
215
|
+
bool HostUartComponent::peek_byte(uint8_t *data) {
|
216
|
+
if (this->file_descriptor_ == -1) {
|
217
|
+
return false;
|
218
|
+
}
|
219
|
+
if (!this->has_peek_) {
|
220
|
+
if (!this->check_read_timeout_()) {
|
221
|
+
return false;
|
222
|
+
}
|
223
|
+
if (::read(this->file_descriptor_, &this->peek_byte_, 1) != 1) {
|
224
|
+
this->update_error_(strerror(errno));
|
225
|
+
return false;
|
226
|
+
}
|
227
|
+
this->has_peek_ = true;
|
228
|
+
}
|
229
|
+
*data = this->peek_byte_;
|
230
|
+
return true;
|
231
|
+
}
|
232
|
+
|
233
|
+
bool HostUartComponent::read_array(uint8_t *data, size_t len) {
|
234
|
+
if ((this->file_descriptor_ == -1) || (len == 0)) {
|
235
|
+
return false;
|
236
|
+
}
|
237
|
+
if (!this->check_read_timeout_(len))
|
238
|
+
return false;
|
239
|
+
uint8_t *data_ptr = data;
|
240
|
+
size_t length_to_read = len;
|
241
|
+
if (this->has_peek_) {
|
242
|
+
length_to_read--;
|
243
|
+
*data_ptr = this->peek_byte_;
|
244
|
+
data_ptr++;
|
245
|
+
this->has_peek_ = false;
|
246
|
+
}
|
247
|
+
if (length_to_read > 0) {
|
248
|
+
int sz = ::read(this->file_descriptor_, data_ptr, length_to_read);
|
249
|
+
if (sz == -1) {
|
250
|
+
this->update_error_(strerror(errno));
|
251
|
+
return false;
|
252
|
+
}
|
253
|
+
}
|
254
|
+
#ifdef USE_UART_DEBUGGER
|
255
|
+
for (size_t i = 0; i < len; i++) {
|
256
|
+
this->debug_callback_.call(UART_DIRECTION_RX, data[i]);
|
257
|
+
}
|
258
|
+
#endif
|
259
|
+
return true;
|
260
|
+
}
|
261
|
+
|
262
|
+
int HostUartComponent::available() {
|
263
|
+
if (this->file_descriptor_ == -1) {
|
264
|
+
return 0;
|
265
|
+
}
|
266
|
+
int available;
|
267
|
+
int res = ioctl(this->file_descriptor_, FIONREAD, &available);
|
268
|
+
if (res == -1) {
|
269
|
+
this->update_error_(strerror(errno));
|
270
|
+
return 0;
|
271
|
+
}
|
272
|
+
if (this->has_peek_)
|
273
|
+
available++;
|
274
|
+
return available;
|
275
|
+
};
|
276
|
+
|
277
|
+
void HostUartComponent::flush() {
|
278
|
+
if (this->file_descriptor_ == -1) {
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
tcflush(this->file_descriptor_, TCIOFLUSH);
|
282
|
+
ESP_LOGV(TAG, " Flushing...");
|
283
|
+
}
|
284
|
+
|
285
|
+
void HostUartComponent::update_error_(const std::string &error) {
|
286
|
+
if (this->first_error_.empty()) {
|
287
|
+
this->first_error_ = error;
|
288
|
+
}
|
289
|
+
ESP_LOGE(TAG, "Port error: %s", error.c_str());
|
290
|
+
}
|
291
|
+
|
292
|
+
} // namespace uart
|
293
|
+
} // namespace esphome
|
294
|
+
|
295
|
+
#endif // USE_HOST
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#ifdef USE_HOST
|
4
|
+
|
5
|
+
#include "esphome/core/component.h"
|
6
|
+
#include "esphome/core/log.h"
|
7
|
+
#include "uart_component.h"
|
8
|
+
|
9
|
+
namespace esphome {
|
10
|
+
namespace uart {
|
11
|
+
|
12
|
+
class HostUartComponent : public UARTComponent, public Component {
|
13
|
+
public:
|
14
|
+
virtual ~HostUartComponent();
|
15
|
+
void setup() override;
|
16
|
+
void dump_config() override;
|
17
|
+
float get_setup_priority() const override { return setup_priority::BUS; }
|
18
|
+
void write_array(const uint8_t *data, size_t len) override;
|
19
|
+
bool peek_byte(uint8_t *data) override;
|
20
|
+
bool read_array(uint8_t *data, size_t len) override;
|
21
|
+
int available() override;
|
22
|
+
void flush() override;
|
23
|
+
void set_name(std::string port_name) { port_name_ = port_name; };
|
24
|
+
|
25
|
+
protected:
|
26
|
+
void update_error_(const std::string &error);
|
27
|
+
void check_logger_conflict() override {}
|
28
|
+
std::string port_name_;
|
29
|
+
std::string first_error_{""};
|
30
|
+
int file_descriptor_ = -1;
|
31
|
+
bool has_peek_{false};
|
32
|
+
uint8_t peek_byte_;
|
33
|
+
};
|
34
|
+
|
35
|
+
} // namespace uart
|
36
|
+
} // namespace esphome
|
37
|
+
|
38
|
+
#endif // USE_HOST
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import esphome.codegen as cg
|
2
2
|
import esphome.config_validation as cv
|
3
|
-
from esphome.components import sensor
|
3
|
+
from esphome.components import sensor, time
|
4
4
|
from esphome.const import (
|
5
|
+
CONF_TIME_ID,
|
6
|
+
DEVICE_CLASS_TIMESTAMP,
|
5
7
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
6
8
|
STATE_CLASS_TOTAL_INCREASING,
|
7
9
|
UNIT_SECOND,
|
@@ -10,19 +12,50 @@ from esphome.const import (
|
|
10
12
|
)
|
11
13
|
|
12
14
|
uptime_ns = cg.esphome_ns.namespace("uptime")
|
13
|
-
|
15
|
+
UptimeSecondsSensor = uptime_ns.class_(
|
16
|
+
"UptimeSecondsSensor", sensor.Sensor, cg.PollingComponent
|
17
|
+
)
|
18
|
+
UptimeTimestampSensor = uptime_ns.class_(
|
19
|
+
"UptimeTimestampSensor", sensor.Sensor, cg.Component
|
20
|
+
)
|
14
21
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
|
23
|
+
CONFIG_SCHEMA = cv.typed_schema(
|
24
|
+
{
|
25
|
+
"seconds": sensor.sensor_schema(
|
26
|
+
UptimeSecondsSensor,
|
27
|
+
unit_of_measurement=UNIT_SECOND,
|
28
|
+
icon=ICON_TIMER,
|
29
|
+
accuracy_decimals=0,
|
30
|
+
state_class=STATE_CLASS_TOTAL_INCREASING,
|
31
|
+
device_class=DEVICE_CLASS_DURATION,
|
32
|
+
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
33
|
+
).extend(cv.polling_component_schema("60s")),
|
34
|
+
"timestamp": sensor.sensor_schema(
|
35
|
+
UptimeTimestampSensor,
|
36
|
+
icon=ICON_TIMER,
|
37
|
+
accuracy_decimals=0,
|
38
|
+
device_class=DEVICE_CLASS_TIMESTAMP,
|
39
|
+
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
40
|
+
)
|
41
|
+
.extend(
|
42
|
+
cv.Schema(
|
43
|
+
{
|
44
|
+
cv.GenerateID(CONF_TIME_ID): cv.All(
|
45
|
+
cv.requires_component("time"), cv.use_id(time.RealTimeClock)
|
46
|
+
),
|
47
|
+
}
|
48
|
+
)
|
49
|
+
)
|
50
|
+
.extend(cv.COMPONENT_SCHEMA),
|
51
|
+
},
|
52
|
+
default_type="seconds",
|
53
|
+
)
|
24
54
|
|
25
55
|
|
26
56
|
async def to_code(config):
|
27
57
|
var = await sensor.new_sensor(config)
|
28
58
|
await cg.register_component(var, config)
|
59
|
+
if time_id_config := config.get(CONF_TIME_ID):
|
60
|
+
time_id = await cg.get_variable(time_id_config)
|
61
|
+
cg.add(var.set_time(time_id))
|
@@ -1,14 +1,15 @@
|
|
1
|
-
#include "
|
2
|
-
|
3
|
-
#include "esphome/core/helpers.h"
|
1
|
+
#include "uptime_seconds_sensor.h"
|
2
|
+
|
4
3
|
#include "esphome/core/hal.h"
|
4
|
+
#include "esphome/core/helpers.h"
|
5
|
+
#include "esphome/core/log.h"
|
5
6
|
|
6
7
|
namespace esphome {
|
7
8
|
namespace uptime {
|
8
9
|
|
9
10
|
static const char *const TAG = "uptime.sensor";
|
10
11
|
|
11
|
-
void
|
12
|
+
void UptimeSecondsSensor::update() {
|
12
13
|
const uint32_t ms = millis();
|
13
14
|
const uint64_t ms_mask = (1ULL << 32) - 1ULL;
|
14
15
|
const uint32_t last_ms = this->uptime_ & ms_mask;
|
@@ -26,9 +27,12 @@ void UptimeSensor::update() {
|
|
26
27
|
const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f;
|
27
28
|
this->publish_state(seconds);
|
28
29
|
}
|
29
|
-
std::string
|
30
|
-
float
|
31
|
-
void
|
30
|
+
std::string UptimeSecondsSensor::unique_id() { return get_mac_address() + "-uptime"; }
|
31
|
+
float UptimeSecondsSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
|
32
|
+
void UptimeSecondsSensor::dump_config() {
|
33
|
+
LOG_SENSOR("", "Uptime Sensor", this);
|
34
|
+
ESP_LOGCONFIG(TAG, " Type: Seconds");
|
35
|
+
}
|
32
36
|
|
33
37
|
} // namespace uptime
|
34
38
|
} // namespace esphome
|
@@ -1,12 +1,12 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
-
#include "esphome/core/component.h"
|
4
3
|
#include "esphome/components/sensor/sensor.h"
|
4
|
+
#include "esphome/core/component.h"
|
5
5
|
|
6
6
|
namespace esphome {
|
7
7
|
namespace uptime {
|
8
8
|
|
9
|
-
class
|
9
|
+
class UptimeSecondsSensor : public sensor::Sensor, public PollingComponent {
|
10
10
|
public:
|
11
11
|
void update() override;
|
12
12
|
void dump_config() override;
|
@@ -0,0 +1,39 @@
|
|
1
|
+
#include "uptime_timestamp_sensor.h"
|
2
|
+
|
3
|
+
#ifdef USE_TIME
|
4
|
+
|
5
|
+
#include "esphome/core/hal.h"
|
6
|
+
#include "esphome/core/helpers.h"
|
7
|
+
#include "esphome/core/log.h"
|
8
|
+
|
9
|
+
namespace esphome {
|
10
|
+
namespace uptime {
|
11
|
+
|
12
|
+
static const char *const TAG = "uptime.sensor";
|
13
|
+
|
14
|
+
void UptimeTimestampSensor::setup() {
|
15
|
+
this->time_->add_on_time_sync_callback([this]() {
|
16
|
+
if (this->has_state_)
|
17
|
+
return; // No need to update the timestamp if it's already set
|
18
|
+
|
19
|
+
auto now = this->time_->now();
|
20
|
+
const uint32_t ms = millis();
|
21
|
+
if (!now.is_valid())
|
22
|
+
return; // No need to update the timestamp if the time is not valid
|
23
|
+
|
24
|
+
time_t timestamp = now.timestamp;
|
25
|
+
uint32_t seconds = ms / 1000;
|
26
|
+
timestamp -= seconds;
|
27
|
+
this->publish_state(timestamp);
|
28
|
+
});
|
29
|
+
}
|
30
|
+
float UptimeTimestampSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
|
31
|
+
void UptimeTimestampSensor::dump_config() {
|
32
|
+
LOG_SENSOR("", "Uptime Sensor", this);
|
33
|
+
ESP_LOGCONFIG(TAG, " Type: Timestamp");
|
34
|
+
}
|
35
|
+
|
36
|
+
} // namespace uptime
|
37
|
+
} // namespace esphome
|
38
|
+
|
39
|
+
#endif // USE_TIME
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/defines.h"
|
4
|
+
|
5
|
+
#ifdef USE_TIME
|
6
|
+
|
7
|
+
#include "esphome/components/sensor/sensor.h"
|
8
|
+
#include "esphome/components/time/real_time_clock.h"
|
9
|
+
#include "esphome/core/component.h"
|
10
|
+
|
11
|
+
namespace esphome {
|
12
|
+
namespace uptime {
|
13
|
+
|
14
|
+
class UptimeTimestampSensor : public sensor::Sensor, public Component {
|
15
|
+
public:
|
16
|
+
void setup() override;
|
17
|
+
void dump_config() override;
|
18
|
+
|
19
|
+
float get_setup_priority() const override;
|
20
|
+
|
21
|
+
void set_time(time::RealTimeClock *time) { this->time_ = time; }
|
22
|
+
|
23
|
+
protected:
|
24
|
+
time::RealTimeClock *time_;
|
25
|
+
};
|
26
|
+
|
27
|
+
} // namespace uptime
|
28
|
+
} // namespace esphome
|
29
|
+
|
30
|
+
#endif // USE_TIME
|
@@ -243,7 +243,7 @@ ErrorCode VEML7700Component::configure_() {
|
|
243
243
|
}
|
244
244
|
|
245
245
|
PSMRegister psm{0};
|
246
|
-
psm.PSM =
|
246
|
+
psm.PSM = PSMMode::PSM_MODE_1;
|
247
247
|
psm.PSM_EN = false;
|
248
248
|
ESP_LOGV(TAG, "Setting PSM to 0x%04X", psm.raw);
|
249
249
|
err = this->write_register((uint8_t) CommandRegisters::PWR_SAVING, psm.raw_bytes, VEML_REG_SIZE);
|
@@ -24,7 +24,7 @@ enum class CommandRegisters : uint8_t {
|
|
24
24
|
ALS_INT = 0x06 // R: ALS INT trigger event
|
25
25
|
};
|
26
26
|
|
27
|
-
enum Gain :
|
27
|
+
enum Gain : uint16_t {
|
28
28
|
X_1 = 0,
|
29
29
|
X_2 = 1,
|
30
30
|
X_1_8 = 2,
|
@@ -32,7 +32,7 @@ enum Gain : uint8_t {
|
|
32
32
|
};
|
33
33
|
const uint8_t GAINS_COUNT = 4;
|
34
34
|
|
35
|
-
enum IntegrationTime :
|
35
|
+
enum IntegrationTime : uint16_t {
|
36
36
|
INTEGRATION_TIME_25MS = 0b1100,
|
37
37
|
INTEGRATION_TIME_50MS = 0b1000,
|
38
38
|
INTEGRATION_TIME_100MS = 0b0000,
|
@@ -42,14 +42,14 @@ enum IntegrationTime : uint8_t {
|
|
42
42
|
};
|
43
43
|
const uint8_t INTEGRATION_TIMES_COUNT = 6;
|
44
44
|
|
45
|
-
enum Persistence :
|
45
|
+
enum Persistence : uint16_t {
|
46
46
|
PERSISTENCE_1 = 0,
|
47
47
|
PERSISTENCE_2 = 1,
|
48
48
|
PERSISTENCE_4 = 2,
|
49
49
|
PERSISTENCE_8 = 3,
|
50
50
|
};
|
51
51
|
|
52
|
-
enum
|
52
|
+
enum PSMMode : uint16_t {
|
53
53
|
PSM_MODE_1 = 0,
|
54
54
|
PSM_MODE_2 = 1,
|
55
55
|
PSM_MODE_3 = 2,
|
@@ -92,7 +92,7 @@ union PSMRegister {
|
|
92
92
|
uint8_t raw_bytes[2];
|
93
93
|
struct {
|
94
94
|
bool PSM_EN : 1;
|
95
|
-
|
95
|
+
PSMMode PSM : 2;
|
96
96
|
uint16_t reserved : 13;
|
97
97
|
} __attribute__((packed));
|
98
98
|
};
|
@@ -684,7 +684,9 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
|
|
684
684
|
this->defer([this, text]() {
|
685
685
|
this->tts_start_trigger_->trigger(text);
|
686
686
|
#ifdef USE_SPEAKER
|
687
|
-
this->speaker_
|
687
|
+
if (this->speaker_ != nullptr) {
|
688
|
+
this->speaker_->start();
|
689
|
+
}
|
688
690
|
#endif
|
689
691
|
});
|
690
692
|
break;
|
@@ -799,7 +801,7 @@ void VoiceAssistant::on_audio(const api::VoiceAssistantAudio &msg) {
|
|
799
801
|
this->speaker_buffer_index_ += msg.data.length();
|
800
802
|
this->speaker_buffer_size_ += msg.data.length();
|
801
803
|
this->speaker_bytes_received_ += msg.data.length();
|
802
|
-
ESP_LOGV(TAG, "Received audio: %
|
804
|
+
ESP_LOGV(TAG, "Received audio: %u bytes from API", msg.data.length());
|
803
805
|
} else {
|
804
806
|
ESP_LOGE(TAG, "Cannot receive audio, buffer is full");
|
805
807
|
}
|