esphome 2024.11.3__py3-none-any.whl → 2024.12.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.
Files changed (183) hide show
  1. esphome/components/adc/adc_sensor.h +7 -8
  2. esphome/components/adc/adc_sensor_common.cpp +24 -0
  3. esphome/components/adc/{adc_sensor.cpp → adc_sensor_esp32.cpp} +10 -179
  4. esphome/components/adc/adc_sensor_esp8266.cpp +58 -0
  5. esphome/components/adc/adc_sensor_libretiny.cpp +48 -0
  6. esphome/components/adc/adc_sensor_rp2040.cpp +93 -0
  7. esphome/components/alarm_control_panel/alarm_control_panel_call.cpp +3 -4
  8. esphome/components/animation/__init__.py +1 -2
  9. esphome/components/apds9306/apds9306.cpp +2 -1
  10. esphome/components/audio/audio.h +1 -1
  11. esphome/components/bk72xx/__init__.py +1 -1
  12. esphome/components/cse7766/cse7766.cpp +1 -1
  13. esphome/components/deep_sleep/deep_sleep_esp32.cpp +2 -2
  14. esphome/components/dht/dht.cpp +2 -1
  15. esphome/components/display/display.cpp +10 -6
  16. esphome/components/display/display.h +14 -0
  17. esphome/components/display_menu_base/__init__.py +0 -2
  18. esphome/components/display_menu_base/display_menu_base.cpp +1 -1
  19. esphome/components/dsmr/dsmr.cpp +1 -1
  20. esphome/components/esp32/__init__.py +94 -12
  21. esphome/components/esp32/boards.py +222 -14
  22. esphome/components/esp32_ble/__init__.py +22 -2
  23. esphome/components/esp32_ble/ble.cpp +39 -12
  24. esphome/components/esp32_ble/ble.h +2 -0
  25. esphome/components/esp32_ble/ble_advertising.cpp +1 -1
  26. esphome/components/esp32_ble/ble_uuid.cpp +9 -10
  27. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +4 -1
  28. esphome/components/esp32_camera_web_server/camera_web_server.h +1 -1
  29. esphome/components/esp32_rmt_led_strip/light.py +3 -3
  30. esphome/components/esp8266/__init__.py +5 -7
  31. esphome/components/ezo/ezo.cpp +14 -26
  32. esphome/components/font/__init__.py +10 -25
  33. esphome/components/font/font.cpp +5 -3
  34. esphome/components/graphical_display_menu/__init__.py +2 -0
  35. esphome/components/haier/hon_climate.cpp +79 -80
  36. esphome/components/hbridge/switch/__init__.py +44 -0
  37. esphome/components/hbridge/switch/hbridge_switch.cpp +95 -0
  38. esphome/components/hbridge/switch/hbridge_switch.h +50 -0
  39. esphome/components/hitachi_ac344/hitachi_ac344.cpp +4 -2
  40. esphome/components/hitachi_ac424/hitachi_ac424.cpp +4 -2
  41. esphome/components/homeassistant/number/homeassistant_number.cpp +3 -0
  42. esphome/components/hx711/hx711.cpp +1 -1
  43. esphome/components/hx711/hx711.h +1 -1
  44. esphome/components/i2c/i2c_bus_esp_idf.cpp +2 -2
  45. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +61 -59
  46. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -17
  47. esphome/components/ili9xxx/display.py +1 -2
  48. esphome/components/ili9xxx/ili9xxx_display.cpp +3 -2
  49. esphome/components/image/__init__.py +1 -2
  50. esphome/components/logger/logger.cpp +1 -1
  51. esphome/components/ltr501/ltr501.cpp +1 -1
  52. esphome/components/lvgl/defines.py +8 -1
  53. esphome/components/lvgl/lv_validation.py +8 -3
  54. esphome/components/lvgl/lvgl_esphome.cpp +1 -1
  55. esphome/components/lvgl/lvgl_esphome.h +16 -0
  56. esphome/components/lvgl/widgets/animimg.py +12 -17
  57. esphome/components/lvgl/widgets/img.py +1 -3
  58. esphome/components/matrix_keypad/__init__.py +15 -3
  59. esphome/components/matrix_keypad/matrix_keypad.cpp +4 -0
  60. esphome/components/matrix_keypad/matrix_keypad.h +5 -0
  61. esphome/components/max31865/max31865.cpp +4 -2
  62. esphome/components/modbus_controller/modbus_controller.cpp +24 -24
  63. esphome/components/modbus_controller/modbus_controller.h +22 -22
  64. esphome/components/modbus_controller/number/modbus_number.cpp +8 -8
  65. esphome/components/modbus_controller/number/modbus_number.h +4 -4
  66. esphome/components/modbus_controller/output/modbus_output.cpp +7 -6
  67. esphome/components/modbus_controller/output/modbus_output.h +5 -5
  68. esphome/components/modbus_controller/select/modbus_select.cpp +4 -3
  69. esphome/components/modbus_controller/select/modbus_select.h +4 -4
  70. esphome/components/modbus_controller/switch/modbus_switch.cpp +5 -5
  71. esphome/components/modbus_controller/switch/modbus_switch.h +2 -2
  72. esphome/components/mqtt/__init__.py +4 -0
  73. esphome/components/mqtt/mqtt_alarm_control_panel.cpp +2 -5
  74. esphome/components/mqtt/mqtt_backend_esp32.cpp +3 -3
  75. esphome/components/mqtt/mqtt_client.cpp +4 -0
  76. esphome/components/mqtt/mqtt_client.h +6 -0
  77. esphome/components/mqtt/mqtt_climate.cpp +13 -3
  78. esphome/components/mqtt/mqtt_sensor.cpp +2 -0
  79. esphome/components/network/ip_address.h +1 -1
  80. esphome/components/nextion/__init__.py +2 -0
  81. esphome/components/nextion/automation.h +76 -0
  82. esphome/components/nextion/base_component.py +1 -0
  83. esphome/components/nextion/binary_sensor/__init__.py +43 -2
  84. esphome/components/nextion/display.py +15 -0
  85. esphome/components/nextion/nextion.cpp +8 -5
  86. esphome/components/nextion/nextion.h +7 -0
  87. esphome/components/nextion/nextion_upload_idf.cpp +2 -2
  88. esphome/components/nextion/sensor/__init__.py +38 -5
  89. esphome/components/nextion/switch/__init__.py +38 -2
  90. esphome/components/nextion/text_sensor/__init__.py +37 -2
  91. esphome/components/nfc/ndef_record.cpp +3 -3
  92. esphome/components/online_image/__init__.py +1 -0
  93. esphome/components/opentherm/opentherm.cpp +3 -3
  94. esphome/components/opentherm/opentherm.h +1 -1
  95. esphome/components/ota/automation.h +1 -1
  96. esphome/components/output/float_output.cpp +1 -1
  97. esphome/components/pca6416a/pca6416a.cpp +5 -3
  98. esphome/components/pca9554/pca9554.cpp +4 -4
  99. esphome/components/pipsolar/pipsolar.cpp +2 -2
  100. esphome/components/pipsolar/switch/pipsolar_switch.cpp +2 -2
  101. esphome/components/pn532/pn532_mifare_ultralight.cpp +2 -2
  102. esphome/components/pn7150/pn7150_mifare_ultralight.cpp +2 -2
  103. esphome/components/pn7160/pn7160_mifare_ultralight.cpp +2 -2
  104. esphome/components/qmc5883l/qmc5883l.cpp +45 -19
  105. esphome/components/qmc5883l/qmc5883l.h +1 -1
  106. esphome/components/qspi_dbi/qspi_dbi.cpp +2 -1
  107. esphome/components/remote_base/raw_protocol.cpp +1 -1
  108. esphome/components/remote_receiver/__init__.py +5 -6
  109. esphome/components/rotary_encoder/rotary_encoder.cpp +3 -1
  110. esphome/components/rp2040/__init__.py +1 -1
  111. esphome/components/rtl87xx/__init__.py +1 -1
  112. esphome/components/safe_mode/automation.h +1 -1
  113. esphome/components/seeed_mr60bha2/__init__.py +41 -0
  114. esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +173 -0
  115. esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +61 -0
  116. esphome/components/seeed_mr60bha2/sensor.py +57 -0
  117. esphome/components/seeed_mr60fda2/__init__.py +41 -0
  118. esphome/components/seeed_mr60fda2/binary_sensor.py +33 -0
  119. esphome/components/seeed_mr60fda2/button/__init__.py +45 -0
  120. esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.cpp +9 -0
  121. esphome/components/seeed_mr60fda2/button/get_radar_parameters_button.h +18 -0
  122. esphome/components/seeed_mr60fda2/button/reset_radar_button.cpp +9 -0
  123. esphome/components/seeed_mr60fda2/button/reset_radar_button.h +18 -0
  124. esphome/components/seeed_mr60fda2/seeed_mr60fda2.cpp +368 -0
  125. esphome/components/seeed_mr60fda2/seeed_mr60fda2.h +101 -0
  126. esphome/components/seeed_mr60fda2/select/__init__.py +59 -0
  127. esphome/components/seeed_mr60fda2/select/height_threshold_select.cpp +15 -0
  128. esphome/components/seeed_mr60fda2/select/height_threshold_select.h +18 -0
  129. esphome/components/seeed_mr60fda2/select/install_height_select.cpp +15 -0
  130. esphome/components/seeed_mr60fda2/select/install_height_select.h +18 -0
  131. esphome/components/seeed_mr60fda2/select/sensitivity_select.cpp +15 -0
  132. esphome/components/seeed_mr60fda2/select/sensitivity_select.h +18 -0
  133. esphome/components/sen5x/sensor.py +5 -6
  134. esphome/components/sgp30/sensor.py +8 -9
  135. esphome/components/sgp30/sgp30.cpp +2 -6
  136. esphome/components/shelly_dimmer/shelly_dimmer.cpp +1 -1
  137. esphome/components/sim800l/sim800l.cpp +1 -1
  138. esphome/components/sntp/sntp_component.cpp +14 -20
  139. esphome/components/sntp/sntp_component.h +6 -9
  140. esphome/components/sntp/time.py +4 -7
  141. esphome/components/sprinkler/sprinkler.cpp +2 -2
  142. esphome/components/st7735/st7735.cpp +1 -1
  143. esphome/components/st7789v/st7789v.cpp +1 -1
  144. esphome/components/stepper/stepper.h +0 -1
  145. esphome/components/sun_gtil2/sun_gtil2.cpp +1 -1
  146. esphome/components/switch/binary_sensor/__init__.py +31 -0
  147. esphome/components/switch/binary_sensor/switch_binary_sensor.cpp +17 -0
  148. esphome/components/switch/binary_sensor/switch_binary_sensor.h +22 -0
  149. esphome/components/sx1509/sx1509_gpio_pin.cpp +2 -1
  150. esphome/components/sx1509/sx1509_gpio_pin.h +5 -5
  151. esphome/components/uart/uart.h +1 -1
  152. esphome/components/udp/udp_component.cpp +32 -16
  153. esphome/components/ufire_ec/sensor.py +4 -4
  154. esphome/components/uln2003/uln2003.cpp +4 -1
  155. esphome/components/waveshare_epaper/display.py +8 -0
  156. esphome/components/waveshare_epaper/waveshare_epaper.cpp +191 -0
  157. esphome/components/waveshare_epaper/waveshare_epaper.h +56 -0
  158. esphome/components/wiegand/__init__.py +3 -4
  159. esphome/components/wifi/__init__.py +42 -0
  160. esphome/components/wifi/wifi_component.cpp +2 -2
  161. esphome/components/wifi/wifi_component.h +82 -1
  162. esphome/components/wifi/wifi_component_esp32_arduino.cpp +1 -1
  163. esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
  164. esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
  165. esphome/components/wifi/wifi_component_libretiny.cpp +1 -1
  166. esphome/components/wifi/wifi_component_pico_w.cpp +1 -1
  167. esphome/components/wireguard/wireguard.cpp +2 -2
  168. esphome/components/xiaomi_ble/xiaomi_ble.cpp +1 -1
  169. esphome/config_validation.py +15 -11
  170. esphome/const.py +11 -1
  171. esphome/core/component.cpp +1 -1
  172. esphome/core/config.py +1 -2
  173. esphome/core/defines.h +3 -1
  174. esphome/core/helpers.cpp +8 -2
  175. esphome/core/helpers.h +2 -1
  176. esphome/core/optional.h +2 -2
  177. esphome/dashboard/web_server.py +6 -0
  178. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/METADATA +4 -4
  179. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/RECORD +183 -153
  180. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/LICENSE +0 -0
  181. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/WHEEL +0 -0
  182. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/entry_points.txt +0 -0
  183. {esphome-2024.11.3.dist-info → esphome-2024.12.0.dist-info}/top_level.txt +0 -0
