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.
Files changed (102) hide show
  1. esphome/components/aht10/aht10.cpp +4 -2
  2. esphome/components/climate/climate.cpp +10 -6
  3. esphome/components/climate/climate_traits.h +3 -3
  4. esphome/components/cover/cover.h +2 -2
  5. esphome/components/esp32_camera/__init__.py +6 -3
  6. esphome/components/esp32_can/canbus.py +3 -0
  7. esphome/components/ethernet/ethernet_component.cpp +8 -3
  8. esphome/components/font/__init__.py +2 -28
  9. esphome/components/gree/climate.py +1 -0
  10. esphome/components/gree/gree.cpp +11 -3
  11. esphome/components/gree/gree.h +5 -1
  12. esphome/components/haier/binary_sensor/__init__.py +4 -4
  13. esphome/components/haier/button/__init__.py +1 -1
  14. esphome/components/haier/climate.py +43 -9
  15. esphome/components/haier/haier_base.cpp +4 -0
  16. esphome/components/haier/haier_base.h +11 -1
  17. esphome/components/haier/hon_climate.cpp +109 -55
  18. esphome/components/haier/hon_climate.h +7 -1
  19. esphome/components/haier/hon_packet.h +5 -0
  20. esphome/components/haier/sensor/__init__.py +5 -5
  21. esphome/components/haier/smartair2_climate.cpp +1 -0
  22. esphome/components/haier/text_sensor/__init__.py +4 -4
  23. esphome/components/heatpumpir/climate.py +12 -5
  24. esphome/components/heatpumpir/heatpumpir.cpp +11 -0
  25. esphome/components/heatpumpir/heatpumpir.h +11 -0
  26. esphome/components/http_request/http_request_arduino.cpp +7 -2
  27. esphome/components/http_request/update/http_request_update.cpp +6 -7
  28. esphome/components/http_request/update/http_request_update.h +0 -3
  29. esphome/components/i2s_audio/__init__.py +10 -0
  30. esphome/components/i2s_audio/microphone/__init__.py +7 -0
  31. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +2 -3
  32. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +3 -0
  33. esphome/components/image/__init__.py +2 -29
  34. esphome/components/improv_serial/improv_serial_component.cpp +9 -8
  35. esphome/components/ltr390/ltr390.cpp +44 -29
  36. esphome/components/ltr390/ltr390.h +9 -5
  37. esphome/components/ltr390/sensor.py +35 -5
  38. esphome/components/mdns/__init__.py +3 -3
  39. esphome/components/mdns/mdns_component.cpp +3 -1
  40. esphome/components/mdns/mdns_component.h +3 -1
  41. esphome/components/mdns/mdns_esp32.cpp +2 -1
  42. esphome/components/mdns/mdns_esp8266.cpp +2 -1
  43. esphome/components/mdns/mdns_host.cpp +2 -1
  44. esphome/components/mdns/mdns_libretiny.cpp +2 -1
  45. esphome/components/mdns/mdns_rp2040.cpp +2 -1
  46. esphome/components/micro_wake_word/__init__.py +205 -56
  47. esphome/components/micro_wake_word/micro_wake_word.cpp +225 -275
  48. esphome/components/micro_wake_word/micro_wake_word.h +77 -107
  49. esphome/components/micro_wake_word/preprocessor_settings.h +20 -0
  50. esphome/components/micro_wake_word/streaming_model.cpp +189 -0
  51. esphome/components/micro_wake_word/streaming_model.h +84 -0
  52. esphome/components/mitsubishi/mitsubishi.cpp +1 -0
  53. esphome/components/modbus_controller/text_sensor/__init__.py +2 -1
  54. esphome/components/modbus_controller/text_sensor/modbus_textsensor.cpp +4 -1
  55. esphome/components/modbus_controller/text_sensor/modbus_textsensor.h +1 -1
  56. esphome/components/number/__init__.py +2 -0
  57. esphome/components/ota/ota_backend_arduino_esp32.cpp +22 -7
  58. esphome/components/ota/ota_backend_arduino_esp8266.cpp +23 -8
  59. esphome/components/ota/ota_backend_arduino_libretiny.cpp +22 -7
  60. esphome/components/ota/ota_backend_arduino_rp2040.cpp +22 -7
  61. esphome/components/pmsa003i/pmsa003i.cpp +9 -0
  62. esphome/components/qspi_amoled/display.py +16 -4
  63. esphome/components/qspi_amoled/qspi_amoled.cpp +16 -0
  64. esphome/components/qspi_amoled/qspi_amoled.h +0 -3
  65. esphome/components/remote_base/dooya_protocol.cpp +4 -4
  66. esphome/components/remote_base/rc_switch_protocol.cpp +1 -1
  67. esphome/components/restart/button/__init__.py +2 -0
  68. esphome/components/script/__init__.py +1 -1
  69. esphome/components/sensor/__init__.py +2 -0
  70. esphome/components/tuya/tuya.cpp +8 -2
  71. esphome/components/tuya/tuya.h +3 -1
  72. esphome/components/uart/__init__.py +72 -9
  73. esphome/components/uart/uart_component_esp32_arduino.cpp +18 -4
  74. esphome/components/uart/uart_component_esp_idf.cpp +22 -2
  75. esphome/components/uart/uart_component_host.cpp +295 -0
  76. esphome/components/uart/uart_component_host.h +38 -0
  77. esphome/components/uptime/sensor.py +44 -11
  78. esphome/components/uptime/{uptime_sensor.cpp → uptime_seconds_sensor.cpp} +11 -7
  79. esphome/components/uptime/{uptime_sensor.h → uptime_seconds_sensor.h} +2 -2
  80. esphome/components/uptime/uptime_timestamp_sensor.cpp +39 -0
  81. esphome/components/uptime/uptime_timestamp_sensor.h +30 -0
  82. esphome/components/veml7700/veml7700.cpp +1 -1
  83. esphome/components/veml7700/veml7700.h +5 -5
  84. esphome/components/voice_assistant/voice_assistant.cpp +4 -2
  85. esphome/components/web_server/server_index_v2.h +42 -41
  86. esphome/components/web_server/server_index_v3.h +368 -367
  87. esphome/components/wifi/wifi_component_esp_idf.cpp +1 -1
  88. esphome/components/wifi/wifi_component_pico_w.cpp +18 -2
  89. esphome/components/wireguard/__init__.py +1 -1
  90. esphome/components/x9c/output.py +7 -1
  91. esphome/const.py +2 -1
  92. esphome/core/defines.h +1 -0
  93. esphome/core/helpers.cpp +2 -2
  94. esphome/core/helpers.h +1 -1
  95. esphome/external_files.py +26 -0
  96. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/METADATA +1 -1
  97. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/RECORD +101 -95
  98. esphome/components/micro_wake_word/audio_preprocessor_int8_model_data.h +0 -493
  99. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/LICENSE +0 -0
  100. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/WHEEL +0 -0
  101. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/entry_points.txt +0 -0
  102. {esphome-2024.6.6.dist-info → esphome-2024.7.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,6 @@ import hashlib
6
6
  import io
7
7
  from pathlib import Path
8
8
  import re
9
- import requests
10
9
  from magic import Magic
11
10
 
12
11
  from esphome import core
@@ -15,7 +14,6 @@ from esphome import external_files
15
14
  import esphome.config_validation as cv
16
15
  import esphome.codegen as cg
17
16
  from esphome.const import (
18
- __version__,
19
17
  CONF_DITHER,
20
18
  CONF_FILE,
21
19
  CONF_ICON,
@@ -75,31 +73,6 @@ def compute_local_image_path(value: dict) -> Path:
75
73
  return base_dir / key
76
74
 
77
75
 
78
- def download_content(url: str, path: Path) -> None:
79
- if not external_files.has_remote_file_changed(url, path):
80
- _LOGGER.debug("Remote file has not changed %s", url)
81
- return
82
-
83
- _LOGGER.debug(
84
- "Remote file has changed, downloading from %s to %s",
85
- url,
86
- path,
87
- )
88
-
89
- try:
90
- req = requests.get(
91
- url,
92
- timeout=IMAGE_DOWNLOAD_TIMEOUT,
93
- headers={"User-agent": f"ESPHome/{__version__} (https://esphome.io)"},
94
- )
95
- req.raise_for_status()
96
- except requests.exceptions.RequestException as e:
97
- raise cv.Invalid(f"Could not download from {url}: {e}")
98
-
99
- path.parent.mkdir(parents=True, exist_ok=True)
100
- path.write_bytes(req.content)
101
-
102
-
103
76
  def download_mdi(value):
104
77
  validate_cairosvg_installed(value)
105
78
 
@@ -108,7 +81,7 @@ def download_mdi(value):
108
81
 
109
82
  url = f"https://raw.githubusercontent.com/Templarian/MaterialDesign/master/svg/{mdi_id}.svg"
110
83
 
111
- download_content(url, path)
84
+ external_files.download_content(url, path, IMAGE_DOWNLOAD_TIMEOUT)
112
85
 
113
86
  return value
114
87
 
@@ -117,7 +90,7 @@ def download_image(value):
117
90
  url = value[CONF_URL]
118
91
  path = compute_local_image_path(value)
119
92
 
120
- download_content(url, path)
93
+ external_files.download_content(url, path, IMAGE_DOWNLOAD_TIMEOUT)
121
94
 
122
95
  return value
123
96
 
@@ -57,7 +57,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
57
57
  }
58
58
  }
