esphome 2024.9.2__py3-none-any.whl → 2024.10.0b1__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 (188) hide show
  1. esphome/components/aic3204/__init__.py +0 -0
  2. esphome/components/aic3204/aic3204.cpp +173 -0
  3. esphome/components/aic3204/aic3204.h +88 -0
  4. esphome/components/aic3204/audio_dac.py +52 -0
  5. esphome/components/aic3204/automation.h +23 -0
  6. esphome/components/alarm_control_panel/__init__.py +3 -4
  7. esphome/components/animation/__init__.py +16 -12
  8. esphome/components/api/api_connection.cpp +2 -0
  9. esphome/components/api/api_connection.h +3 -1
  10. esphome/components/api/api_frame_helper.cpp +2 -1
  11. esphome/components/api/api_frame_helper.h +2 -1
  12. esphome/components/api/api_server.cpp +2 -0
  13. esphome/components/api/api_server.h +3 -1
  14. esphome/components/api/custom_api_device.h +3 -2
  15. esphome/components/api/homeassistant_service.h +4 -3
  16. esphome/components/api/list_entities.cpp +2 -0
  17. esphome/components/api/list_entities.h +3 -2
  18. esphome/components/api/subscribe_state.cpp +2 -0
  19. esphome/components/api/subscribe_state.h +3 -2
  20. esphome/components/audio_dac/__init__.py +57 -0
  21. esphome/components/audio_dac/audio_dac.h +23 -0
  22. esphome/components/audio_dac/automation.h +43 -0
  23. esphome/components/bang_bang/bang_bang_climate.cpp +5 -2
  24. esphome/components/bedjet/bedjet_codec.cpp +4 -2
  25. esphome/components/binary_sensor/__init__.py +3 -4
  26. esphome/components/button/__init__.py +3 -4
  27. esphome/components/ch422g/__init__.py +26 -17
  28. esphome/components/ch422g/ch422g.cpp +66 -49
  29. esphome/components/ch422g/ch422g.h +17 -19
  30. esphome/components/climate/__init__.py +3 -4
  31. esphome/components/cover/__init__.py +4 -5
  32. esphome/components/cse7766/cse7766.cpp +11 -0
  33. esphome/components/cse7766/cse7766.h +4 -0
  34. esphome/components/cse7766/sensor.py +13 -1
  35. esphome/components/cst816/touchscreen/__init__.py +7 -4
  36. esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +20 -19
  37. esphome/components/cst816/touchscreen/cst816_touchscreen.h +2 -0
  38. esphome/components/datetime/__init__.py +21 -14
  39. esphome/components/datetime/datetime_base.h +8 -1
  40. esphome/components/datetime/datetime_entity.cpp +2 -0
  41. esphome/components/datetime/datetime_entity.h +2 -0
  42. esphome/components/datetime/time_entity.cpp +2 -0
  43. esphome/components/datetime/time_entity.h +2 -0
  44. esphome/components/esp32/__init__.py +20 -4
  45. esphome/components/esp32_improv/__init__.py +82 -1
  46. esphome/components/esp32_improv/automation.h +72 -0
  47. esphome/components/esp32_improv/esp32_improv_component.cpp +13 -5
  48. esphome/components/esp32_improv/esp32_improv_component.h +15 -0
  49. esphome/components/ethernet/__init__.py +5 -0
  50. esphome/components/ethernet/ethernet_component.cpp +13 -0
  51. esphome/components/ethernet/ethernet_component.h +1 -0
  52. esphome/components/fan/__init__.py +3 -4
  53. esphome/components/gp2y1010au0f/__init__.py +0 -0
  54. esphome/components/gp2y1010au0f/gp2y1010au0f.cpp +67 -0
  55. esphome/components/gp2y1010au0f/gp2y1010au0f.h +52 -0
  56. esphome/components/gp2y1010au0f/sensor.py +61 -0
  57. esphome/components/gpio_expander/__init__.py +0 -0
  58. esphome/components/gpio_expander/cached_gpio.h +38 -0
  59. esphome/components/grove_gas_mc_v2/__init__.py +0 -0
  60. esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.cpp +88 -0
  61. esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.h +39 -0
  62. esphome/components/grove_gas_mc_v2/sensor.py +77 -0
  63. esphome/components/haier/climate.py +4 -3
  64. esphome/components/haier/haier_base.cpp +63 -8
  65. esphome/components/haier/haier_base.h +29 -3
  66. esphome/components/haier/hon_climate.cpp +122 -65
  67. esphome/components/haier/hon_climate.h +18 -2
  68. esphome/components/haier/smartair2_climate.cpp +21 -21
  69. esphome/components/haier/switch/__init__.py +91 -0
  70. esphome/components/haier/switch/beeper.cpp +14 -0
  71. esphome/components/haier/switch/beeper.h +18 -0
  72. esphome/components/haier/switch/display.cpp +14 -0
  73. esphome/components/haier/switch/display.h +18 -0
  74. esphome/components/haier/switch/health_mode.cpp +14 -0
  75. esphome/components/haier/switch/health_mode.h +18 -0
  76. esphome/components/haier/switch/quiet_mode.cpp +14 -0
  77. esphome/components/haier/switch/quiet_mode.h +18 -0
  78. esphome/components/hmac_md5/hmac_md5.cpp +2 -0
  79. esphome/components/hmac_md5/hmac_md5.h +2 -1
  80. esphome/components/i2s_audio/speaker/__init__.py +19 -0
  81. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
  82. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
  83. esphome/components/ili9xxx/ili9xxx_display.h +1 -0
  84. esphome/components/image/__init__.py +12 -12
  85. esphome/components/image/image.cpp +44 -0
  86. esphome/components/image/image.h +17 -2
  87. esphome/components/inkplate6/display.py +2 -0
  88. esphome/components/inkplate6/inkplate.h +30 -2
  89. esphome/components/light/__init__.py +3 -4
  90. esphome/components/lock/__init__.py +3 -4
  91. esphome/components/lvgl/__init__.py +16 -5
  92. esphome/components/lvgl/defines.py +1 -0
  93. esphome/components/lvgl/hello_world.py +64 -0
  94. esphome/components/lvgl/lv_validation.py +159 -3
  95. esphome/components/lvgl/lvgl_esphome.cpp +0 -43
  96. esphome/components/lvgl/lvgl_esphome.h +0 -4
  97. esphome/components/lvgl/styles.py +3 -2
  98. esphome/components/lvgl/text/__init__.py +3 -3
  99. esphome/components/lvgl/widgets/__init__.py +2 -0
  100. esphome/components/lvgl/widgets/animimg.py +3 -4
  101. esphome/components/lvgl/widgets/dropdown.py +5 -1
  102. esphome/components/lvgl/widgets/meter.py +16 -11
  103. esphome/components/md5/__init__.py +6 -0
  104. esphome/components/md5/md5.cpp +2 -0
  105. esphome/components/md5/md5.h +2 -0
  106. esphome/components/micro_wake_word/__init__.py +7 -0
  107. esphome/components/mics_4514/sensor.py +11 -26
  108. esphome/components/modbus_controller/__init__.py +7 -5
  109. esphome/components/modbus_controller/binary_sensor/__init__.py +6 -6
  110. esphome/components/modbus_controller/number/__init__.py +5 -6
  111. esphome/components/modbus_controller/output/__init__.py +10 -14
  112. esphome/components/modbus_controller/select/__init__.py +1 -1
  113. esphome/components/modbus_controller/sensor/__init__.py +7 -7
  114. esphome/components/modbus_controller/switch/__init__.py +6 -7
  115. esphome/components/modbus_controller/text_sensor/__init__.py +8 -9
  116. esphome/components/mqtt/__init__.py +3 -0
  117. esphome/components/mqtt/mqtt_client.cpp +2 -0
  118. esphome/components/mqtt/mqtt_client.h +2 -0
  119. esphome/components/nau7802/__init__.py +0 -0
  120. esphome/components/nau7802/nau7802.cpp +323 -0
  121. esphome/components/nau7802/nau7802.h +121 -0
  122. esphome/components/nau7802/sensor.py +134 -0
  123. esphome/components/nextion/base_component.py +1 -0
  124. esphome/components/nextion/display.py +4 -0
  125. esphome/components/nextion/nextion.cpp +19 -4
  126. esphome/components/nextion/nextion.h +16 -0
  127. esphome/components/npi19/__init__.py +0 -0
  128. esphome/components/npi19/npi19.cpp +111 -0
  129. esphome/components/npi19/npi19.h +30 -0
  130. esphome/components/npi19/sensor.py +52 -0
  131. esphome/components/number/__init__.py +3 -5
  132. esphome/components/online_image/__init__.py +1 -1
  133. esphome/components/online_image/online_image.h +1 -2
  134. esphome/components/opentherm/__init__.py +57 -0
  135. esphome/components/opentherm/hub.cpp +277 -0
  136. esphome/components/opentherm/hub.h +110 -0
  137. esphome/components/opentherm/opentherm.cpp +568 -0
  138. esphome/components/opentherm/opentherm.h +347 -0
  139. esphome/components/pulse_counter/pulse_counter_sensor.cpp +8 -1
  140. esphome/components/pulse_counter/pulse_counter_sensor.h +1 -0
  141. esphome/components/radon_eye_ble/radon_eye_listener.cpp +10 -3
  142. esphome/components/remote_transmitter/__init__.py +18 -2
  143. esphome/components/remote_transmitter/remote_transmitter.h +6 -0
  144. esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +2 -0
  145. esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +2 -0
  146. esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +2 -0
  147. esphome/components/select/__init__.py +3 -4
  148. esphome/components/sensor/__init__.py +3 -4
  149. esphome/components/st7701s/st7701s.cpp +21 -8
  150. esphome/components/st7701s/st7701s.h +2 -0
  151. esphome/components/switch/__init__.py +3 -4
  152. esphome/components/tca9555/__init__.py +72 -0
  153. esphome/components/tca9555/tca9555.cpp +140 -0
  154. esphome/components/tca9555/tca9555.h +64 -0
  155. esphome/components/tcs34725/tcs34725.cpp +62 -64
  156. esphome/components/tem3200/__init__.py +0 -0
  157. esphome/components/tem3200/sensor.py +55 -0
  158. esphome/components/tem3200/tem3200.cpp +151 -0
  159. esphome/components/tem3200/tem3200.h +30 -0
  160. esphome/components/template/binary_sensor/__init__.py +19 -6
  161. esphome/components/text/__init__.py +3 -4
  162. esphome/components/text_sensor/__init__.py +3 -4
  163. esphome/components/thermostat/climate.py +11 -9
  164. esphome/components/thermostat/thermostat_climate.cpp +21 -15
  165. esphome/components/tm1638/binary_sensor/__init__.py +3 -2
  166. esphome/components/tm1638/display.py +5 -5
  167. esphome/components/tm1638/output/__init__.py +3 -2
  168. esphome/components/tm1638/switch/__init__.py +3 -2
  169. esphome/components/update/__init__.py +3 -4
  170. esphome/components/valve/__init__.py +3 -4
  171. esphome/components/web_server/__init__.py +78 -22
  172. esphome/components/web_server/server_index_v3.h +3989 -3979
  173. esphome/components/web_server/web_server.cpp +212 -33
  174. esphome/components/web_server/web_server.h +10 -1
  175. esphome/components/wifi/wifi_component_esp_idf.cpp +4 -5
  176. esphome/config_validation.py +1 -0
  177. esphome/const.py +12 -2
  178. esphome/core/defines.h +4 -2
  179. esphome/core/helpers.cpp +46 -10
  180. esphome/core/helpers.h +8 -0
  181. esphome/core/ring_buffer.cpp +12 -2
  182. esphome/core/ring_buffer.h +3 -0
  183. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/METADATA +5 -3
  184. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/RECORD +188 -139
  185. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/LICENSE +0 -0
  186. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/WHEEL +0 -0
  187. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/entry_points.txt +0 -0
  188. {esphome-2024.9.2.dist-info → esphome-2024.10.0b1.dist-info}/top_level.txt +0 -0