@@ -3,13 +3,12 @@
3
3
  #include "esphome/components/sensor/sensor.h"
4
4
  #include "esphome/components/voltage_sampler/voltage_sampler.h"
5
5
  #include "esphome/core/component.h"
6
- #include "esphome/core/defines.h"
7
6
  #include "esphome/core/hal.h"
8
7
 
9
8
  #ifdef USE_ESP32
10
9
  #include <esp_adc_cal.h>
11
10
  #include "driver/adc.h"
12
- #endif
11
+ #endif // USE_ESP32
13
12
 
14
13
  namespace esphome {
15
14
  namespace adc {
@@ -43,7 +42,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
43
42
  this->channel1_ = ADC1_CHANNEL_MAX;
44
43
  }
45
44
  void set_autorange(bool autorange) { this->autorange_ = autorange; }
46
- #endif
45
+ #endif // USE_ESP32
47
46
 
48
47
  /// Update ADC values
49
48
  void update() override;
@@ -59,11 +58,11 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
59
58
 
60
59
  #ifdef USE_ESP8266
61
60
  std::string unique_id() override;
62
- #endif
61
+ #endif // USE_ESP8266
63
62
 
64
63
  #ifdef USE_RP2040
65
64
  void set_is_temperature() { this->is_temperature_ = true; }
66
- #endif
65
+ #endif // USE_RP2040
67
66
 
68
67
  protected:
69
68
  InternalGPIOPin *pin_;
@@ -72,7 +71,7 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
72
71
 
73
72
  #ifdef USE_RP2040
74
73
  bool is_temperature_{false};
75
- #endif
74
+ #endif // USE_RP2040
76
75
 
77
76
  #ifdef USE_ESP32
78
77
  adc_atten_t attenuation_{ADC_ATTEN_DB_0};
@@ -83,8 +82,8 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
83
82
  esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
84
83
  #else
85
84
  esp_adc_cal_characteristics_t cal_characteristics_[ADC_ATTEN_MAX] = {};
86
- #endif
87
- #endif
85
+ #endif // ESP_IDF_VERSION_MAJOR
86
+ #endif // USE_ESP32
88
87
  };
