esphome 2025.9.0b1__py3-none-any.whl → 2025.9.0b3__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.
Files changed (48) hide show
  1. esphome/__main__.py +146 -68
  2. esphome/components/adc/__init__.py +1 -26
  3. esphome/components/adc/sensor.py +20 -0
  4. esphome/components/ade7880/ade7880.cpp +1 -1
  5. esphome/components/api/api_connection.cpp +4 -11
  6. esphome/components/api/api_connection.h +0 -1
  7. esphome/components/api/api_pb2.cpp +0 -8
  8. esphome/components/api/api_pb2.h +0 -4
  9. esphome/components/api/api_pb2_dump.cpp +1 -7
  10. esphome/components/api/api_pb2_service.cpp +0 -14
  11. esphome/components/api/api_pb2_service.h +1 -3
  12. esphome/components/api/client.py +5 -3
  13. esphome/components/bluetooth_proxy/bluetooth_proxy.h +3 -1
  14. esphome/components/captive_portal/captive_index.h +77 -97
  15. esphome/components/esp32_ble/ble_uuid.cpp +30 -9
  16. esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +4 -3
  17. esphome/components/esp32_ble_client/ble_client_base.h +8 -5
  18. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +2 -3
  19. esphome/components/ethernet/__init__.py +11 -0
  20. esphome/components/ethernet/ethernet_component.cpp +52 -2
  21. esphome/components/ethernet/ethernet_component.h +4 -0
  22. esphome/components/factory_reset/button/factory_reset_button.cpp +18 -1
  23. esphome/components/factory_reset/button/factory_reset_button.h +6 -1
  24. esphome/components/factory_reset/switch/factory_reset_switch.cpp +18 -1
  25. esphome/components/factory_reset/switch/factory_reset_switch.h +5 -1
  26. esphome/components/ina2xx_base/__init__.py +4 -2
  27. esphome/components/md5/md5.cpp +3 -2
  28. esphome/components/mqtt/mqtt_client.cpp +1 -1
  29. esphome/components/openthread/openthread.cpp +41 -7
  30. esphome/components/openthread/openthread.h +11 -0
  31. esphome/components/select/select.cpp +3 -3
  32. esphome/components/select/select_call.cpp +1 -1
  33. esphome/components/web_server/server_index_v2.h +149 -149
  34. esphome/components/wifi/wifi_component.cpp +1 -1
  35. esphome/components/wifi_info/wifi_info_text_sensor.h +3 -2
  36. esphome/const.py +2 -1
  37. esphome/core/defines.h +1 -0
  38. esphome/core/helpers.cpp +8 -7
  39. esphome/core/helpers.h +29 -0
  40. esphome/core/scheduler.cpp +4 -4
  41. esphome/core/scheduler.h +1 -1
  42. esphome/dashboard/web_server.py +2 -5
  43. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/METADATA +2 -2
  44. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/RECORD +48 -48
  45. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/WHEEL +0 -0
  46. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/entry_points.txt +0 -0
  47. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/licenses/LICENSE +0 -0
  48. {esphome-2025.9.0b1.dist-info → esphome-2025.9.0b3.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,8 @@
1
1
  #pragma once
2
2
 
3
- #include "esphome/core/component.h"
4
3
  #include "esphome/components/switch/switch.h"
4
+ #include "esphome/core/component.h"
5
+ #include "esphome/core/defines.h"
5
6
 
6
7
  namespace esphome {
7
8
  namespace factory_reset {
@@ -9,6 +10,9 @@ namespace factory_reset {
9
10
  class FactoryResetSwitch : public switch_::Switch, public Component {
10
11
  public:
11
12
  void dump_config() override;
13
+ #ifdef USE_OPENTHREAD
14
+ static void factory_reset_callback();
15
+ #endif
12
16
 
13
17
  protected:
14
18
  void write_state(bool state) override;
@@ -18,6 +18,7 @@ from esphome.const import (
18
18
  DEVICE_CLASS_TEMPERATURE,
19
19
  DEVICE_CLASS_VOLTAGE,
20
20
  STATE_CLASS_MEASUREMENT,
21
+ STATE_CLASS_TOTAL_INCREASING,
21
22
  UNIT_AMPERE,
22
23
  UNIT_CELSIUS,
23
24
  UNIT_VOLT,
@@ -162,7 +163,7 @@ INA2XX_SCHEMA = cv.Schema(
162
163
  unit_of_measurement=UNIT_WATT_HOURS,
163
164
  accuracy_decimals=8,
164
165
  device_class=DEVICE_CLASS_ENERGY,
165
- state_class=STATE_CLASS_MEASUREMENT,
166
+ state_class=STATE_CLASS_TOTAL_INCREASING,
166
167
  ),
167
168
  key=CONF_NAME,
168
169
  ),
@@ -170,7 +171,8 @@ INA2XX_SCHEMA = cv.Schema(
170
171
  sensor.sensor_schema(
171
172
  unit_of_measurement=UNIT_JOULE,
172
173
  accuracy_decimals=8,
173
- state_class=STATE_CLASS_MEASUREMENT,
174
+ device_class=DEVICE_CLASS_ENERGY,
175
+ state_class=STATE_CLASS_TOTAL_INCREASING,
174
176
  ),
175
177
  key=CONF_NAME,
176
178
  ),
@@ -1,4 +1,3 @@
1
- #include <cstdio>
2
1
  #include <cstring>
3
2
  #include "md5.h"
4
3
  #ifdef USE_MD5
@@ -44,7 +43,9 @@ void MD5Digest::get_bytes(uint8_t *output) { memcpy(output, this->digest_, 16);
44
43
 
45
44
  void MD5Digest::get_hex(char *output) {
46
45
  for (size_t i = 0; i < 16; i++) {
47
- sprintf(output + i * 2, "%02x", this->digest_[i]);
46
+ uint8_t byte = this->digest_[i];
47
+ output[i * 2] = format_hex_char(byte >> 4);
48
+ output[i * 2 + 1] = format_hex_char(byte & 0x0F);
48
49
  }
49
50
  }
50
51
 
@@ -491,7 +491,7 @@ bool MQTTClientComponent::publish(const std::string &topic, const std::string &p
491
491
 
492
492
  bool MQTTClientComponent::publish(const std::string &topic, const char *payload, size_t payload_length, uint8_t qos,
493
493
  bool retain) {
494
- return publish({.topic = topic, .payload = payload, .qos = qos, .retain = retain});
494
+ return publish({.topic = topic, .payload = std::string(payload, payload_length), .qos = qos, .retain = retain});
495
495
  }
496
496
 
497
497
  bool MQTTClientComponent::publish(const MQTTMessage &message) {
@@ -11,8 +11,6 @@
11
11
  #include <openthread/instance.h>
12
12
  #include <openthread/logging.h>
13
13
  #include <openthread/netdata.h>
14
- #include <openthread/srp_client.h>
15
- #include <openthread/srp_client_buffers.h>
16
14
  #include <openthread/tasklet.h>
17
15
 
18
16
  #include <cstring>
@@ -77,8 +75,14 @@ std::optional<otIp6Address> OpenThreadComponent::get_omr_address_(InstanceLock &
77
75
  return {};
78
76
  }
79
77
 
80
- void srp_callback(otError err, const otSrpClientHostInfo *host_info, const otSrpClientService *services,
81
- const otSrpClientService *removed_services, void *context) {
78
+ void OpenThreadComponent::defer_factory_reset_external_callback() {
79
+ ESP_LOGD(TAG, "Defer factory_reset_external_callback_");
80
+ this->defer([this]() { this->factory_reset_external_callback_(); });
81
+ }
82
+
83
+ void OpenThreadSrpComponent::srp_callback(otError err, const otSrpClientHostInfo *host_info,
84
+ const otSrpClientService *services,
85
+ const otSrpClientService *removed_services, void *context) {
82
86
  if (err != 0) {
83
87
  ESP_LOGW(TAG, "SRP client reported an error: %s", otThreadErrorToString(err));
84
88
  for (const otSrpClientHostInfo *host = host_info; host; host = nullptr) {
@@ -90,16 +94,30 @@ void srp_callback(otError err, const otSrpClientHostInfo *host_info, const otSrp
90
94
  }
91
95
  }
92
96
 
93
- void srp_start_callback(const otSockAddr *server_socket_address, void *context) {
97
+ void OpenThreadSrpComponent::srp_start_callback(const otSockAddr *server_socket_address, void *context) {
94
98
  ESP_LOGI(TAG, "SRP client has started");
95
99
  }
96
100
 
101
+ void OpenThreadSrpComponent::srp_factory_reset_callback(otError err, const otSrpClientHostInfo *host_info,
102
+ const otSrpClientService *services,
103
+ const otSrpClientService *removed_services, void *context) {
104
+ OpenThreadComponent *obj = (OpenThreadComponent *) context;
105
+ if (err == OT_ERROR_NONE && removed_services != NULL && host_info != NULL &&
106
+ host_info->mState == OT_SRP_CLIENT_ITEM_STATE_REMOVED) {
107
+ ESP_LOGD(TAG, "Successful Removal SRP Host and Services");
108
+ } else if (err != OT_ERROR_NONE) {
109
+ // Handle other SRP client events or errors
110
+ ESP_LOGW(TAG, "SRP client event/error: %s", otThreadErrorToString(err));
111
+ }
112
+ obj->defer_factory_reset_external_callback();
113
+ }
114
+
97
115
  void OpenThreadSrpComponent::setup() {
98
116
  otError error;
99
117
  InstanceLock lock = InstanceLock::acquire();
100
118
  otInstance *instance = lock.get_instance();
101
119
 
102
- otSrpClientSetCallback(instance, srp_callback, nullptr);
120
+ otSrpClientSetCallback(instance, OpenThreadSrpComponent::srp_callback, nullptr);
103
121
 
104
122
  // set the host name
105
123
  uint16_t size;
@@ -179,7 +197,8 @@ void OpenThreadSrpComponent::setup() {
179
197
  ESP_LOGD(TAG, "Added service: %s", full_service.c_str());
180
198
  }
181
199
 
182
- otSrpClientEnableAutoStartMode(instance, srp_start_callback, nullptr);
200
+ otSrpClientEnableAutoStartMode(instance, OpenThreadSrpComponent::srp_start_callback, nullptr);
201
+ ESP_LOGD(TAG, "Finished SRP setup");
183
202
  }
184
203
 
185
204
  void *OpenThreadSrpComponent::pool_alloc_(size_t size) {
@@ -217,6 +236,21 @@ bool OpenThreadComponent::teardown() {
217
236
  return this->teardown_complete_;
218
237
  }
219
238
 
239
+ void OpenThreadComponent::on_factory_reset(std::function<void()> callback) {
240
+ factory_reset_external_callback_ = callback;
241
+ ESP_LOGD(TAG, "Start Removal SRP Host and Services");
242
+ otError error;
243
+ InstanceLock lock = InstanceLock::acquire();
244
+ otInstance *instance = lock.get_instance();
245
+ otSrpClientSetCallback(instance, OpenThreadSrpComponent::srp_factory_reset_callback, this);
246
+ error = otSrpClientRemoveHostAndServices(instance, true, true);
247
+ if (error != OT_ERROR_NONE) {
248
+ ESP_LOGW(TAG, "Failed to Remove SRP Host and Services");
249
+ return;
250
+ }
251
+ ESP_LOGD(TAG, "Waiting on Confirmation Removal SRP Host and Services");
252
+ }
253
+
220
254
  } // namespace openthread
221
255
  } // namespace esphome
222
256
 
@@ -6,6 +6,8 @@
6
6
  #include "esphome/components/network/ip_address.h"
7
7
  #include "esphome/core/component.h"
8
8
 
9
+ #include <openthread/srp_client.h>
10
+ #include <openthread/srp_client_buffers.h>
9
11
  #include <openthread/thread.h>
10
12
 
11
13
  #include <optional>
@@ -28,11 +30,14 @@ class OpenThreadComponent : public Component {
28
30
  network::IPAddresses get_ip_addresses();
29
31
  std::optional<otIp6Address> get_omr_address();
30
32
  void ot_main();
33
+ void on_factory_reset(std::function<void()> callback);
34
+ void defer_factory_reset_external_callback();
31
35
 
32
36
  protected:
33
37
  std::optional<otIp6Address> get_omr_address_(InstanceLock &lock);
34
38
  bool teardown_started_{false};
35
39
  bool teardown_complete_{false};
40
+ std::function<void()> factory_reset_external_callback_;
36
41
  };
37
42
 
38
43
  extern OpenThreadComponent *global_openthread_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
@@ -43,6 +48,12 @@ class OpenThreadSrpComponent : public Component {
43
48
  // This has to run after the mdns component or else no services are available to advertise
44
49
  float get_setup_priority() const override { return this->mdns_->get_setup_priority() - 1.0; }
45
50
  void setup() override;
51
+ static void srp_callback(otError err, const otSrpClientHostInfo *host_info, const otSrpClientService *services,
52
+ const otSrpClientService *removed_services, void *context);
53
+ static void srp_start_callback(const otSockAddr *server_socket_address, void *context);
54
+ static void srp_factory_reset_callback(otError err, const otSrpClientHostInfo *host_info,
55
+ const otSrpClientService *services, const otSrpClientService *removed_services,
56
+ void *context);
46
57
 
47
58
  protected:
48
59
  esphome::mdns::MDNSComponent *mdns_{nullptr};
@@ -28,12 +28,12 @@ bool Select::has_option(const std::string &option) const { return this->index_of
28
28
  bool Select::has_index(size_t index) const { return index < this->size(); }
29
29
 
30
30
  size_t Select::size() const {
31
- auto options = traits.get_options();
31
+ const auto &options = traits.get_options();
32
32
  return options.size();
33
33
  }
34
34
 
35
35
  optional<size_t> Select::index_of(const std::string &option) const {
36
- auto options = traits.get_options();
36
+ const auto &options = traits.get_options();
37
37
  auto it = std::find(options.begin(), options.end(), option);
38
38
  if (it == options.end()) {
39
39
  return {};
@@ -51,7 +51,7 @@ optional<size_t> Select::active_index() const {
51
51
 
52
52
  optional<std::string> Select::at(size_t index) const {
53
53
  if (this->has_index(index)) {
54
- auto options = traits.get_options();
54
+ const auto &options = traits.get_options();
55
55
  return options.at(index);
56
56
  } else {
57
57
  return {};
@@ -45,7 +45,7 @@ void SelectCall::perform() {
45
45
  auto *parent = this->parent_;
46
46
  const auto *name = parent->get_name().c_str();
47
47
  const auto &traits = parent->traits;
48
- auto options = traits.get_options();
48
+ const auto &options = traits.get_options();
49
49
 
50
50
  if (this->operation_ == SELECT_OP_NONE) {
51
51
  ESP_LOGW(TAG, "'%s' - SelectCall performed without selecting an operation", name);