File without changes
@@ -0,0 +1,173 @@
1
+ #include "aic3204.h"
2
+
3
+ #include "esphome/core/defines.h"
4
+ #include "esphome/core/helpers.h"
5
+ #include "esphome/core/log.h"
6
+
7
+ namespace esphome {
8
+ namespace aic3204 {
9
+
10
+ static const char *const TAG = "aic3204";
11
+
12
+ #define ERROR_CHECK(err, msg) \
13
+ if (!(err)) { \
14
+ ESP_LOGE(TAG, msg); \
15
+ this->mark_failed(); \
16
+ return; \
17
+ }
18
+
19
+ void AIC3204::setup() {
20
+ ESP_LOGCONFIG(TAG, "Setting up AIC3204...");
21
+
22
+ // Set register page to 0
23
+ ERROR_CHECK(this->write_byte(AIC3204_PAGE_CTRL, 0x00), "Set page 0 failed");
24
+ // Initiate SW reset (PLL is powered off as part of reset)
25
+ ERROR_CHECK(this->write_byte(AIC3204_SW_RST, 0x01), "Software reset failed");
26
+ // *** Program clock settings ***
27
+ // Default is CODEC_CLKIN is from MCLK pin. Don't need to change this.
28
+ // MDAC*NDAC*FOSR*48Khz = mClk (24.576 MHz when the XMOS is expecting 48kHz audio)
29
+ // (See page 51 of https://www.ti.com/lit/ml/slaa557/slaa557.pdf)
30
+ // We do need MDAC*DOSR/32 >= the resource compute level for the processing block
31
+ // So here 2*128/32 = 8, which is equal to processing block 1 's resource compute
32
+ // See page 5 of https://www.ti.com/lit/an/slaa404c/slaa404c.pdf for the workflow
33
+ // for determining these settings.
34
+
35
+ // Power up NDAC and set to 2
36
+ ERROR_CHECK(this->write_byte(AIC3204_NDAC, 0x82), "Set NDAC failed");
37
+ // Power up MDAC and set to 2
38
+ ERROR_CHECK(this->write_byte(AIC3204_MDAC, 0x82), "Set MDAC failed");
39
+ // Program DOSR = 128
40
+ ERROR_CHECK(this->write_byte(AIC3204_DOSR, 0x80), "Set DOSR failed");
41
+ // Set Audio Interface Config: I2S, 32 bits, DOUT always driving
42
+ ERROR_CHECK(this->write_byte(AIC3204_CODEC_IF, 0x30), "Set CODEC_IF failed");
43
+ // For I2S Firmware only, set SCLK/MFP3 pin as Audio Data In
44
+ ERROR_CHECK(this->write_byte(AIC3204_SCLK_MFP3, 0x02), "Set SCLK/MFP3 failed");
45
+ ERROR_CHECK(this->write_byte(AIC3204_AUDIO_IF_4, 0x01), "Set AUDIO_IF_4 failed");
46
+ ERROR_CHECK(this->write_byte(AIC3204_AUDIO_IF_5, 0x01), "Set AUDIO_IF_5 failed");
47
+ // Program the DAC processing block to be used - PRB_P1
48
+ ERROR_CHECK(this->write_byte(AIC3204_DAC_SIG_PROC, 0x01), "Set DAC_SIG_PROC failed");
49
+
50
+ // *** Select Page 1 ***
51
+ ERROR_CHECK(this->write_byte(AIC3204_PAGE_CTRL, 0x01), "Set page 1 failed");
52
+ // Enable the internal AVDD_LDO:
53
+ ERROR_CHECK(this->write_byte(AIC3204_LDO_CTRL, 0x09), "Set LDO_CTRL failed");
54
+ // *** Program Analog Blocks ***
55
+ // Disable Internal Crude AVdd in presence of external AVdd supply or before powering up internal AVdd LDO
56
+ ERROR_CHECK(this->write_byte(AIC3204_PWR_CFG, 0x08), "Set PWR_CFG failed");
57
+ // Enable Master Analog Power Control
58
+ ERROR_CHECK(this->write_byte(AIC3204_LDO_CTRL, 0x01), "Set LDO_CTRL failed");
59
+ // Page 125: Common mode control register, set d6 to 1 to make the full chip common mode = 0.75 v
60
+ // We are using the internal AVdd regulator with a nominal output of 1.72 V (see LDO_CTRL_REGISTER on page 123)
61
+ // Page 86 says to only set the common mode voltage to 0.9 v if AVdd >= 1.8... but it isn't on our hardware
62
+ // We also adjust the HPL and HPR gains to -2dB gian later in this config flow compensate (see page 47)
63
+ // (All pages refer to the TLV320AIC3204 Application Reference Guide)
64
+ ERROR_CHECK(this->write_byte(AIC3204_CM_CTRL, 0x40), "Set CM_CTRL failed");
65
+ // *** Set PowerTune Modes ***
66
+ // Set the Left & Right DAC PowerTune mode to PTM_P3/4. Use Class-AB driver.
67
+ ERROR_CHECK(this->write_byte(AIC3204_PLAY_CFG1, 0x00), "Set PLAY_CFG1 failed");
68
+ ERROR_CHECK(this->write_byte(AIC3204_PLAY_CFG2, 0x00), "Set PLAY_CFG2 failed");
69
+ // Set the REF charging time to 40ms
70
+ ERROR_CHECK(this->write_byte(AIC3204_REF_STARTUP, 0x01), "Set REF_STARTUP failed");
71
+ // HP soft stepping settings for optimal pop performance at power up
72
+ // Rpop used is 6k with N = 6 and soft step = 20usec. This should work with 47uF coupling
73
+ // capacitor. Can try N=5,6 or 7 time constants as well. Trade-off delay vs “pop” sound.
74
+ ERROR_CHECK(this->write_byte(AIC3204_HP_START, 0x25), "Set HP_START failed");
75
+ // Route Left DAC to HPL
76
+ ERROR_CHECK(this->write_byte(AIC3204_HPL_ROUTE, 0x08), "Set HPL_ROUTE failed");
77
+ // Route Right DAC to HPR
78
+ ERROR_CHECK(this->write_byte(AIC3204_HPR_ROUTE, 0x08), "Set HPR_ROUTE failed");
79
+ // Route Left DAC to LOL
80
+ ERROR_CHECK(this->write_byte(AIC3204_LOL_ROUTE, 0x08), "Set LOL_ROUTE failed");
81
+ // Route Right DAC to LOR
82
+ ERROR_CHECK(this->write_byte(AIC3204_LOR_ROUTE, 0x08), "Set LOR_ROUTE failed");
83
+
84
+ // Unmute HPL and set gain to -2dB (see comment before configuring the AIC3204_CM_CTRL register)
85
+ ERROR_CHECK(this->write_byte(AIC3204_HPL_GAIN, 0x3e), "Set HPL_GAIN failed");
86
+ // Unmute HPR and set gain to -2dB (see comment before configuring the AIC3204_CM_CTRL register)
87
+ ERROR_CHECK(this->write_byte(AIC3204_HPR_GAIN, 0x3e), "Set HPR_GAIN failed");
88
+ // Unmute LOL and set gain to 0dB
89
+ ERROR_CHECK(this->write_byte(AIC3204_LOL_DRV_GAIN, 0x00), "Set LOL_DRV_GAIN failed");
90
+ // Unmute LOR and set gain to 0dB
91
+ ERROR_CHECK(this->write_byte(AIC3204_LOR_DRV_GAIN, 0x00), "Set LOR_DRV_GAIN failed");
92
+
93
+ // Power up HPL and HPR, LOL and LOR drivers
94
+ ERROR_CHECK(this->write_byte(AIC3204_OP_PWR_CTRL, 0x3C), "Set OP_PWR_CTRL failed");
95
+
96
+ // Wait for 2.5 sec for soft stepping to take effect before attempting power-up
97
+ this->set_timeout(2500, [this]() {
98
+ // *** Power Up DAC ***
99
+ // Select Page 0
100
+ ERROR_CHECK(this->write_byte(AIC3204_PAGE_CTRL, 0x00), "Set PAGE_CTRL failed");
101
+ // Power up the Left and Right DAC Channels. Route Left data to Left DAC and Right data to Right DAC.
102
+ // DAC Vol control soft step 1 step per DAC word clock.
103
+ ERROR_CHECK(this->write_byte(AIC3204_DAC_CH_SET1, 0xd4), "Set DAC_CH_SET1 failed");
104
+ // Set left and right DAC digital volume control
105
+ ERROR_CHECK(this->write_volume_(), "Set volume failed");
106
+ // Unmute left and right channels
107
+ ERROR_CHECK(this->write_mute_(), "Set mute failed");
108
+ });
109
+ }
110
+
111
+ void AIC3204::dump_config() {
112
+ ESP_LOGCONFIG(TAG, "AIC3204:");
113
+ LOG_I2C_DEVICE(this);
114
+
115
+ if (this->is_failed()) {
116
+ ESP_LOGE(TAG, "Communication with AIC3204 failed");
117
+ }
118
+ }
119
+
120
+ bool AIC3204::set_mute_off() {
121
+ this->is_muted_ = false;
122
+ return this->write_mute_();
123
+ }
124
+
125
+ bool AIC3204::set_mute_on() {
126
+ this->is_muted_ = true;
127
+ return this->write_mute_();
128
+ }
129
+
130
+ bool AIC3204::set_auto_mute_mode(uint8_t auto_mute_mode) {
131
+ this->auto_mute_mode_ = auto_mute_mode & 0x07;
132
+ ESP_LOGVV(TAG, "Setting auto_mute_mode to 0x%.2x", this->auto_mute_mode_);
133
+ return this->write_mute_();
134
+ }
135
+
136
+ bool AIC3204::set_volume(float volume) {
137
+ this->volume_ = clamp<float>(volume, 0.0, 1.0);
138
+ return this->write_volume_();
139
+ }
140
+
141
+ bool AIC3204::is_muted() { return this->is_muted_; }
142
+
143
+ float AIC3204::volume() { return this->volume_; }
144
+
145
+ bool AIC3204::write_mute_() {
146
+ uint8_t mute_mode_byte = this->auto_mute_mode_ << 4; // auto-mute control is bits 4-6
147
+ mute_mode_byte |= this->is_muted_ ? 0x0c : 0x00; // mute bits are 2-3
148
+ if (!this->write_byte(AIC3204_PAGE_CTRL, 0x00) || !this->write_byte(AIC3204_DAC_CH_SET2, mute_mode_byte)) {
149
+ ESP_LOGE(TAG, "Writing mute modes failed");
150
+ return false;
151
+ }
152
+ return true;
153
+ }
154
+
155
+ bool AIC3204::write_volume_() {
156
+ const int8_t dvc_min_byte = -127;
157
+ const int8_t dvc_max_byte = 48;
158
+
159
+ int8_t volume_byte = dvc_min_byte + (this->volume_ * (dvc_max_byte - dvc_min_byte));
160
+ volume_byte = clamp<int8_t>(volume_byte, dvc_min_byte, dvc_max_byte);
161
+
162
+ ESP_LOGVV(TAG, "Setting volume to 0x%.2x", volume_byte & 0xFF);
163
+
164
+ if ((!this->write_byte(AIC3204_PAGE_CTRL, 0x00)) || (!this->write_byte(AIC3204_DACL_VOL_D, volume_byte)) ||
165
+ (!this->write_byte(AIC3204_DACR_VOL_D, volume_byte))) {
166
+ ESP_LOGE(TAG, "Writing volume failed");
167
+ return false;
168
+ }
169
+ return true;
170
+ }
171
+
172
+ } // namespace aic3204
173
+ } // namespace esphome
@@ -0,0 +1,88 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/audio_dac/audio_dac.h"
4
+ #include "esphome/components/i2c/i2c.h"
5
+ #include "esphome/core/component.h"
6
+ #include "esphome/core/defines.h"
7
+ #include "esphome/core/hal.h"
8
+
9
+ namespace esphome {
10
+ namespace aic3204 {
11
+
12
+ // TLV320AIC3204 Register Addresses
13
+ // Page 0
14
+ static const uint8_t AIC3204_PAGE_CTRL = 0x00; // Register 0 - Page Control
15
+ static const uint8_t AIC3204_SW_RST = 0x01; // Register 1 - Software Reset
16
+ static const uint8_t AIC3204_CLK_PLL1 = 0x04; // Register 4 - Clock Setting Register 1, Multiplexers
17
+ static const uint8_t AIC3204_CLK_PLL2 = 0x05; // Register 5 - Clock Setting Register 2, P and R values
18
+ static const uint8_t AIC3204_CLK_PLL3 = 0x06; // Register 6 - Clock Setting Register 3, J values
19
+ static const uint8_t AIC3204_NDAC = 0x0B; // Register 11 - NDAC Divider Value
20
+ static const uint8_t AIC3204_MDAC = 0x0C; // Register 12 - MDAC Divider Value
21
+ static const uint8_t AIC3204_DOSR = 0x0E; // Register 14 - DOSR Divider Value (LS Byte)
22
+ static const uint8_t AIC3204_NADC = 0x12; // Register 18 - NADC Divider Value
23
+ static const uint8_t AIC3204_MADC = 0x13; // Register 19 - MADC Divider Value
24
+ static const uint8_t AIC3204_AOSR = 0x14; // Register 20 - AOSR Divider Value
25
+ static const uint8_t AIC3204_CODEC_IF = 0x1B; // Register 27 - CODEC Interface Control
26
+ static const uint8_t AIC3204_AUDIO_IF_4 = 0x1F; // Register 31 - Audio Interface Setting Register 4
27
+ static const uint8_t AIC3204_AUDIO_IF_5 = 0x20; // Register 32 - Audio Interface Setting Register 5
28
+ static const uint8_t AIC3204_SCLK_MFP3 = 0x38; // Register 56 - SCLK/MFP3 Function Control
29
+ static const uint8_t AIC3204_DAC_SIG_PROC = 0x3C; // Register 60 - DAC Sig Processing Block Control
30
+ static const uint8_t AIC3204_ADC_SIG_PROC = 0x3D; // Register 61 - ADC Sig Processing Block Control
31
+ static const uint8_t AIC3204_DAC_CH_SET1 = 0x3F; // Register 63 - DAC Channel Setup 1
32
+ static const uint8_t AIC3204_DAC_CH_SET2 = 0x40; // Register 64 - DAC Channel Setup 2
33
+ static const uint8_t AIC3204_DACL_VOL_D = 0x41; // Register 65 - DAC Left Digital Vol Control
34
+ static const uint8_t AIC3204_DACR_VOL_D = 0x42; // Register 66 - DAC Right Digital Vol Control
35
+ static const uint8_t AIC3204_DRC_ENABLE = 0x44;
36
+ static const uint8_t AIC3204_ADC_CH_SET = 0x51; // Register 81 - ADC Channel Setup
37
+ static const uint8_t AIC3204_ADC_FGA_MUTE = 0x52; // Register 82 - ADC Fine Gain Adjust/Mute
38
+
39
+ // Page 1
40
+ static const uint8_t AIC3204_PWR_CFG = 0x01; // Register 1 - Power Config
41
+ static const uint8_t AIC3204_LDO_CTRL = 0x02; // Register 2 - LDO Control
42
+ static const uint8_t AIC3204_PLAY_CFG1 = 0x03; // Register 3 - Playback Config 1
43
+ static const uint8_t AIC3204_PLAY_CFG2 = 0x04; // Register 4 - Playback Config 2
44
+ static const uint8_t AIC3204_OP_PWR_CTRL = 0x09; // Register 9 - Output Driver Power Control
45
+ static const uint8_t AIC3204_CM_CTRL = 0x0A; // Register 10 - Common Mode Control
46
+ static const uint8_t AIC3204_HPL_ROUTE = 0x0C; // Register 12 - HPL Routing Select
47
+ static const uint8_t AIC3204_HPR_ROUTE = 0x0D; // Register 13 - HPR Routing Select
48
+ static const uint8_t AIC3204_LOL_ROUTE = 0x0E; // Register 14 - LOL Routing Selection
49
+ static const uint8_t AIC3204_LOR_ROUTE = 0x0F; // Register 15 - LOR Routing Selection
50
+ static const uint8_t AIC3204_HPL_GAIN = 0x10; // Register 16 - HPL Driver Gain
51
+ static const uint8_t AIC3204_HPR_GAIN = 0x11; // Register 17 - HPR Driver Gain
52
+ static const uint8_t AIC3204_LOL_DRV_GAIN = 0x12; // Register 18 - LOL Driver Gain Setting
53
+ static const uint8_t AIC3204_LOR_DRV_GAIN = 0x13; // Register 19 - LOR Driver Gain Setting
54
+ static const uint8_t AIC3204_HP_START = 0x14; // Register 20 - Headphone Driver Startup
55
+ static const uint8_t AIC3204_LPGA_P_ROUTE = 0x34; // Register 52 - Left PGA Positive Input Route
56
+ static const uint8_t AIC3204_LPGA_N_ROUTE = 0x36; // Register 54 - Left PGA Negative Input Route
57
+ static const uint8_t AIC3204_RPGA_P_ROUTE = 0x37; // Register 55 - Right PGA Positive Input Route
58
+ static const uint8_t AIC3204_RPGA_N_ROUTE = 0x39; // Register 57 - Right PGA Negative Input Route
59
+ static const uint8_t AIC3204_LPGA_VOL = 0x3B; // Register 59 - Left PGA Volume
60
+ static const uint8_t AIC3204_RPGA_VOL = 0x3C; // Register 60 - Right PGA Volume
61
+ static const uint8_t AIC3204_ADC_PTM = 0x3D; // Register 61 - ADC Power Tune Config
62
+ static const uint8_t AIC3204_AN_IN_CHRG = 0x47; // Register 71 - Analog Input Quick Charging Config
63
+ static const uint8_t AIC3204_REF_STARTUP = 0x7B; // Register 123 - Reference Power Up Config
64
+
65
+ class AIC3204 : public audio_dac::AudioDac, public Component, public i2c::I2CDevice {
66
+ public:
67
+ void setup() override;
68
+ void dump_config() override;
69
+ float get_setup_priority() const override { return setup_priority::DATA; }
70
+
71
+ bool set_mute_off() override;
72
+ bool set_mute_on() override;
73
+ bool set_auto_mute_mode(uint8_t auto_mute_mode);
74
+ bool set_volume(float volume) override;
75
+
76
+ bool is_muted() override;
77
+ float volume() override;
78
+
79
+ protected:
80
+ bool write_mute_();
81
+ bool write_volume_();
82
+
83
+ uint8_t auto_mute_mode_{0};
84
+ float volume_{0};
85
+ };
86
+
87
+ } // namespace aic3204
88
+ } // namespace esphome
@@ -0,0 +1,52 @@
1
+ from esphome import automation
2
+ import esphome.codegen as cg
3
+ from esphome.components import i2c
4
+ from esphome.components.audio_dac import AudioDac
5
+ import esphome.config_validation as cv
6
+ from esphome.const import CONF_ID, CONF_MODE
7
+
8
+ CODEOWNERS = ["@kbx81"]
9
+ DEPENDENCIES = ["i2c"]
10
+
11
+ aic3204_ns = cg.esphome_ns.namespace("aic3204")
12
+ AIC3204 = aic3204_ns.class_("AIC3204", AudioDac, cg.Component, i2c.I2CDevice)
13
+
14
+ SetAutoMuteAction = aic3204_ns.class_("SetAutoMuteAction", automation.Action)
15
+
16
+ CONFIG_SCHEMA = (
17
+ cv.Schema(
18
+ {
19
+ cv.GenerateID(): cv.declare_id(AIC3204),
20
+ }
21
+ )
22
+ .extend(cv.COMPONENT_SCHEMA)
23
+ .extend(i2c.i2c_device_schema(0x18))
24
+ )
25
+
26
+
27
+ SET_AUTO_MUTE_ACTION_SCHEMA = cv.maybe_simple_value(
28
+ {
29
+ cv.GenerateID(): cv.use_id(AIC3204),
30
+ cv.Required(CONF_MODE): cv.templatable(cv.int_range(max=7, min=0)),
31
+ },
32
+ key=CONF_MODE,
33
+ )
34
+
35
+
36
+ @automation.register_action(
37
+ "aic3204.set_auto_mute_mode", SetAutoMuteAction, SET_AUTO_MUTE_ACTION_SCHEMA
38
+ )
39
+ async def aic3204_set_volume_to_code(config, action_id, template_arg, args):
40
+ paren = await cg.get_variable(config[CONF_ID])
41
+ var = cg.new_Pvariable(action_id, template_arg, paren)
42
+
43
+ template_ = await cg.templatable(config.get(CONF_MODE), args, int)
44
+ cg.add(var.set_auto_mute_mode(template_))
45
+
46
+ return var
47
+
48
+
49
+ async def to_code(config):
50
+ var = cg.new_Pvariable(config[CONF_ID])
51
+ await cg.register_component(var, config)
52
+ await i2c.register_i2c_device(var, config)
@@ -0,0 +1,23 @@
1
+ #pragma once
2
+
3
+ #include "esphome/core/automation.h"
4
+ #include "esphome/core/component.h"
5
+ #include "aic3204.h"
6
+
7
+ namespace esphome {
8
+ namespace aic3204 {
9
+
10
+ template<typename... Ts> class SetAutoMuteAction : public Action<Ts...> {
11
+ public:
12
+ explicit SetAutoMuteAction(AIC3204 *aic3204) : aic3204_(aic3204) {}
13
+
14
+ TEMPLATABLE_VALUE(uint8_t, auto_mute_mode)
15
+
16
+ void play(Ts... x) override { this->aic3204_->set_auto_mute_mode(this->auto_mute_mode_.value(x...)); }
17
+
18
+ protected:
19
+ AIC3204 *aic3204_;
20
+ };
21
+
22
+ } // namespace aic3204
23
+ } // namespace esphome
@@ -9,7 +9,7 @@ from esphome.const import (
9
9
  CONF_MQTT_ID,
10
10
  CONF_ON_STATE,
11
11
  CONF_TRIGGER_ID,
12
- CONF_WEB_SERVER_ID,
12
+ CONF_WEB_SERVER,
13
13
  )