89
88
 
90
89
  } // namespace adc
@@ -0,0 +1,24 @@
1
+ #include "adc_sensor.h"
2
+ #include "esphome/core/log.h"
3
+
4
+ namespace esphome {
5
+ namespace adc {
6
+
7
+ static const char *const TAG = "adc.common";
8
+
9
+ void ADCSensor::update() {
10
+ float value_v = this->sample();
11
+ ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v);
12
+ this->publish_state(value_v);
13
+ }
14
+
15
+ void ADCSensor::set_sample_count(uint8_t sample_count) {
16
+ if (sample_count != 0) {
17
+ this->sample_count_ = sample_count;
18
+ }
19
+ }
20
+
21
+ float ADCSensor::get_setup_priority() const { return setup_priority::DATA; }
22
+
23
+ } // namespace adc
24
+ } // namespace esphome
@@ -1,30 +1,13 @@
1
+ #ifdef USE_ESP32
2
+
1
3
  #include "adc_sensor.h"
2
- #include "esphome/core/helpers.h"
3
4
  #include "esphome/core/log.h"
4
5
 
5
- #ifdef USE_ESP8266
6
- #ifdef USE_ADC_SENSOR_VCC
7
- #include <Esp.h>
8
- ADC_MODE(ADC_VCC)
9
- #else
10
- #include <Arduino.h>
11
- #endif
12
- #endif
13
-
14
- #ifdef USE_RP2040
15
- #ifdef CYW43_USES_VSYS_PIN
16
- #include "pico/cyw43_arch.h"
17
- #endif
18
- #include <hardware/adc.h>
19
- #endif
20
-
21
6
  namespace esphome {
22
7
  namespace adc {
23
8
 
24
- static const char *const TAG = "adc";
9
+ static const char *const TAG = "adc.esp32";
25
10
 
26
- // 13-bit for S2, 12-bit for all other ESP32 variants
27
- #ifdef USE_ESP32
28
11
  static const adc_bits_width_t ADC_WIDTH_MAX_SOC_BITS = static_cast<adc_bits_width_t>(ADC_WIDTH_MAX - 1);
29
12
 
30
13
  #ifndef SOC_ADC_RTC_MAX_BITWIDTH
@@ -32,24 +15,15 @@ static const adc_bits_width_t ADC_WIDTH_MAX_SOC_BITS = static_cast<adc_bits_widt
32
15
  static const int32_t SOC_ADC_RTC_MAX_BITWIDTH = 13;
33
16
  #else
34
17
  static const int32_t SOC_ADC_RTC_MAX_BITWIDTH = 12;
35
- #endif
36
- #endif
18
+ #endif // USE_ESP32_VARIANT_ESP32S2
19
+ #endif // SOC_ADC_RTC_MAX_BITWIDTH
37
20
 
38
- static const int ADC_MAX = (1 << SOC_ADC_RTC_MAX_BITWIDTH) - 1; // 4095 (12 bit) or 8191 (13 bit)
39
- static const int ADC_HALF = (1 << SOC_ADC_RTC_MAX_BITWIDTH) >> 1; // 2048 (12 bit) or 4096 (13 bit)
40
- #endif
21
+ static const int ADC_MAX = (1 << SOC_ADC_RTC_MAX_BITWIDTH) - 1;
22
+ static const int ADC_HALF = (1 << SOC_ADC_RTC_MAX_BITWIDTH) >> 1;
41
23
 
42
- #ifdef USE_RP2040
43
- extern "C"
44
- #endif
45
- void
46
- ADCSensor::setup() {
24
+ void ADCSensor::setup() {
47
25
  ESP_LOGCONFIG(TAG, "Setting up ADC '%s'...", this->get_name().c_str());
48
- #if !defined(USE_ADC_SENSOR_VCC) && !defined(USE_RP2040)
49
- this->pin_->setup();
50
- #endif
51
26
 
52
- #ifdef USE_ESP32
53
27
  if (this->channel1_ != ADC1_CHANNEL_MAX) {
54
28
  adc1_config_width(ADC_WIDTH_MAX_SOC_BITS);
55
29
  if (!this->autorange_) {
@@ -61,7 +35,6 @@ extern "C"
61
35
  }
62
36
  }
63
37
 
64
- // load characteristics for each attenuation
65
38
  for (int32_t i = 0; i <= ADC_ATTEN_DB_12_COMPAT; i++) {
66
39
  auto adc_unit = this->channel1_ != ADC1_CHANNEL_MAX ? ADC_UNIT_1 : ADC_UNIT_2;
67
40
  auto cal_value = esp_adc_cal_characterize(adc_unit, (adc_atten_t) i, ADC_WIDTH_MAX_SOC_BITS,
@@ -79,31 +52,10 @@ extern "C"
79
52
  break;
80
53
  }
81
54
  }
82
-
83
- #endif // USE_ESP32
84
-
85
- #ifdef USE_RP2040
86
- static bool initialized = false;
87
- if (!initialized) {
88
- adc_init();
89
- initialized = true;
90
- }
91
- #endif
92
-
93
- ESP_LOGCONFIG(TAG, "ADC '%s' setup finished!", this->get_name().c_str());
94
55
  }
95
56
 
96
57
  void ADCSensor::dump_config() {
97
58
  LOG_SENSOR("", "ADC Sensor", this);
98
- #if defined(USE_ESP8266) || defined(USE_LIBRETINY)
99
- #ifdef USE_ADC_SENSOR_VCC
100
- ESP_LOGCONFIG(TAG, " Pin: VCC");
101
- #else
102
- LOG_PIN(" Pin: ", this->pin_);
103
- #endif
104
- #endif // USE_ESP8266 || USE_LIBRETINY
105
-
106
- #ifdef USE_ESP32
107
59
  LOG_PIN(" Pin: ", this->pin_);
108
60
  if (this->autorange_) {
109
61
  ESP_LOGCONFIG(TAG, " Attenuation: auto");
@@ -125,55 +77,10 @@ void ADCSensor::dump_config() {
125
77
  break;
126
78
  }
127
79
  }
128
- #endif // USE_ESP32
129
-
130
- #ifdef USE_RP2040
131
- if (this->is_temperature_) {
132
- ESP_LOGCONFIG(TAG, " Pin: Temperature");
133
- } else {
134
- #ifdef USE_ADC_SENSOR_VCC
135
- ESP_LOGCONFIG(TAG, " Pin: VCC");
136
- #else
137
- LOG_PIN(" Pin: ", this->pin_);
138
- #endif // USE_ADC_SENSOR_VCC
139
- }
140
- #endif // USE_RP2040
141
80
  ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
142
81
  LOG_UPDATE_INTERVAL(this);
143
82
  }
144
83
 
145
- float ADCSensor::get_setup_priority() const { return setup_priority::DATA; }
146
- void ADCSensor::update() {
147
- float value_v = this->sample();
148
- ESP_LOGV(TAG, "'%s': Got voltage=%.4fV", this->get_name().c_str(), value_v);
149
- this->publish_state(value_v);
150
- }
151
-
152
- void ADCSensor::set_sample_count(uint8_t sample_count) {
153
- if (sample_count != 0) {
154
- this->sample_count_ = sample_count;
155
- }
156
- }
157
-
158
- #ifdef USE_ESP8266
159
- float ADCSensor::sample() {
160
- uint32_t raw = 0;
161
- for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
162
- #ifdef USE_ADC_SENSOR_VCC
163
- raw += ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance)
164
- #else
165
- raw += analogRead(this->pin_->get_pin()); // NOLINT
166
- #endif
167
- }
168
- raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
169
- if (this->output_raw_) {
170
- return raw;
171
- }
172
- return raw / 1024.0f;
173
- }
174
- #endif
175
-
176
- #ifdef USE_ESP32
177
84
  float ADCSensor::sample() {
178
85
  if (!this->autorange_) {
179
86
  uint32_t sum = 0;
@@ -240,93 +147,17 @@ float ADCSensor::sample() {
240
147
  uint32_t mv2 = esp_adc_cal_raw_to_voltage(raw2, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_2_5]);
241
148
  uint32_t mv0 = esp_adc_cal_raw_to_voltage(raw0, &this->cal_characteristics_[(int32_t) ADC_ATTEN_DB_0]);
242
149
 
243
- // Contribution of each value, in range 0-2048 (12 bit ADC) or 0-4096 (13 bit ADC)
244
150
  uint32_t c12 = std::min(raw12, ADC_HALF);
245
151
  uint32_t c6 = ADC_HALF - std::abs(raw6 - ADC_HALF);
246
152
  uint32_t c2 = ADC_HALF - std::abs(raw2 - ADC_HALF);
247
153
  uint32_t c0 = std::min(ADC_MAX - raw0, ADC_HALF);
248
- // max theoretical csum value is 4096*4 = 16384
249
154
  uint32_t csum = c12 + c6 + c2 + c0;
250
155
 
251
- // each mv is max 3900; so max value is 3900*4096*4, fits in unsigned32
252
156
  uint32_t mv_scaled = (mv12 * c12) + (mv6 * c6) + (mv2 * c2) + (mv0 * c0);
253
157
  return mv_scaled / (float) (csum * 1000U);
254
158
  }
255
- #endif // USE_ESP32
256
-
257
- #ifdef USE_RP2040
258
- float ADCSensor::sample() {
259
- if (this->is_temperature_) {
260
- adc_set_temp_sensor_enabled(true);
261
- delay(1);
262
- adc_select_input(4);
263
- uint32_t raw = 0;
264
- for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
265
- raw += adc_read();
266
- }
267
- raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
268
- adc_set_temp_sensor_enabled(false);
269
- if (this->output_raw_) {
270
- return raw;
271
- }
272
- return raw * 3.3f / 4096.0f;
273
- } else {
274
- uint8_t pin = this->pin_->get_pin();
275
- #ifdef CYW43_USES_VSYS_PIN
276
- if (pin == PICO_VSYS_PIN) {
277
- // Measuring VSYS on Raspberry Pico W needs to be wrapped with
278
- // `cyw43_thread_enter()`/`cyw43_thread_exit()` as discussed in
279
- // https://github.com/raspberrypi/pico-sdk/issues/1222, since Wifi chip and
280
- // VSYS ADC both share GPIO29
281
- cyw43_thread_enter();
282
- }
283
- #endif // CYW43_USES_VSYS_PIN
284
-
285
- adc_gpio_init(pin);
286
- adc_select_input(pin - 26);
287
-
288
- uint32_t raw = 0;
289
- for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
290
- raw += adc_read();
291
- }
292
- raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
293
-
294
- #ifdef CYW43_USES_VSYS_PIN
295
- if (pin == PICO_VSYS_PIN) {
296
- cyw43_thread_exit();
297
- }
298
- #endif // CYW43_USES_VSYS_PIN
299
-
300
- if (this->output_raw_) {
301
- return raw;
302
- }
303
- float coeff = pin == PICO_VSYS_PIN ? 3.0 : 1.0;
304
- return raw * 3.3f / 4096.0f * coeff;
305
- }
306
- }
307
- #endif
308
-
309
- #ifdef USE_LIBRETINY
310
- float ADCSensor::sample() {
311
- uint32_t raw = 0;
312
- if (this->output_raw_) {
313
- for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
314
- raw += analogRead(this->pin_->get_pin()); // NOLINT
315
- }
316
- raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
317
- return raw;
318
- }
319
- for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
320
- raw += analogReadVoltage(this->pin_->get_pin()); // NOLINT
321
- }
322
- raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
323
- return raw / 1000.0f;
324
- }
325
- #endif // USE_LIBRETINY
326
-
327
- #ifdef USE_ESP8266
328
- std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; }
329
- #endif
330
159
 