59
59
  break;
60
- #if defined(CONFIG_ESP_CONSOLE_USB_CDC) && (defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3))
60
+ #if defined(USE_LOGGER_USB_CDC) && defined(CONFIG_ESP_CONSOLE_USB_CDC)
61
61
  case logger::UART_SELECTION_USB_CDC:
62
62
  #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
63
63
  if (esp_usb_console_available_for_read()) {
@@ -68,15 +68,15 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
68
68
  byte = data;
69
69
  }
70
70
  break;
71
- #endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
72
- #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
71
+ #endif // USE_LOGGER_USB_CDC
72
+ #ifdef USE_LOGGER_USB_SERIAL_JTAG
73
73
  case logger::UART_SELECTION_USB_SERIAL_JTAG: {
74
74
  if (usb_serial_jtag_read_bytes((char *) &data, 1, 0)) {
75
75
  byte = data;
76
76
  }
77
77
  break;
78
78
  }
79
- #endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32C6 || USE_ESP32_VARIANT_ESP32S3
79
+ #endif // USE_LOGGER_USB_SERIAL_JTAG
80
80
  default:
81
81
  break;
82
82
  }
@@ -99,19 +99,20 @@ void ImprovSerialComponent::write_data_(std::vector<uint8_t> &data) {
99
99
  #endif // !USE_ESP32_VARIANT_ESP32C3 && !USE_ESP32_VARIANT_ESP32S2 && !USE_ESP32_VARIANT_ESP32S3
100
100
  uart_write_bytes(this->uart_num_, data.data(), data.size());
101
101
  break;
102
- #if defined(CONFIG_ESP_CONSOLE_USB_CDC) && (defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3))
102
+ #if defined(USE_LOGGER_USB_CDC) && defined(CONFIG_ESP_CONSOLE_USB_CDC)
103
103
  case logger::UART_SELECTION_USB_CDC: {
104
104
  const char *msg = (char *) data.data();
105
105
  esp_usb_console_write_buf(msg, data.size());
106
106
  break;
107
107
  }
108
- #endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
109
- #if defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S3)
108
+ #endif // USE_LOGGER_USB_CDC
109
+ #ifdef USE_LOGGER_USB_SERIAL_JTAG
110
110
  case logger::UART_SELECTION_USB_SERIAL_JTAG:
111
111
  usb_serial_jtag_write_bytes((char *) data.data(), data.size(), 20 / portTICK_PERIOD_MS);
112
+ delay(10);
112
113
  usb_serial_jtag_ll_txfifo_flush(); // fixes for issue in IDF 4.4.7
113
114
  break;
114
- #endif // USE_ESP32_VARIANT_ESP32C3 || USE_ESP32_VARIANT_ESP32S3
115
+ #endif // USE_LOGGER_USB_SERIAL_JTAG
115
116
  default:
116
117
  break;
117
118
  }