14
14
  from esphome.core import CORE, coroutine_with_priority
15
15
  from esphome.cpp_helpers import setup_entity
@@ -195,9 +195,8 @@ async def setup_alarm_control_panel_core_(var, config):
195
195
  for conf in config.get(CONF_ON_READY, []):
196
196
  trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
197
197
  await automation.build_automation(trigger, [], conf)
198
- if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
199
- web_server_ = await cg.get_variable(webserver_id)
200
- web_server.add_entity_to_sorting_list(web_server_, var, config)
198
+ if web_server_config := config.get(CONF_WEB_SERVER):
199
+ await web_server.add_entity_config(var, web_server_config)
201
200
  if mqtt_id := config.get(CONF_MQTT_ID):
202
201
  mqtt_ = cg.new_Pvariable(mqtt_id, var)
203
202
  await mqtt.register_mqtt_component(mqtt_, config)
@@ -1,26 +1,26 @@
1
1
  import logging
2
2
 
3
3
  from esphome import automation, core
4
+ import esphome.codegen as cg
4
5
  from esphome.components import font
5
6
  import esphome.components.image as espImage
6
7
  from esphome.components.image import (
7
8
  CONF_USE_TRANSPARENCY,
8
9
  LOCAL_SCHEMA,
9
- WEB_SCHEMA,
10
- SOURCE_WEB,
11
10
  SOURCE_LOCAL,
11
+ SOURCE_WEB,
12
+ WEB_SCHEMA,
12
13
  )