331
160
  } // namespace adc
332
161
  } // namespace esphome
162
+
163
+ #endif // USE_ESP32
@@ -0,0 +1,58 @@
1
+ #ifdef USE_ESP8266
2
+
3
+ #include "adc_sensor.h"
4
+ #include "esphome/core/helpers.h"
5
+ #include "esphome/core/log.h"
6
+
7
+ #ifdef USE_ADC_SENSOR_VCC
8
+ #include <Esp.h>
9
+ ADC_MODE(ADC_VCC)
10
+ #else
11
+ #include <Arduino.h>
12
+ #endif // USE_ADC_SENSOR_VCC
13
+
14
+ namespace esphome {
15
+ namespace adc {
16
+
17
+ static const char *const TAG = "adc.esp8266";
18
+
19
+ void ADCSensor::setup() {
20
+ ESP_LOGCONFIG(TAG, "Setting up ADC '%s'...", this->get_name().c_str());
21
+ #ifndef USE_ADC_SENSOR_VCC
22
+ this->pin_->setup();
23
+ #endif
24
+ }
25
+
26
+ void ADCSensor::dump_config() {
27
+ LOG_SENSOR("", "ADC Sensor", this);
28
+ #ifdef USE_ADC_SENSOR_VCC
29
+ ESP_LOGCONFIG(TAG, " Pin: VCC");
30
+ #else
31
+ LOG_PIN(" Pin: ", this->pin_);
32
+ #endif // USE_ADC_SENSOR_VCC
33
+ ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
34
+ LOG_UPDATE_INTERVAL(this);
35
+ }
36
+
37
+ float ADCSensor::sample() {
38
+ uint32_t raw = 0;
39
+ for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
40
+ #ifdef USE_ADC_SENSOR_VCC
41
+ raw += ESP.getVcc(); // NOLINT(readability-static-accessed-through-instance)
42
+ #else
43
+ raw += analogRead(this->pin_->get_pin()); // NOLINT
44
+ #endif // USE_ADC_SENSOR_VCC
45
+ }
46
+ raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
47
+ if (this->output_raw_) {
48
+ return raw;
49
+ }
50
+ return raw / 1024.0f;
51
+ }
52
+
53
+ std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; }
54
+
55
+ } // namespace adc
56
+ } // namespace esphome
57
+
58
+ #endif // USE_ESP8266
@@ -0,0 +1,48 @@
1
+ #ifdef USE_LIBRETINY
2
+
3
+ #include "adc_sensor.h"
4
+ #include "esphome/core/log.h"
5
+
6
+ namespace esphome {
7
+ namespace adc {
8
+
9
+ static const char *const TAG = "adc.libretiny";
10
+
11
+ void ADCSensor::setup() {
12
+ ESP_LOGCONFIG(TAG, "Setting up ADC '%s'...", this->get_name().c_str());
13
+ #ifndef USE_ADC_SENSOR_VCC
14
+ this->pin_->setup();
15
+ #endif // !USE_ADC_SENSOR_VCC
16
+ }
17
+
18
+ void ADCSensor::dump_config() {
19
+ LOG_SENSOR("", "ADC Sensor", this);
20
+ #ifdef USE_ADC_SENSOR_VCC
21
+ ESP_LOGCONFIG(TAG, " Pin: VCC");
22
+ #else // USE_ADC_SENSOR_VCC
23
+ LOG_PIN(" Pin: ", this->pin_);
24
+ #endif // USE_ADC_SENSOR_VCC
25
+ ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
26
+ LOG_UPDATE_INTERVAL(this);
27
+ }
28
+
29
+ float ADCSensor::sample() {
30
+ uint32_t raw = 0;
31
+ if (this->output_raw_) {
32
+ for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
33
+ raw += analogRead(this->pin_->get_pin()); // NOLINT
34
+ }
35
+ raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
36
+ return raw;
37
+ }
38
+ for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
39
+ raw += analogReadVoltage(this->pin_->get_pin()); // NOLINT
40
+ }
41
+ raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
42
+ return raw / 1000.0f;
43
+ }
44
+
45
+ } // namespace adc
46
+ } // namespace esphome
47
+
48
+ #endif // USE_LIBRETINY
@@ -0,0 +1,93 @@
1
+ #ifdef USE_RP2040
2
+
3
+ #include "adc_sensor.h"
4
+ #include "esphome/core/log.h"
5
+
6
+ #ifdef CYW43_USES_VSYS_PIN
7
+ #include "pico/cyw43_arch.h"
8
+ #endif // CYW43_USES_VSYS_PIN
9
+ #include <hardware/adc.h>
10
+
11
+ namespace esphome {
12
+ namespace adc {
13
+
14
+ static const char *const TAG = "adc.rp2040";
15
+
16
+ void ADCSensor::setup() {
17
+ ESP_LOGCONFIG(TAG, "Setting up ADC '%s'...", this->get_name().c_str());
18
+ static bool initialized = false;
19
+ if (!initialized) {
20
+ adc_init();
21
+ initialized = true;
22
+ }
23
+ }
24
+
25
+ void ADCSensor::dump_config() {
26
+ LOG_SENSOR("", "ADC Sensor", this);
27
+ if (this->is_temperature_) {
28
+ ESP_LOGCONFIG(TAG, " Pin: Temperature");
29
+ } else {
30
+ #ifdef USE_ADC_SENSOR_VCC
31
+ ESP_LOGCONFIG(TAG, " Pin: VCC");
32
+ #else
33
+ LOG_PIN(" Pin: ", this->pin_);
34
+ #endif // USE_ADC_SENSOR_VCC
35
+ }
36
+ ESP_LOGCONFIG(TAG, " Samples: %i", this->sample_count_);
37
+ LOG_UPDATE_INTERVAL(this);
38
+ }
39
+
40
+ float ADCSensor::sample() {
41
+ if (this->is_temperature_) {
42
+ adc_set_temp_sensor_enabled(true);
43
+ delay(1);
44
+ adc_select_input(4);
45
+ uint32_t raw = 0;
46
+ for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
47
+ raw += adc_read();
48
+ }
49
+ raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
50
+ adc_set_temp_sensor_enabled(false);
51
+ if (this->output_raw_) {
52
+ return raw;
53
+ }
54
+ return raw * 3.3f / 4096.0f;
55
+ }
56
+
57
+ uint8_t pin = this->pin_->get_pin();
58
+ #ifdef CYW43_USES_VSYS_PIN
59
+ if (pin == PICO_VSYS_PIN) {
60
+ // Measuring VSYS on Raspberry Pico W needs to be wrapped with
61
+ // `cyw43_thread_enter()`/`cyw43_thread_exit()` as discussed in
62
+ // https://github.com/raspberrypi/pico-sdk/issues/1222, since Wifi chip and
63
+ // VSYS ADC both share GPIO29
64
+ cyw43_thread_enter();
65
+ }
66
+ #endif // CYW43_USES_VSYS_PIN
67
+
68
+ adc_gpio_init(pin);
69
+ adc_select_input(pin - 26);
70
+
71
+ uint32_t raw = 0;
72
+ for (uint8_t sample = 0; sample < this->sample_count_; sample++) {
73
+ raw += adc_read();
74
+ }
75
+ raw = (raw + (this->sample_count_ >> 1)) / this->sample_count_; // NOLINT(clang-analyzer-core.DivideZero)
76
+
77
+ #ifdef CYW43_USES_VSYS_PIN
78
+ if (pin == PICO_VSYS_PIN) {
79
+ cyw43_thread_exit();
80
+ }
81
+ #endif // CYW43_USES_VSYS_PIN
82
+
83
+ if (this->output_raw_) {
84
+ return raw;
85
+ }
86
+ float coeff = pin == PICO_VSYS_PIN ? 3.0f : 1.0f;
87
+ return raw * 3.3f / 4096.0f * coeff;
88
+ }
89
+
90
+ } // namespace adc
91
+ } // namespace esphome
92
+
93
+ #endif // USE_RP2040
@@ -72,10 +72,9 @@ void AlarmControlPanelCall::validate_() {
72
72
  this->state_.reset();
73
73
  return;
74
74
  }