@@ -19,6 +19,7 @@ static const uint8_t LTR390_MAIN_STATUS = 0x07;
19
19
 
20
20
  static const float GAINVALUES[5] = {1.0, 3.0, 6.0, 9.0, 18.0};
21
21
  static const float RESOLUTIONVALUE[6] = {4.0, 2.0, 1.0, 0.5, 0.25, 0.125};
22
+ static const uint8_t RESOLUTION_BITS[6] = {20, 19, 18, 17, 16, 13};
22
23
 
23
24
  // Request fastest measurement rate - will be slowed by device if conversion rate is slower.
24
25
  static const float RESOLUTION_SETTING[6] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50};
@@ -74,7 +75,7 @@ void LTR390Component::read_als_() {
74
75
  uint32_t als = *val;
75
76
 
76
77
  if (this->light_sensor_ != nullptr) {
77
- float lux = ((0.6 * als) / (GAINVALUES[this->gain_] * RESOLUTIONVALUE[this->res_])) * this->wfac_;
78
+ float lux = ((0.6 * als) / (GAINVALUES[this->gain_als_] * RESOLUTIONVALUE[this->res_als_])) * this->wfac_;
78
79
  this->light_sensor_->publish_state(lux);
79
80
  }
80
81
 
@@ -90,7 +91,7 @@ void LTR390Component::read_uvs_() {
90
91
  uint32_t uv = *val;
91
92
 
92
93
  if (this->uvi_sensor_ != nullptr) {
93
- this->uvi_sensor_->publish_state((uv / this->sensitivity_) * this->wfac_);
94
+ this->uvi_sensor_->publish_state((uv / this->sensitivity_uv_) * this->wfac_);
94
95
  }
95
96
 
96
97
  if (this->uv_sensor_ != nullptr) {
@@ -107,24 +108,38 @@ void LTR390Component::read_mode_(int mode_index) {
107
108
  ctrl[LTR390_CTRL_EN] = true;
108
109
  this->reg(LTR390_MAIN_CTRL) = ctrl.to_ulong();
109
110
 
111
+ uint32_t int_time{0};
112
+ // Set gain, resolution and measurement rate
113
+ switch (mode) {
114
+ case LTR390_MODE_ALS:
115
+ this->reg(LTR390_GAIN) = this->gain_als_;
116
+ this->reg(LTR390_MEAS_RATE) = RESOLUTION_SETTING[this->res_als_];
117
+ int_time = ((uint32_t) RESOLUTIONVALUE[this->res_als_]) * 100;
118
+ break;
119
+ case LTR390_MODE_UVS:
120
+ this->reg(LTR390_GAIN) = this->gain_uv_;
121
+ this->reg(LTR390_MEAS_RATE) = RESOLUTION_SETTING[this->res_uv_];
122
+ int_time = ((uint32_t) RESOLUTIONVALUE[this->res_uv_]) * 100;
123
+ break;
124
+ }
125
+
110
126
  // After the sensor integration time do the following
111
- this->set_timeout(((uint32_t) RESOLUTIONVALUE[this->res_]) * 100 + LTR390_WAKEUP_TIME + LTR390_SETTLE_TIME,
112
- [this, mode_index]() {
113
- // Read from the sensor
114
- std::get<1>(this->mode_funcs_[mode_index])();
115
-
116
- // If there are more modes to read then begin the next
117
- // otherwise stop
118
- if (mode_index + 1 < (int) this->mode_funcs_.size()) {
119
- this->read_mode_(mode_index + 1);
120
- } else {
121
- // put sensor in standby
122
- std::bitset<8> ctrl = this->reg(LTR390_MAIN_CTRL).get();
123
- ctrl[LTR390_CTRL_EN] = false;
124
- this->reg(LTR390_MAIN_CTRL) = ctrl.to_ulong();
125
- this->reading_ = false;
126
- }
127
- });
127
+ this->set_timeout(int_time + LTR390_WAKEUP_TIME + LTR390_SETTLE_TIME, [this, mode_index]() {
128
+ // Read from the sensor
129
+ std::get<1>(this->mode_funcs_[mode_index])();
130
+
131
+ // If there are more modes to read then begin the next
132
+ // otherwise stop
133
+ if (mode_index + 1 < (int) this->mode_funcs_.size()) {
134
+ this->read_mode_(mode_index + 1);
135
+ } else {
136
+ // put sensor in standby
137
+ std::bitset<8> ctrl = this->reg(LTR390_MAIN_CTRL).get();
138
+ ctrl[LTR390_CTRL_EN] = false;
139
+ this->reg(LTR390_MAIN_CTRL) = ctrl.to_ulong();
140
+ this->reading_ = false;
141
+ }
142
+ });
128
143
  }
129
144
 
130
145
  void LTR390Component::setup() {
@@ -151,16 +166,10 @@ void LTR390Component::setup() {
151
166
  return;
152
167
  }
153
168
 
154
- // Set gain
155
- this->reg(LTR390_GAIN) = gain_;
156
-
157
- // Set resolution and measurement rate
158
- this->reg(LTR390_MEAS_RATE) = RESOLUTION_SETTING[this->res_];
159
-
160
169
  // Set sensitivity by linearly scaling against known value in the datasheet
161
- float gain_scale = GAINVALUES[this->gain_] / GAIN_MAX;
162
- float intg_scale = (RESOLUTIONVALUE[this->res_] * 100) / INTG_MAX;
163
- this->sensitivity_ = SENSITIVITY_MAX * gain_scale * intg_scale;
170
+ float gain_scale_uv = GAINVALUES[this->gain_uv_] / GAIN_MAX;
171
+ float intg_scale_uv = (RESOLUTIONVALUE[this->res_uv_] * 100) / INTG_MAX;
172
+ this->sensitivity_uv_ = SENSITIVITY_MAX * gain_scale_uv * intg_scale_uv;
164
173
 
165
174
  // Set sensor read state
166
175
  this->reading_ = false;
@@ -176,7 +185,13 @@ void LTR390Component::setup() {
176
185
  }
177
186
  }
178
187
 
179
- void LTR390Component::dump_config() { LOG_I2C_DEVICE(this); }
188
+ void LTR390Component::dump_config() {
189
+ LOG_I2C_DEVICE(this);
190
+ ESP_LOGCONFIG(TAG, " ALS Gain: X%.0f", GAINVALUES[this->gain_als_]);
191
+ ESP_LOGCONFIG(TAG, " ALS Resolution: %u-bit", RESOLUTION_BITS[this->res_als_]);
192
+ ESP_LOGCONFIG(TAG, " UV Gain: X%.0f", GAINVALUES[this->gain_uv_]);
193
+ ESP_LOGCONFIG(TAG, " UV Resolution: %u-bit", RESOLUTION_BITS[this->res_uv_]);
194
+ }
180
195
 
181
196
  void LTR390Component::update() {
182
197
  if (!this->reading_ && !mode_funcs_.empty()) {
@@ -49,8 +49,10 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice {
49
49
  void dump_config() override;
50
50
  void update() override;
51
51
 
52
- void set_gain_value(LTR390GAIN gain) { this->gain_ = gain; }
53
- void set_res_value(LTR390RESOLUTION res) { this->res_ = res; }
52
+ void set_als_gain_value(LTR390GAIN gain) { this->gain_als_ = gain; }
53
+ void set_uv_gain_value(LTR390GAIN gain) { this->gain_uv_ = gain; }
54
+ void set_als_res_value(LTR390RESOLUTION res) { this->res_als_ = res; }
55
+ void set_uv_res_value(LTR390RESOLUTION res) { this->res_uv_ = res; }
54
56
  void set_wfac_value(float wfac) { this->wfac_ = wfac; }
55
57
 
56
58
  void set_light_sensor(sensor::Sensor *light_sensor) { this->light_sensor_ = light_sensor; }
@@ -71,9 +73,11 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice {
71
73
  // a list of modes and corresponding read functions
72
74
  std::vector<std::tuple<LTR390MODE, std::function<void()>>> mode_funcs_;
73
75
 
74
- LTR390GAIN gain_;
75
- LTR390RESOLUTION res_;
76
- float sensitivity_;
76
+ LTR390GAIN gain_als_;
77
+ LTR390GAIN gain_uv_;
78
+ LTR390RESOLUTION res_als_;
79
+ LTR390RESOLUTION res_uv_;
80
+ float sensitivity_uv_;
77
81
  float wfac_;
78
82
 
79
83
  sensor::Sensor *light_sensor_{nullptr};
@@ -13,7 +13,7 @@ from esphome.const import (
13
13
  UNIT_LUX,
14
14
  )
15
15
 
16
- CODEOWNERS = ["@sjtrny"]
16
+ CODEOWNERS = ["@sjtrny", "@latonita"]
17
17
  DEPENDENCIES = ["i2c"]
18
18
 
19
19
  ltr390_ns = cg.esphome_ns.namespace("ltr390")
@@ -76,8 +76,24 @@ CONFIG_SCHEMA = cv.All(
76
76
  accuracy_decimals=1,
77
77
  device_class=DEVICE_CLASS_EMPTY,
78
78
  ),
79
- cv.Optional(CONF_GAIN, default="X18"): cv.enum(GAIN_OPTIONS),
80
- cv.Optional(CONF_RESOLUTION, default=20): cv.enum(RES_OPTIONS),
79
+ cv.Optional(CONF_GAIN, default="X18"): cv.Any(
80
+ cv.enum(GAIN_OPTIONS),
81
+ cv.Schema(
82
+ {
83
+ cv.Required(CONF_AMBIENT_LIGHT): cv.enum(GAIN_OPTIONS),
84
+ cv.Required(CONF_UV): cv.enum(GAIN_OPTIONS),
85
+ }
86
+ ),
87
+ ),
88
+ cv.Optional(CONF_RESOLUTION, default=20): cv.Any(
89
+ cv.enum(RES_OPTIONS),
90
+ cv.Schema(
91
+ {
92
+ cv.Required(CONF_AMBIENT_LIGHT): cv.enum(RES_OPTIONS),
93
+ cv.Required(CONF_UV): cv.enum(RES_OPTIONS),
94
+ }
95
+ ),
96
+ ),
81
97
  cv.Optional(CONF_WINDOW_CORRECTION_FACTOR, default=1.0): cv.float_range(
82
98
  min=1.0
83
99
  ),
@@ -101,11 +117,25 @@ async def to_code(config):
101
117
  await cg.register_component(var, config)
102
118
  await i2c.register_i2c_device(var, config)
103
119
 
104
- cg.add(var.set_gain_value(config[CONF_GAIN]))
105
- cg.add(var.set_res_value(config[CONF_RESOLUTION]))
106
120
  cg.add(var.set_wfac_value(config[CONF_WINDOW_CORRECTION_FACTOR]))
107
121
 
108
122
  for key, funcName in TYPES.items():
109
123
  if key in config:
110
124
  sens = await sensor.new_sensor(config[key])
111
125
  cg.add(getattr(var, funcName)(sens))
126
+
127
+ gain_value = config[CONF_GAIN]
128
+ if isinstance(gain_value, dict):
129
+ cg.add(var.set_als_gain_value(gain_value[CONF_AMBIENT_LIGHT]))
130
+ cg.add(var.set_uv_gain_value(gain_value[CONF_UV]))
131
+ else:
132
+ cg.add(var.set_als_gain_value(gain_value))
133
+ cg.add(var.set_uv_gain_value(gain_value))
134
+
135
+ res_value = config[CONF_RESOLUTION]
136
+ if isinstance(res_value, dict):
137
+ cg.add(var.set_als_res_value(res_value[CONF_AMBIENT_LIGHT]))
138
+ cg.add(var.set_uv_res_value(res_value[CONF_UV]))
139
+ else:
140
+ cg.add(var.set_als_res_value(res_value))
141
+ cg.add(var.set_uv_res_value(res_value))
@@ -74,6 +74,9 @@ def mdns_service(
74
74
 
75
75
  @coroutine_with_priority(55.0)
76
76
  async def to_code(config):
77
+ if config[CONF_DISABLED] is True:
78
+ return
79
+
77
80
  if CORE.using_arduino:
78
81
  if CORE.is_esp32:
79
82
  cg.add_library("ESPmDNS", None)
@@ -92,9 +95,6 @@ async def to_code(config):
92
95
  path="components/mdns",
93
96
  )
94
97
 
95
- if config[CONF_DISABLED]:
96
- return
97
-
98
98
  cg.add_define("USE_MDNS")
99
99
 
100
100
  var = cg.new_Pvariable(config[CONF_ID])
@@ -1,5 +1,6 @@
1
- #include "mdns_component.h"
2
1
  #include "esphome/core/defines.h"
2
+ #ifdef USE_MDNS
3
+ #include "mdns_component.h"
3
4
  #include "esphome/core/version.h"
4
5
  #include "esphome/core/application.h"
5
6
  #include "esphome/core/log.h"
@@ -125,3 +126,4 @@ void MDNSComponent::dump_config() {
125
126
 
126
127
  } // namespace mdns
127
128
  } // namespace esphome
129
+ #endif
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
-
2
+ #include "esphome/core/defines.h"
3
+ #ifdef USE_MDNS
3
4
  #include <string>
4
5
  #include <vector>
5
6
  #include "esphome/core/component.h"
@@ -46,3 +47,4 @@ class MDNSComponent : public Component {
46
47
 
47
48
  } // namespace mdns
48
49
  } // namespace esphome
50
+ #endif
@@ -1,4 +1,5 @@
1
- #ifdef USE_ESP32
1
+ #include "esphome/core/defines.h"
2
+ #if defined(USE_ESP32) && defined(USE_MDNS)
2
3
 
3
4
  #include <mdns.h>
4
5
  #include <cstring>
@@ -1,4 +1,5 @@
1
- #if defined(USE_ESP8266) && defined(USE_ARDUINO)
1
+ #include "esphome/core/defines.h"
2
+ #if defined(USE_ESP8266) && defined(USE_ARDUINO) && defined(USE_MDNS)
2
3
 
3
4
  #include <ESP8266mDNS.h>
4
5
  #include "esphome/components/network/ip_address.h"
@@ -1,4 +1,5 @@
1
- #ifdef USE_HOST
1
+ #include "esphome/core/defines.h"
2
+ #if defined(USE_HOST) && defined(USE_MDNS)
2
3
 
3
4
  #include "esphome/components/network/ip_address.h"
4
5
  #include "esphome/components/network/util.h"
@@ -1,4 +1,5 @@
1
- #ifdef USE_LIBRETINY
1
+ #include "esphome/core/defines.h"
2
+ #if defined(USE_LIBRETINY) && defined(USE_MDNS)
2
3
 
3
4
  #include "esphome/components/network/ip_address.h"
4
5
  #include "esphome/components/network/util.h"
@@ -1,4 +1,5 @@
1
- #ifdef USE_RP2040
1
+ #include "esphome/core/defines.h"
2
+ #if defined(USE_RP2040) && defined(USE_MDNS)
2
3
 
3
4
  #include "esphome/components/network/ip_address.h"
4
5
  #include "esphome/components/network/util.h"