13
14
  import esphome.config_validation as cv
14
- import esphome.codegen as cg
15
15
  from esphome.const import (
16
16
  CONF_FILE,
17
17
  CONF_ID,
18
+ CONF_PATH,
18
19
  CONF_RAW_DATA_ID,
19
20
  CONF_REPEAT,
20
21
  CONF_RESIZE,
21
- CONF_TYPE,
22
22
  CONF_SOURCE,
23
- CONF_PATH,
23
+ CONF_TYPE,
24
24
  CONF_URL,
25
25
  )
26
26
  from esphome.core import CORE, HexInt
@@ -172,6 +172,9 @@ async def to_code(config):
172
172
  path = CORE.relative_config_path(conf_file[CONF_PATH])
173
173
  elif conf_file[CONF_SOURCE] == SOURCE_WEB:
174
174
  path = espImage.compute_local_image_path(conf_file).as_posix()
175
+ else:
176
+ raise core.EsphomeError(f"Unknown animation source: {conf_file[CONF_SOURCE]}")
177
+
175
178
  try:
176
179
  image = Image.open(path)
177
180
  except Exception as e:
@@ -183,13 +186,12 @@ async def to_code(config):
183
186
  new_width_max, new_height_max = config[CONF_RESIZE]
184
187
  ratio = min(new_width_max / width, new_height_max / height)