75
- if (state == ACP_STATE_DISARMED &&
76
- !(this->parent_->is_state_armed(this->parent_->get_state()) ||
77
- this->parent_->get_state() == ACP_STATE_PENDING || this->parent_->get_state() == ACP_STATE_ARMING ||
78
- this->parent_->get_state() == ACP_STATE_TRIGGERED)) {
75
+ if (state == ACP_STATE_DISARMED && !this->parent_->is_state_armed(this->parent_->get_state()) &&
76
+ this->parent_->get_state() != ACP_STATE_PENDING && this->parent_->get_state() != ACP_STATE_ARMING &&
77
+ this->parent_->get_state() != ACP_STATE_TRIGGERED) {
79
78
  ESP_LOGW(TAG, "Cannot disarm when not armed");
80
79
  this->state_.reset();
81
80
  return;
@@ -2,7 +2,6 @@ import logging
2
2
 
3
3
  from esphome import automation, core
4
4
  import esphome.codegen as cg
5
- from esphome.components import font
6
5
  import esphome.components.image as espImage
7
6
  from esphome.components.image import (
8
7
  CONF_USE_TRANSPARENCY,
@@ -131,7 +130,7 @@ ANIMATION_SCHEMA = cv.Schema(
131
130
  )
132
131
  )
133
132
 
134
- CONFIG_SCHEMA = cv.All(font.validate_pillow_installed, ANIMATION_SCHEMA)
133
+ CONFIG_SCHEMA = ANIMATION_SCHEMA
135
134
 
136
135
  NEXT_FRAME_SCHEMA = automation.maybe_simple_id(
137
136
  {
@@ -122,7 +122,8 @@ void APDS9306::update() {
122
122
 
123
123
  this->status_clear_warning();
124
124
 
125
- if (!(status &= 0b00001000)) { // No new data
125
+ status &= 0b00001000;
126
+ if (!status) { // No new data
126
127
  return;
127
128
  }
128
129
 
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
 
3
+ #include <cstddef>
3
4
  #include <cstdint>
4
- #include <stddef.h>
5
5
 
6
6
  namespace esphome {
7
7
  namespace audio {
@@ -15,7 +15,7 @@ from esphome.components.libretiny.const import (
15
15
  )
16
16
  from esphome.core import CORE
17
17
 
18
- from .boards import BK72XX_BOARDS, BK72XX_BOARD_PINS
18
+ from .boards import BK72XX_BOARD_PINS, BK72XX_BOARDS
19
19
 
20
20
  CODEOWNERS = ["@kuba2k2"]
21
21
  AUTO_LOAD = ["libretiny"]
@@ -43,7 +43,7 @@ bool CSE7766Component::check_byte_() {
43
43
  uint8_t index = this->raw_data_index_;
44
44
  uint8_t byte = this->raw_data_[index];
45
45
  if (index == 0) {
46
- return !((byte != 0x55) && ((byte & 0xF0) != 0xF0) && (byte != 0xAA));
46
+ return (byte == 0x55) || ((byte & 0xF0) == 0xF0) || (byte == 0xAA);
47
47
  }
48
48
 
49
49
  if (index == 1) {
@@ -52,11 +52,11 @@ void DeepSleepComponent::dump_config_platform_() {
52
52
 
53
53
  bool DeepSleepComponent::prepare_to_sleep_() {
54
54
  if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_KEEP_AWAKE && this->wakeup_pin_ != nullptr &&
55
- !this->sleep_duration_.has_value() && this->wakeup_pin_->digital_read()) {
55
+ this->wakeup_pin_->digital_read()) {
56
56
  // Defer deep sleep until inactive
57
57
  if (!this->next_enter_deep_sleep_) {
58
58
  this->status_set_warning();
59
- ESP_LOGW(TAG, "Waiting for pin_ to switch state to enter deep sleep...");
59
+ ESP_LOGW(TAG, "Waiting wakeup pin state change to enter deep sleep...");
60
60
  }
61
61
  this->next_enter_deep_sleep_ = true;
62
62
  return false;
@@ -135,7 +135,8 @@ bool HOT IRAM_ATTR DHT::read_sensor_(float *temperature, float *humidity, bool r
135
135
 
136
136
  // Wait for falling edge
137
137
  while (this->pin_->digital_read()) {
138
- if ((end_time = micros()) - start_time > 90) {
138
+ end_time = micros();
139
+ if (end_time - start_time > 90) {
139
140
  if (i < 0) {
140
141
  error_code = 3;
141
142
  } else {
@@ -1,6 +1,6 @@
1
1
  #include "display.h"
2
- #include "display_color_utils.h"
3
2
  #include <utility>
3
+ #include "display_color_utils.h"
4
4
  #include "esphome/core/hal.h"
5
5
  #include "esphome/core/log.h"
6
6
 
@@ -662,20 +662,24 @@ void DisplayOnPageChangeTrigger::process(DisplayPage *from, DisplayPage *to) {
662
662
  if ((this->from_ == nullptr || this->from_ == from) && (this->to_ == nullptr || this->to_ == to))
663
663
  this->trigger(from, to);
664
664
  }
665
- void Display::strftime(int x, int y, BaseFont *font, Color color, TextAlign align, const char *format, ESPTime time) {
665
+ void Display::strftime(int x, int y, BaseFont *font, Color color, Color background, TextAlign align, const char *format,
666
+ ESPTime time) {
666
667
  char buffer[64];
667
668
  size_t ret = time.strftime(buffer, sizeof(buffer), format);
668
669
  if (ret > 0)
669
- this->print(x, y, font, color, align, buffer);
670
+ this->print(x, y, font, color, align, buffer, background);
671
+ }
672
+ void Display::strftime(int x, int y, BaseFont *font, Color color, TextAlign align, const char *format, ESPTime time) {
673
+ this->strftime(x, y, font, color, COLOR_OFF, align, format, time);
670
674
  }
671
675
  void Display::strftime(int x, int y, BaseFont *font, Color color, const char *format, ESPTime time) {
672
- this->strftime(x, y, font, color, TextAlign::TOP_LEFT, format, time);
676
+ this->strftime(x, y, font, color, COLOR_OFF, TextAlign::TOP_LEFT, format, time);
673
677
  }
674
678
  void Display::strftime(int x, int y, BaseFont *font, TextAlign align, const char *format, ESPTime time) {
675
- this->strftime(x, y, font, COLOR_ON, align, format, time);
679
+ this->strftime(x, y, font, COLOR_ON, COLOR_OFF, align, format, time);
676
680
  }
677
681
  void Display::strftime(int x, int y, BaseFont *font, const char *format, ESPTime time) {
678
- this->strftime(x, y, font, COLOR_ON, TextAlign::TOP_LEFT, format, time);
682
+ this->strftime(x, y, font, COLOR_ON, COLOR_OFF, TextAlign::TOP_LEFT, format, time);
679
683
  }
680
684
 
681
685
  void Display::start_clipping(Rect rect) {