esphome 2024.7.0__py3-none-any.whl → 2024.7.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.
- esphome/components/aht10/aht10.cpp +2 -4
- esphome/components/climate/climate.cpp +6 -10
- esphome/components/climate/climate_traits.h +3 -3
- esphome/components/esp32_can/canbus.py +0 -3
- esphome/components/ethernet/ethernet_component.cpp +1 -5
- esphome/components/gree/climate.py +0 -1
- esphome/components/gree/gree.cpp +3 -11
- esphome/components/gree/gree.h +1 -5
- esphome/components/heatpumpir/climate.py +5 -6
- esphome/components/heatpumpir/heatpumpir.cpp +0 -5
- esphome/components/heatpumpir/heatpumpir.h +0 -5
- esphome/components/http_request/http_request_arduino.cpp +2 -7
- esphome/components/i2s_audio/__init__.py +0 -10
- esphome/components/i2s_audio/microphone/__init__.py +0 -7
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +3 -2
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -3
- esphome/components/improv_serial/improv_serial_component.cpp +2 -3
- esphome/components/ltr390/ltr390.cpp +29 -44
- esphome/components/ltr390/ltr390.h +5 -9
- esphome/components/ltr390/sensor.py +5 -35
- esphome/components/micro_wake_word/__init__.py +1 -3
- esphome/components/mitsubishi/mitsubishi.cpp +0 -1
- esphome/components/ota/ota_backend_arduino_esp32.cpp +7 -22
- esphome/components/ota/ota_backend_arduino_esp8266.cpp +8 -23
- esphome/components/ota/ota_backend_arduino_libretiny.cpp +7 -22
- esphome/components/ota/ota_backend_arduino_rp2040.cpp +7 -22
- esphome/components/pmsa003i/pmsa003i.cpp +0 -9
- esphome/components/restart/button/__init__.py +0 -2
- esphome/components/voice_assistant/voice_assistant.cpp +1 -3
- esphome/components/web_server/server_index_v2.h +41 -42
- esphome/components/web_server/server_index_v3.h +367 -368
- esphome/const.py +1 -1
- esphome/core/helpers.cpp +1 -1
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/METADATA +1 -1
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/RECORD +39 -39
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2024.7.0.dist-info → esphome-2024.7.0b1.dist-info}/top_level.txt +0 -0
@@ -93,9 +93,8 @@ void AHT10Component::restart_read_() {
|
|
93
93
|
|
94
94
|
void AHT10Component::read_data_() {
|
95
95
|
uint8_t data[6];
|
96
|
-
if (this->read_count_ > 1)
|
96
|
+
if (this->read_count_ > 1)
|
97
97
|
ESP_LOGD(TAG, "Read attempt %d at %ums", this->read_count_, (unsigned) (millis() - this->start_time_));
|
98
|
-
}
|
99
98
|
if (this->read(data, 6) != i2c::ERROR_OK) {
|
100
99
|
this->status_set_warning("AHT10 read failed, retrying soon");
|
101
100
|
this->restart_read_();
|
@@ -120,9 +119,8 @@ void AHT10Component::read_data_() {
|
|
120
119
|
return;
|
121
120
|
}
|
122
121
|
}
|
123
|
-
if (this->read_count_ > 1)
|
122
|
+
if (this->read_count_ > 1)
|
124
123
|
ESP_LOGD(TAG, "Success at %ums", (unsigned) (millis() - this->start_time_));
|
125
|
-
}
|
126
124
|
uint32_t raw_temperature = ((data[3] & 0x0F) << 16) | (data[4] << 8) | data[5];
|
127
125
|
uint32_t raw_humidity = ((data[1] << 16) | (data[2] << 8) | data[3]) >> 4;
|
128
126
|
|
@@ -574,25 +574,21 @@ void Climate::dump_traits_(const char *tag) {
|
|
574
574
|
ESP_LOGCONFIG(tag, " - Max temperature: %.1f", traits.get_visual_max_temperature());
|
575
575
|
ESP_LOGCONFIG(tag, " - Temperature step:");
|
576
576
|
ESP_LOGCONFIG(tag, " Target: %.1f", traits.get_visual_target_temperature_step());
|
577
|
+
ESP_LOGCONFIG(tag, " Current: %.1f", traits.get_visual_current_temperature_step());
|
578
|
+
ESP_LOGCONFIG(tag, " - Min humidity: %.0f", traits.get_visual_min_humidity());
|
579
|
+
ESP_LOGCONFIG(tag, " - Max humidity: %.0f", traits.get_visual_max_humidity());
|
577
580
|
if (traits.get_supports_current_temperature()) {
|
578
|
-
ESP_LOGCONFIG(tag, "
|
581
|
+
ESP_LOGCONFIG(tag, " [x] Supports current temperature");
|
579
582
|
}
|
580
|
-
if (traits.
|
581
|
-
ESP_LOGCONFIG(tag, "
|
582
|
-
ESP_LOGCONFIG(tag, " - Max humidity: %.0f", traits.get_visual_max_humidity());
|
583
|
+
if (traits.get_supports_current_humidity()) {
|
584
|
+
ESP_LOGCONFIG(tag, " [x] Supports current humidity");
|
583
585
|
}
|
584
586
|
if (traits.get_supports_two_point_target_temperature()) {
|
585
587
|
ESP_LOGCONFIG(tag, " [x] Supports two-point target temperature");
|
586
588
|
}
|
587
|
-
if (traits.get_supports_current_temperature()) {
|
588
|
-
ESP_LOGCONFIG(tag, " [x] Supports current temperature");
|
589
|
-
}
|
590
589
|
if (traits.get_supports_target_humidity()) {
|
591
590
|
ESP_LOGCONFIG(tag, " [x] Supports target humidity");
|
592
591
|
}
|
593
|
-
if (traits.get_supports_current_humidity()) {
|
594
|
-
ESP_LOGCONFIG(tag, " [x] Supports current humidity");
|
595
|
-
}
|
596
592
|
if (traits.get_supports_action()) {
|
597
593
|
ESP_LOGCONFIG(tag, " [x] Supports action");
|
598
594
|
}
|
@@ -73,7 +73,7 @@ class ClimateTraits {
|
|
73
73
|
ESPDEPRECATED("This method is deprecated, use set_supported_modes() instead", "v1.20")
|
74
74
|
void set_supports_dry_mode(bool supports_dry_mode) { set_mode_support_(CLIMATE_MODE_DRY, supports_dry_mode); }
|
75
75
|
bool supports_mode(ClimateMode mode) const { return supported_modes_.count(mode); }
|
76
|
-
|
76
|
+
std::set<ClimateMode> get_supported_modes() const { return supported_modes_; }
|
77
77
|
|
78
78
|
void set_supports_action(bool supports_action) { supports_action_ = supports_action; }
|
79
79
|
bool get_supports_action() const { return supports_action_; }
|
@@ -101,7 +101,7 @@ class ClimateTraits {
|
|
101
101
|
void set_supports_fan_mode_diffuse(bool supported) { set_fan_mode_support_(CLIMATE_FAN_DIFFUSE, supported); }
|
102
102
|
bool supports_fan_mode(ClimateFanMode fan_mode) const { return supported_fan_modes_.count(fan_mode); }
|
103
103
|
bool get_supports_fan_modes() const { return !supported_fan_modes_.empty() || !supported_custom_fan_modes_.empty(); }
|
104
|
-
|
104
|
+
std::set<ClimateFanMode> get_supported_fan_modes() const { return supported_fan_modes_; }
|
105
105
|
|
106
106
|
void set_supported_custom_fan_modes(std::set<std::string> supported_custom_fan_modes) {
|
107
107
|
supported_custom_fan_modes_ = std::move(supported_custom_fan_modes);
|
@@ -140,7 +140,7 @@ class ClimateTraits {
|
|
140
140
|
}
|
141
141
|
bool supports_swing_mode(ClimateSwingMode swing_mode) const { return supported_swing_modes_.count(swing_mode); }
|
142
142
|
bool get_supports_swing_modes() const { return !supported_swing_modes_.empty(); }
|
143
|
-
|
143
|
+
std::set<ClimateSwingMode> get_supported_swing_modes() const { return supported_swing_modes_; }
|
144
144
|
|
145
145
|
float get_visual_min_temperature() const { return visual_min_temperature_; }
|
146
146
|
void set_visual_min_temperature(float visual_min_temperature) { visual_min_temperature_ = visual_min_temperature; }
|
@@ -11,7 +11,6 @@ from esphome.components.esp32.const import (
|
|
11
11
|
VARIANT_ESP32S2,
|
12
12
|
VARIANT_ESP32S3,
|
13
13
|
VARIANT_ESP32C3,
|
14
|
-
VARIANT_ESP32C6,
|
15
14
|
VARIANT_ESP32H2,
|
16
15
|
)
|
17
16
|
|
@@ -48,7 +47,6 @@ CAN_SPEEDS_ESP32_S2 = {
|
|
48
47
|
|
49
48
|
CAN_SPEEDS_ESP32_S3 = {**CAN_SPEEDS_ESP32_S2}
|
50
49
|
CAN_SPEEDS_ESP32_C3 = {**CAN_SPEEDS_ESP32_S2}
|
51
|
-
CAN_SPEEDS_ESP32_C6 = {**CAN_SPEEDS_ESP32_S2}
|
52
50
|
CAN_SPEEDS_ESP32_H2 = {**CAN_SPEEDS_ESP32_S2}
|
53
51
|
|
54
52
|
CAN_SPEEDS = {
|
@@ -56,7 +54,6 @@ CAN_SPEEDS = {
|
|
56
54
|
VARIANT_ESP32S2: CAN_SPEEDS_ESP32_S2,
|
57
55
|
VARIANT_ESP32S3: CAN_SPEEDS_ESP32_S3,
|
58
56
|
VARIANT_ESP32C3: CAN_SPEEDS_ESP32_C3,
|
59
|
-
VARIANT_ESP32C6: CAN_SPEEDS_ESP32_C6,
|
60
57
|
VARIANT_ESP32H2: CAN_SPEEDS_ESP32_H2,
|
61
58
|
}
|
62
59
|
|
@@ -394,7 +394,7 @@ void EthernetComponent::got_ip_event_handler(void *arg, esp_event_base_t event_b
|
|
394
394
|
const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
395
395
|
ESP_LOGV(TAG, "[Ethernet event] ETH Got IP " IPSTR, IP2STR(&ip_info->ip));
|
396
396
|
global_eth_component->got_ipv4_address_ = true;
|
397
|
-
#if USE_NETWORK_IPV6
|
397
|
+
#if USE_NETWORK_IPV6
|
398
398
|
global_eth_component->connected_ = global_eth_component->ipv6_count_ >= USE_NETWORK_MIN_IPV6_ADDR_COUNT;
|
399
399
|
#else
|
400
400
|
global_eth_component->connected_ = true;
|
@@ -407,12 +407,8 @@ void EthernetComponent::got_ip6_event_handler(void *arg, esp_event_base_t event_
|
|
407
407
|
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *) event_data;
|
408
408
|
ESP_LOGV(TAG, "[Ethernet event] ETH Got IPv6: " IPV6STR, IPV62STR(event->ip6_info.ip));
|
409
409
|
global_eth_component->ipv6_count_ += 1;
|
410
|
-
#if (USE_NETWORK_MIN_IPV6_ADDR_COUNT > 0)
|
411
410
|
global_eth_component->connected_ =
|
412
411
|
global_eth_component->got_ipv4_address_ && (global_eth_component->ipv6_count_ >= USE_NETWORK_MIN_IPV6_ADDR_COUNT);
|
413
|
-
#else
|
414
|
-
global_eth_component->connected_ = global_eth_component->got_ipv4_address_;
|
415
|
-
#endif
|
416
412
|
}
|
417
413
|
#endif /* USE_NETWORK_IPV6 */
|
418
414
|
|
esphome/components/gree/gree.cpp
CHANGED
@@ -24,7 +24,7 @@ void GreeClimate::transmit_state() {
|
|
24
24
|
remote_state[4] |= (this->horizontal_swing_() << 4);
|
25
25
|
}
|
26
26
|
|
27
|
-
if (this->model_ == GREE_YAA || this->model_ == GREE_YAC
|
27
|
+
if (this->model_ == GREE_YAA || this->model_ == GREE_YAC) {
|
28
28
|
remote_state[2] = 0x20; // bits 0..3 always 0000, bits 4..7 TURBO,LIGHT,HEALTH,X-FAN
|
29
29
|
remote_state[3] = 0x50; // bits 4..7 always 0101
|
30
30
|
remote_state[6] = 0x20; // YAA1FB, FAA1FB1, YB1F2 bits 4..7 always 0010
|
@@ -53,11 +53,7 @@ void GreeClimate::transmit_state() {
|
|
53
53
|
data->set_carrier_frequency(GREE_IR_FREQUENCY);
|
54
54
|
|
55
55
|
data->mark(GREE_HEADER_MARK);
|
56
|
-
|
57
|
-
data->space(GREE_YAC1FB9_HEADER_SPACE);
|
58
|
-
} else {
|
59
|
-
data->space(GREE_HEADER_SPACE);
|
60
|
-
}
|
56
|
+
data->space(GREE_HEADER_SPACE);
|
61
57
|
|
62
58
|
for (int i = 0; i < 4; i++) {
|
63
59
|
for (uint8_t mask = 1; mask > 0; mask <<= 1) { // iterate through bit mask
|
@@ -75,11 +71,7 @@ void GreeClimate::transmit_state() {
|
|
75
71
|
data->space(GREE_ZERO_SPACE);
|
76
72
|
|
77
73
|
data->mark(GREE_BIT_MARK);
|
78
|
-
|
79
|
-
data->space(GREE_YAC1FB9_MESSAGE_SPACE);
|
80
|
-
} else {
|
81
|
-
data->space(GREE_MESSAGE_SPACE);
|
82
|
-
}
|
74
|
+
data->space(GREE_MESSAGE_SPACE);
|
83
75
|
|
84
76
|
for (int i = 4; i < 8; i++) {
|
85
77
|
for (uint8_t mask = 1; mask > 0; mask <<= 1) { // iterate through bit mask
|
esphome/components/gree/gree.h
CHANGED
@@ -41,10 +41,6 @@ const uint32_t GREE_YAC_HEADER_MARK = 6000;
|
|
41
41
|
const uint32_t GREE_YAC_HEADER_SPACE = 3000;
|
42
42
|
const uint32_t GREE_YAC_BIT_MARK = 650;
|
43
43
|
|
44
|
-
// Timing specific to YAC1FB9
|
45
|
-
const uint32_t GREE_YAC1FB9_HEADER_SPACE = 4500;
|
46
|
-
const uint32_t GREE_YAC1FB9_MESSAGE_SPACE = 19980;
|
47
|
-
|
48
44
|
// State Frame size
|
49
45
|
const uint8_t GREE_STATE_FRAME_SIZE = 8;
|
50
46
|
|
@@ -71,7 +67,7 @@ const uint8_t GREE_HDIR_MRIGHT = 0x05;
|
|
71
67
|
const uint8_t GREE_HDIR_RIGHT = 0x06;
|
72
68
|
|
73
69
|
// Model codes
|
74
|
-
enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC
|
70
|
+
enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC };
|
75
71
|
|
76
72
|
class GreeClimate : public climate_ir::ClimateIR {
|
77
73
|
public:
|
@@ -8,6 +8,7 @@ from esphome.const import (
|
|
8
8
|
CONF_PROTOCOL,
|
9
9
|
CONF_VISUAL,
|
10
10
|
)
|
11
|
+
from esphome.core import CORE
|
11
12
|
|
12
13
|
CODEOWNERS = ["@rob-deutsch"]
|
13
14
|
|
@@ -66,11 +67,6 @@ PROTOCOLS = {
|
|
66
67
|
"carrier_qlima_2": Protocol.PROTOCOL_QLIMA_2,
|
67
68
|
"samsung_aqv12msan": Protocol.PROTOCOL_SAMSUNG_AQV12MSAN,
|
68
69
|
"zhjg01": Protocol.PROTOCOL_ZHJG01,
|
69
|
-
"airway": Protocol.PROTOCOL_AIRWAY,
|
70
|
-
"bgh_aud": Protocol.PROTOCOL_BGH_AUD,
|
71
|
-
"panasonic_altdke": Protocol.PROTOCOL_PANASONIC_ALTDKE,
|
72
|
-
"vaillantvai8": Protocol.PROTOCOL_VAILLANTVAI8,
|
73
|
-
"r51m": Protocol.PROTOCOL_R51M,
|
74
70
|
}
|
75
71
|
|
76
72
|
CONF_HORIZONTAL_DEFAULT = "horizontal_default"
|
@@ -126,4 +122,7 @@ def to_code(config):
|
|
126
122
|
cg.add(var.set_max_temperature(config[CONF_MAX_TEMPERATURE]))
|
127
123
|
cg.add(var.set_min_temperature(config[CONF_MIN_TEMPERATURE]))
|
128
124
|
|
129
|
-
cg.add_library("tonia/HeatpumpIR", "1.0.
|
125
|
+
cg.add_library("tonia/HeatpumpIR", "1.0.26")
|
126
|
+
|
127
|
+
if CORE.is_esp8266 or CORE.is_esp32:
|
128
|
+
cg.add_library("crankyoldgit/IRremoteESP8266", "2.8.6")
|
@@ -61,11 +61,6 @@ const std::map<Protocol, std::function<HeatpumpIR *()>> PROTOCOL_CONSTRUCTOR_MAP
|
|
61
61
|
{PROTOCOL_QLIMA_2, []() { return new Qlima2HeatpumpIR(); }}, // NOLINT
|
62
62
|
{PROTOCOL_SAMSUNG_AQV12MSAN, []() { return new SamsungAQV12MSANHeatpumpIR(); }}, // NOLINT
|
63
63
|
{PROTOCOL_ZHJG01, []() { return new ZHJG01HeatpumpIR(); }}, // NOLINT
|
64
|
-
{PROTOCOL_AIRWAY, []() { return new AIRWAYHeatpumpIR(); }}, // NOLINT
|
65
|
-
{PROTOCOL_BGH_AUD, []() { return new BGHHeatpumpIR(); }}, // NOLINT
|
66
|
-
{PROTOCOL_PANASONIC_ALTDKE, []() { return new PanasonicAltDKEHeatpumpIR(); }}, // NOLINT
|
67
|
-
{PROTOCOL_VAILLANTVAI8, []() { return new VaillantHeatpumpIR(); }}, // NOLINT
|
68
|
-
{PROTOCOL_R51M, []() { return new R51MHeatpumpIR(); }}, // NOLINT
|
69
64
|
};
|
70
65
|
|
71
66
|
void HeatpumpIRClimate::setup() {
|
@@ -61,11 +61,6 @@ enum Protocol {
|
|
61
61
|
PROTOCOL_QLIMA_2,
|
62
62
|
PROTOCOL_SAMSUNG_AQV12MSAN,
|
63
63
|
PROTOCOL_ZHJG01,
|
64
|
-
PROTOCOL_AIRWAY,
|
65
|
-
PROTOCOL_BGH_AUD,
|
66
|
-
PROTOCOL_PANASONIC_ALTDKE,
|
67
|
-
PROTOCOL_VAILLANTVAI8,
|
68
|
-
PROTOCOL_R51M,
|
69
64
|
};
|
70
65
|
|
71
66
|
// Simple enum to represent horizontal directios
|
@@ -32,13 +32,6 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
|
|
32
32
|
|
33
33
|
watchdog::WatchdogManager wdm(this->get_watchdog_timeout());
|
34
34
|
|
35
|
-
if (this->follow_redirects_) {
|
36
|
-
container->client_.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS);
|
37
|
-
container->client_.setRedirectLimit(this->redirect_limit_);
|
38
|
-
} else {
|
39
|
-
container->client_.setFollowRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS);
|
40
|
-
}
|
41
|
-
|
42
35
|
#if defined(USE_ESP8266)
|
43
36
|
std::unique_ptr<WiFiClient> stream_ptr;
|
44
37
|
#ifdef USE_HTTP_REQUEST_ESP8266_HTTPS
|
@@ -66,6 +59,8 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
|
|
66
59
|
"in your YAML, or use HTTPS");
|
67
60
|
}
|
68
61
|
#endif // USE_ARDUINO_VERSION_CODE
|
62
|
+
|
63
|
+
container->client_.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
69
64
|
bool status = container->client_.begin(*stream_ptr, url.c_str());
|
70
65
|
|
71
66
|
#elif defined(USE_RP2040)
|
@@ -25,10 +25,6 @@ CONF_I2S_LRCLK_PIN = "i2s_lrclk_pin"
|
|
25
25
|
CONF_I2S_AUDIO = "i2s_audio"
|
26
26
|
CONF_I2S_AUDIO_ID = "i2s_audio_id"
|
27
27
|
|
28
|
-
CONF_I2S_MODE = "i2s_mode"
|
29
|
-
CONF_PRIMARY = "primary"
|
30
|
-
CONF_SECONDARY = "secondary"
|
31
|
-
|
32
28
|
i2s_audio_ns = cg.esphome_ns.namespace("i2s_audio")
|
33
29
|
I2SAudioComponent = i2s_audio_ns.class_("I2SAudioComponent", cg.Component)
|
34
30
|
I2SAudioIn = i2s_audio_ns.class_("I2SAudioIn", cg.Parented.template(I2SAudioComponent))
|
@@ -36,12 +32,6 @@ I2SAudioOut = i2s_audio_ns.class_(
|
|
36
32
|
"I2SAudioOut", cg.Parented.template(I2SAudioComponent)
|
37
33
|
)
|
38
34
|
|
39
|
-
i2s_mode_t = cg.global_ns.enum("i2s_mode_t")
|
40
|
-
I2S_MODE_OPTIONS = {
|
41
|
-
CONF_PRIMARY: i2s_mode_t.I2S_MODE_MASTER, # NOLINT
|
42
|
-
CONF_SECONDARY: i2s_mode_t.I2S_MODE_SLAVE, # NOLINT
|
43
|
-
}
|
44
|
-
|
45
35
|
# https://github.com/espressif/esp-idf/blob/master/components/soc/{variant}/include/soc/soc_caps.h
|
46
36
|
I2S_PORTS = {
|
47
37
|
VARIANT_ESP32: 2,
|
@@ -7,9 +7,6 @@ from esphome.components import microphone, esp32
|
|
7
7
|
from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin
|
8
8
|
|
9
9
|
from .. import (
|
10
|
-
CONF_I2S_MODE,
|
11
|
-
CONF_PRIMARY,
|
12
|
-
I2S_MODE_OPTIONS,
|
13
10
|
i2s_audio_ns,
|
14
11
|
I2SAudioComponent,
|
15
12
|
I2SAudioIn,
|
@@ -71,9 +68,6 @@ BASE_SCHEMA = microphone.MICROPHONE_SCHEMA.extend(
|
|
71
68
|
_validate_bits, cv.enum(BITS_PER_SAMPLE)
|
72
69
|
),
|
73
70
|
cv.Optional(CONF_USE_APLL, default=False): cv.boolean,
|
74
|
-
cv.Optional(CONF_I2S_MODE, default=CONF_PRIMARY): cv.enum(
|
75
|
-
I2S_MODE_OPTIONS, lower=True
|
76
|
-
),
|
77
71
|
}
|
78
72
|
).extend(cv.COMPONENT_SCHEMA)
|
79
73
|
|
@@ -113,7 +107,6 @@ async def to_code(config):
|
|
113
107
|
cg.add(var.set_din_pin(config[CONF_I2S_DIN_PIN]))
|
114
108
|
cg.add(var.set_pdm(config[CONF_PDM]))
|
115
109
|
|
116
|
-
cg.add(var.set_i2s_mode(config[CONF_I2S_MODE]))
|
117
110
|
cg.add(var.set_channel(config[CONF_CHANNEL]))
|
118
111
|
cg.add(var.set_sample_rate(config[CONF_SAMPLE_RATE]))
|
119
112
|
cg.add(var.set_bits_per_sample(config[CONF_BITS_PER_SAMPLE]))
|
@@ -46,7 +46,7 @@ void I2SAudioMicrophone::start_() {
|
|
46
46
|
return; // Waiting for another i2s to return lock
|
47
47
|
}
|
48
48
|
i2s_driver_config_t config = {
|
49
|
-
.mode = (i2s_mode_t) (
|
49
|
+
.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX),
|
50
50
|
.sample_rate = this->sample_rate_,
|
51
51
|
.bits_per_sample = this->bits_per_sample_,
|
52
52
|
.channel_format = this->channel_,
|
@@ -174,7 +174,8 @@ size_t I2SAudioMicrophone::read(int16_t *buf, size_t len) {
|
|
174
174
|
size_t samples_read = bytes_read / sizeof(int32_t);
|
175
175
|
samples.resize(samples_read);
|
176
176
|
for (size_t i = 0; i < samples_read; i++) {
|
177
|
-
|
177
|
+
int32_t temp = reinterpret_cast<int32_t *>(buf)[i] >> 14;
|
178
|
+
samples[i] = clamp<int16_t>(temp, INT16_MIN, INT16_MAX);
|
178
179
|
}
|
179
180
|
memcpy(buf, samples.data(), samples_read * sizeof(int16_t));
|
180
181
|
return samples_read * sizeof(int16_t);
|
@@ -30,8 +30,6 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
|
|
30
30
|
}
|
31
31
|
#endif
|
32
32
|
|
33
|
-
void set_i2s_mode(i2s_mode_t mode) { this->i2s_mode_ = mode; }
|
34
|
-
|
35
33
|
void set_channel(i2s_channel_fmt_t channel) { this->channel_ = channel; }
|
36
34
|
void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
|
37
35
|
void set_bits_per_sample(i2s_bits_per_sample_t bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
|
@@ -48,7 +46,6 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
|
|
48
46
|
bool adc_{false};
|
49
47
|
#endif
|
50
48
|
bool pdm_{false};
|
51
|
-
i2s_mode_t i2s_mode_{};
|
52
49
|
i2s_channel_fmt_t channel_;
|
53
50
|
uint32_t sample_rate_;
|
54
51
|
i2s_bits_per_sample_t bits_per_sample_;
|
@@ -57,7 +57,7 @@ optional<uint8_t> ImprovSerialComponent::read_byte_() {
|
|
57
57
|
}
|
58
58
|
}
|
59
59
|
break;
|
60
|
-
#
|
60
|
+
#ifdef USE_LOGGER_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()) {
|
@@ -99,7 +99,7 @@ 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
|
-
#
|
102
|
+
#ifdef USE_LOGGER_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());
|
@@ -109,7 +109,6 @@ void ImprovSerialComponent::write_data_(std::vector<uint8_t> &data) {
|
|
109
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);
|
113
112
|
usb_serial_jtag_ll_txfifo_flush(); // fixes for issue in IDF 4.4.7
|
114
113
|
break;
|
115
114
|
#endif // USE_LOGGER_USB_SERIAL_JTAG
|
@@ -19,7 +19,6 @@ 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};
|
23
22
|
|
24
23
|
// Request fastest measurement rate - will be slowed by device if conversion rate is slower.
|
25
24
|
static const float RESOLUTION_SETTING[6] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50};
|
@@ -75,7 +74,7 @@ void LTR390Component::read_als_() {
|
|
75
74
|
uint32_t als = *val;
|
76
75
|
|
77
76
|
if (this->light_sensor_ != nullptr) {
|
78
|
-
float lux = ((0.6 * als) / (GAINVALUES[this->
|
77
|
+
float lux = ((0.6 * als) / (GAINVALUES[this->gain_] * RESOLUTIONVALUE[this->res_])) * this->wfac_;
|
79
78
|
this->light_sensor_->publish_state(lux);
|
80
79
|
}
|
81
80
|
|
@@ -91,7 +90,7 @@ void LTR390Component::read_uvs_() {
|
|
91
90
|
uint32_t uv = *val;
|
92
91
|
|
93
92
|
if (this->uvi_sensor_ != nullptr) {
|
94
|
-
this->uvi_sensor_->publish_state((uv / this->
|
93
|
+
this->uvi_sensor_->publish_state((uv / this->sensitivity_) * this->wfac_);
|
95
94
|
}
|
96
95
|
|
97
96
|
if (this->uv_sensor_ != nullptr) {
|
@@ -108,38 +107,24 @@ void LTR390Component::read_mode_(int mode_index) {
|
|
108
107
|
ctrl[LTR390_CTRL_EN] = true;
|
109
108
|
this->reg(LTR390_MAIN_CTRL) = ctrl.to_ulong();
|
110
109
|
|
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
|
-
|
126
110
|
// After the sensor integration time do the following
|
127
|
-
this->set_timeout(
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
+
});
|
143
128
|
}
|
144
129
|
|
145
130
|
void LTR390Component::setup() {
|
@@ -166,10 +151,16 @@ void LTR390Component::setup() {
|
|
166
151
|
return;
|
167
152
|
}
|
168
153
|
|
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
|
+
|
169
160
|
// Set sensitivity by linearly scaling against known value in the datasheet
|
170
|
-
float
|
171
|
-
float
|
172
|
-
this->
|
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;
|
173
164
|
|
174
165
|
// Set sensor read state
|
175
166
|
this->reading_ = false;
|
@@ -185,13 +176,7 @@ void LTR390Component::setup() {
|
|
185
176
|
}
|
186
177
|
}
|
187
178
|
|
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
|
-
}
|
179
|
+
void LTR390Component::dump_config() { LOG_I2C_DEVICE(this); }
|
195
180
|
|
196
181
|
void LTR390Component::update() {
|
197
182
|
if (!this->reading_ && !mode_funcs_.empty()) {
|
@@ -49,10 +49,8 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice {
|
|
49
49
|
void dump_config() override;
|
50
50
|
void update() override;
|
51
51
|
|
52
|
-
void
|
53
|
-
void
|
54
|
-
void set_als_res_value(LTR390RESOLUTION res) { this->res_als_ = res; }
|
55
|
-
void set_uv_res_value(LTR390RESOLUTION res) { this->res_uv_ = res; }
|
52
|
+
void set_gain_value(LTR390GAIN gain) { this->gain_ = gain; }
|
53
|
+
void set_res_value(LTR390RESOLUTION res) { this->res_ = res; }
|
56
54
|
void set_wfac_value(float wfac) { this->wfac_ = wfac; }
|
57
55
|
|
58
56
|
void set_light_sensor(sensor::Sensor *light_sensor) { this->light_sensor_ = light_sensor; }
|
@@ -73,11 +71,9 @@ class LTR390Component : public PollingComponent, public i2c::I2CDevice {
|
|
73
71
|
// a list of modes and corresponding read functions
|
74
72
|
std::vector<std::tuple<LTR390MODE, std::function<void()>>> mode_funcs_;
|
75
73
|
|
76
|
-
LTR390GAIN
|
77
|
-
|
78
|
-
|
79
|
-
LTR390RESOLUTION res_uv_;
|
80
|
-
float sensitivity_uv_;
|
74
|
+
LTR390GAIN gain_;
|
75
|
+
LTR390RESOLUTION res_;
|
76
|
+
float sensitivity_;
|
81
77
|
float wfac_;
|
82
78
|
|
83
79
|
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"]
|
17
17
|
DEPENDENCIES = ["i2c"]
|
18
18
|
|
19
19
|
ltr390_ns = cg.esphome_ns.namespace("ltr390")
|
@@ -76,24 +76,8 @@ 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.
|
80
|
-
|
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
|
-
),
|
79
|
+
cv.Optional(CONF_GAIN, default="X18"): cv.enum(GAIN_OPTIONS),
|
80
|
+
cv.Optional(CONF_RESOLUTION, default=20): cv.enum(RES_OPTIONS),
|
97
81
|
cv.Optional(CONF_WINDOW_CORRECTION_FACTOR, default=1.0): cv.float_range(
|
98
82
|
min=1.0
|
99
83
|
),
|
@@ -117,25 +101,11 @@ async def to_code(config):
|
|
117
101
|
await cg.register_component(var, config)
|
118
102
|
await i2c.register_i2c_device(var, config)
|
119
103
|
|
104
|
+
cg.add(var.set_gain_value(config[CONF_GAIN]))
|
105
|
+
cg.add(var.set_res_value(config[CONF_RESOLUTION]))
|
120
106
|
cg.add(var.set_wfac_value(config[CONF_WINDOW_CORRECTION_FACTOR]))
|
121
107
|
|
122
108
|
for key, funcName in TYPES.items():
|
123
109
|
if key in config:
|
124
110
|
sens = await sensor.new_sensor(config[key])
|
125
111
|
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))
|
@@ -357,9 +357,7 @@ CONFIG_SCHEMA = cv.All(
|
|
357
357
|
{
|
358
358
|
cv.GenerateID(): cv.declare_id(MicroWakeWord),
|
359
359
|
cv.GenerateID(CONF_MICROPHONE): cv.use_id(microphone.Microphone),
|
360
|
-
cv.Required(CONF_MODELS): cv.ensure_list(
|
361
|
-
cv.maybe_simple_value(MODEL_SCHEMA, key=CONF_MODEL)
|
362
|
-
),
|
360
|
+
cv.Required(CONF_MODELS): cv.ensure_list(MODEL_SCHEMA),
|
363
361
|
cv.Optional(CONF_ON_WAKE_WORD_DETECTED): automation.validate_automation(
|
364
362
|
single=True
|
365
363
|
),
|
@@ -52,7 +52,6 @@ const uint8_t MITSUBISHI_BYTE16 = 0X00;
|
|
52
52
|
|
53
53
|
climate::ClimateTraits MitsubishiClimate::traits() {
|
54
54
|
auto traits = climate::ClimateTraits();
|
55
|
-
traits.set_supports_current_temperature(this->sensor_ != nullptr);
|
56
55
|
traits.set_supports_action(false);
|
57
56
|
traits.set_visual_min_temperature(MITSUBISHI_TEMP_MIN);
|
58
57
|
traits.set_visual_max_temperature(MITSUBISHI_TEMP_MAX);
|