185
188
  width, height = int(width * ratio), int(height * ratio)
186
- else:
187
- if width > 500 or height > 500:
188
- _LOGGER.warning(
189
- 'The image "%s" you requested is very big. Please consider'
190
- " using the resize parameter.",
191
- path,
192
- )
189
+ elif width > 500 or height > 500:
190
+ _LOGGER.warning(
191
+ 'The image "%s" you requested is very big. Please consider'
192
+ " using the resize parameter.",
193
+ path,
194
+ )
193
195
 
194
196
  transparent = config[CONF_USE_TRANSPARENCY]
195
197
 
@@ -306,6 +308,8 @@ async def to_code(config):
306
308
  if transparent:
307
309
  alpha = image.split()[-1]
308
310
  has_alpha = alpha.getextrema()[0] < 0xFF
311
+ else:
312
+ has_alpha = False
309
313
  frame = image.convert("1", dither=Image.Dither.NONE)
310
314
  if CONF_RESIZE in config:
311
315
  frame = frame.resize([width, height])
@@ -1,4 +1,5 @@
1
1
  #include "api_connection.h"
2
+ #ifdef USE_API
2
3
  #include <cerrno>
3
4
  #include <cinttypes>
4
5
  #include <utility>
@@ -1568,3 +1569,4 @@ void APIConnection::on_fatal_error() {
1568
1569
 
1569
1570
  } // namespace api
1570
1571
  } // namespace esphome
1572
+ #endif
@@ -1,12 +1,13 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_API
3
5
  #include "api_frame_helper.h"
4
6
  #include "api_pb2.h"
5
7
  #include "api_pb2_service.h"
6
8
  #include "api_server.h"
7
9
  #include "esphome/core/application.h"
8
10
  #include "esphome/core/component.h"
9
- #include "esphome/core/defines.h"
10
11
 
11
12
  #include <vector>
12
13
 
@@ -268,3 +269,4 @@ class APIConnection : public APIServerConnection {
268
269
 
269
270
  } // namespace api
270
271
  } // namespace esphome
272
+ #endif
@@ -1,5 +1,5 @@
1
1
  #include "api_frame_helper.h"
2
-
2
+ #ifdef USE_API
3
3
  #include "esphome/core/log.h"
4
4
  #include "esphome/core/hal.h"
5
5
  #include "esphome/core/helpers.h"
@@ -1028,3 +1028,4 @@ APIError APIPlaintextFrameHelper::shutdown(int how) {
1028
1028
 
1029
1029
  } // namespace api
1030
1030
  } // namespace esphome
1031
+ #endif
@@ -5,7 +5,7 @@
5
5
  #include <vector>
6
6
 
7
7
  #include "esphome/core/defines.h"
8
-
8
+ #ifdef USE_API
9
9
  #ifdef USE_API_NOISE
10
10
  #include "noise/protocol.h"
11
11
  #endif
@@ -190,3 +190,4 @@ class APIPlaintextFrameHelper : public APIFrameHelper {
190
190
 
191
191
  } // namespace api
192
192
  } // namespace esphome
193
+ #endif
@@ -1,4 +1,5 @@
1
1
  #include "api_server.h"
2
+ #ifdef USE_API
2
3
  #include <cerrno>
3
4
  #include "api_connection.h"
4
5
  #include "esphome/components/network/util.h"
@@ -403,3 +404,4 @@ void APIServer::on_alarm_control_panel_update(alarm_control_panel::AlarmControlP
403
404
 
404
405
  } // namespace api
405
406
  } // namespace esphome
407
+ #endif
@@ -1,5 +1,7 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_API
3
5
  #include "api_noise_context.h"
4
6
  #include "api_pb2.h"
5
7
  #include "api_pb2_service.h"
@@ -7,7 +9,6 @@
7
9
  #include "esphome/core/automation.h"
8
10
  #include "esphome/core/component.h"
9
11
  #include "esphome/core/controller.h"
10
- #include "esphome/core/defines.h"
11
12
  #include "esphome/core/log.h"
12
13
  #include "list_entities.h"
13
14
  #include "subscribe_state.h"
@@ -153,3 +154,4 @@ template<typename... Ts> class APIConnectedCondition : public Condition<Ts...> {
153
154
 
154
155
  } // namespace api
155
156
  } // namespace esphome
157
+ #endif
@@ -1,9 +1,9 @@
1
1
  #pragma once
2
2
 
3
3
  #include <map>
4
- #include "user_services.h"
5
4
  #include "api_server.h"
6
-
5
+ #ifdef USE_API
6
+ #include "user_services.h"
7
7
  namespace esphome {
8
8
  namespace api {
9
9
 
@@ -216,3 +216,4 @@ class CustomAPIDevice {
216
216
 
217
217
  } // namespace api
218
218
  } // namespace esphome
219
+ #endif
@@ -1,10 +1,10 @@
1
1
  #pragma once
2
2
 
3
+ #include "api_server.h"
4
+ #ifdef USE_API
5
+ #include "api_pb2.h"
3
6
  #include "esphome/core/helpers.h"
4
7
  #include "esphome/core/automation.h"
5
- #include "api_pb2.h"
6
- #include "api_server.h"
7
-
8
8
  #include <vector>
9
9
 
10
10
  namespace esphome {
@@ -81,3 +81,4 @@ template<typename... Ts> class HomeAssistantServiceCallAction : public Action<Ts
81
81
 
82
82
  } // namespace api
83
83
  } // namespace esphome
84
+ #endif
@@ -1,4 +1,5 @@
1
1
  #include "list_entities.h"
2
+ #ifdef USE_API
2
3
  #include "api_connection.h"
3
4
  #include "esphome/core/application.h"
4
5
  #include "esphome/core/log.h"
@@ -104,3 +105,4 @@ bool ListEntitiesIterator::on_update(update::UpdateEntity *update) { return this
104
105
 
105
106
  } // namespace api
106
107
  } // namespace esphome
108
+ #endif
@@ -1,9 +1,9 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_API
3
5
  #include "esphome/core/component.h"
4
6
  #include "esphome/core/component_iterator.h"
5
- #include "esphome/core/defines.h"
6
-
7
7
  namespace esphome {
8
8
  namespace api {
9
9
 
@@ -87,3 +87,4 @@ class ListEntitiesIterator : public ComponentIterator {
87
87
 
88
88
  } // namespace api
89
89
  } // namespace esphome
90
+ #endif
@@ -1,4 +1,5 @@
1
1
  #include "subscribe_state.h"
2
+ #ifdef USE_API
2
3
  #include "api_connection.h"
3
4
  #include "esphome/core/log.h"
4
5
 
@@ -84,3 +85,4 @@ InitialStateIterator::InitialStateIterator(APIConnection *client) : client_(clie
84
85
 
85
86
  } // namespace api
86
87
  } // namespace esphome
88
+ #endif
@@ -1,10 +1,10 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_API
3
5
  #include "esphome/core/component.h"
4
6
  #include "esphome/core/component_iterator.h"
5
7
  #include "esphome/core/controller.h"
6
- #include "esphome/core/defines.h"
7
-
8
8
  namespace esphome {
9
9
  namespace api {
10
10
 
@@ -82,3 +82,4 @@ class InitialStateIterator : public ComponentIterator {
82
82
 
83
83
  } // namespace api
84
84
  } // namespace esphome
85
+ #endif