mirror of
https://github.com/esphome/esphome.git
synced 2025-11-01 15:41:52 +00:00
Compare commits
21 Commits
2024.4.0b1
...
2024.4.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcd9e3cb5d | ||
|
|
7ae36b023c | ||
|
|
3e64876097 | ||
|
|
44d13f2405 | ||
|
|
03d547d2c0 | ||
|
|
dd8be524b4 | ||
|
|
a29e634af1 | ||
|
|
1a152169e0 | ||
|
|
496b7f45db | ||
|
|
e1b861a0a1 | ||
|
|
f2a12589f3 | ||
|
|
3bae72a8a7 | ||
|
|
b6f1cfd69f | ||
|
|
09fbddea21 | ||
|
|
ed02747ebc | ||
|
|
ff0d33ffe3 | ||
|
|
3ec7f4221f | ||
|
|
8ada8f5e11 | ||
|
|
4ebbd4ebd8 | ||
|
|
1d4c074ee6 | ||
|
|
68b4d8865c |
@@ -4,13 +4,14 @@ from esphome.components import i2c
|
||||
from esphome.const import CONF_ID
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
AUTO_LOAD = ["sensor", "voltage_sampler"]
|
||||
MULTI_CONF = True
|
||||
|
||||
ads1115_ns = cg.esphome_ns.namespace("ads1115")
|
||||
ADS1115Component = ads1115_ns.class_("ADS1115Component", cg.Component, i2c.I2CDevice)
|
||||
|
||||
CONF_CONTINUOUS_MODE = "continuous_mode"
|
||||
CONF_ADS1115_ID = "ads1115_id"
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "ads1115.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ads1115 {
|
||||
@@ -75,25 +75,19 @@ void ADS1115Component::dump_config() {
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, "Communication with ADS1115 failed!");
|
||||
}
|
||||
|
||||
for (auto *sensor : this->sensors_) {
|
||||
LOG_SENSOR(" ", "Sensor", sensor);
|
||||
ESP_LOGCONFIG(TAG, " Multiplexer: %u", sensor->get_multiplexer());
|
||||
ESP_LOGCONFIG(TAG, " Gain: %u", sensor->get_gain());
|
||||
ESP_LOGCONFIG(TAG, " Resolution: %u", sensor->get_resolution());
|
||||
}
|
||||
}
|
||||
float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
||||
float ADS1115Component::request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain,
|
||||
ADS1115Resolution resolution) {
|
||||
uint16_t config = this->prev_config_;
|
||||
// Multiplexer
|
||||
// 0bxBBBxxxxxxxxxxxx
|
||||
config &= 0b1000111111111111;
|
||||
config |= (sensor->get_multiplexer() & 0b111) << 12;
|
||||
config |= (multiplexer & 0b111) << 12;
|
||||
|
||||
// Gain
|
||||
// 0bxxxxBBBxxxxxxxxx
|
||||
config &= 0b1111000111111111;
|
||||
config |= (sensor->get_gain() & 0b111) << 9;
|
||||
config |= (gain & 0b111) << 9;
|
||||
|
||||
if (!this->continuous_mode_) {
|
||||
// Start conversion
|
||||
@@ -132,7 +126,7 @@ float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
||||
return NAN;
|
||||
}
|
||||
|
||||
if (sensor->get_resolution() == ADS1015_12_BITS) {
|
||||
if (resolution == ADS1015_12_BITS) {
|
||||
bool negative = (raw_conversion >> 15) == 1;
|
||||
|
||||
// shift raw_conversion as it's only 12-bits, left justified
|
||||
@@ -151,8 +145,8 @@ float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
||||
auto signed_conversion = static_cast<int16_t>(raw_conversion);
|
||||
|
||||
float millivolts;
|
||||
float divider = (sensor->get_resolution() == ADS1115_16_BITS) ? 32768.0f : 2048.0f;
|
||||
switch (sensor->get_gain()) {
|
||||
float divider = (resolution == ADS1115_16_BITS) ? 32768.0f : 2048.0f;
|
||||
switch (gain) {
|
||||
case ADS1115_GAIN_6P144:
|
||||
millivolts = (signed_conversion * 6144) / divider;
|
||||
break;
|
||||
@@ -179,14 +173,5 @@ float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
||||
return millivolts / 1e3f;
|
||||
}
|
||||
|
||||
float ADS1115Sensor::sample() { return this->parent_->request_measurement(this); }
|
||||
void ADS1115Sensor::update() {
|
||||
float v = this->parent_->request_measurement(this);
|
||||
if (!std::isnan(v)) {
|
||||
ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
|
||||
this->publish_state(v);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ads1115
|
||||
} // namespace esphome
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
#include "esphome/components/voltage_sampler/voltage_sampler.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -35,12 +33,8 @@ enum ADS1115Resolution {
|
||||
ADS1015_12_BITS = 12,
|
||||
};
|
||||
|
||||
class ADS1115Sensor;
|
||||
|
||||
class ADS1115Component : public Component, public i2c::I2CDevice {
|
||||
public:
|
||||
void register_sensor(ADS1115Sensor *obj) { this->sensors_.push_back(obj); }
|
||||
/// Set up the internal sensor array.
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
/// HARDWARE_LATE setup priority
|
||||
@@ -48,33 +42,12 @@ class ADS1115Component : public Component, public i2c::I2CDevice {
|
||||
void set_continuous_mode(bool continuous_mode) { continuous_mode_ = continuous_mode; }
|
||||
|
||||
/// Helper method to request a measurement from a sensor.
|
||||
float request_measurement(ADS1115Sensor *sensor);
|
||||
float request_measurement(ADS1115Multiplexer multiplexer, ADS1115Gain gain, ADS1115Resolution resolution);
|
||||
|
||||
protected:
|
||||
std::vector<ADS1115Sensor *> sensors_;
|
||||
uint16_t prev_config_{0};
|
||||
bool continuous_mode_;
|
||||
};
|
||||
|
||||
/// Internal holder class that is in instance of Sensor so that the hub can create individual sensors.
|
||||
class ADS1115Sensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler {
|
||||
public:
|
||||
ADS1115Sensor(ADS1115Component *parent) : parent_(parent) {}
|
||||
void update() override;
|
||||
void set_multiplexer(ADS1115Multiplexer multiplexer) { multiplexer_ = multiplexer; }
|
||||
void set_gain(ADS1115Gain gain) { gain_ = gain; }
|
||||
void set_resolution(ADS1115Resolution resolution) { resolution_ = resolution; }
|
||||
float sample() override;
|
||||
uint8_t get_multiplexer() const { return multiplexer_; }
|
||||
uint8_t get_gain() const { return gain_; }
|
||||
uint8_t get_resolution() const { return resolution_; }
|
||||
|
||||
protected:
|
||||
ADS1115Component *parent_;
|
||||
ADS1115Multiplexer multiplexer_;
|
||||
ADS1115Gain gain_;
|
||||
ADS1115Resolution resolution_;
|
||||
};
|
||||
|
||||
} // namespace ads1115
|
||||
} // namespace esphome
|
||||
|
||||
@@ -10,8 +10,9 @@ from esphome.const import (
|
||||
UNIT_VOLT,
|
||||
CONF_ID,
|
||||
)
|
||||
from . import ads1115_ns, ADS1115Component
|
||||
from .. import ads1115_ns, ADS1115Component, CONF_ADS1115_ID
|
||||
|
||||
AUTO_LOAD = ["voltage_sampler"]
|
||||
DEPENDENCIES = ["ads1115"]
|
||||
|
||||
ADS1115Multiplexer = ads1115_ns.enum("ADS1115Multiplexer")
|
||||
@@ -43,20 +44,10 @@ RESOLUTION = {
|
||||
}
|
||||
|
||||
|
||||
def validate_gain(value):
|
||||
if isinstance(value, float):
|
||||
value = f"{value:0.03f}"
|
||||
elif not isinstance(value, str):
|
||||
raise cv.Invalid(f'invalid gain "{value}"')
|
||||
|
||||
return cv.enum(GAIN)(value)
|
||||
|
||||
|
||||
ADS1115Sensor = ads1115_ns.class_(
|
||||
"ADS1115Sensor", sensor.Sensor, cg.PollingComponent, voltage_sampler.VoltageSampler
|
||||
)
|
||||
|
||||
CONF_ADS1115_ID = "ads1115_id"
|
||||
CONFIG_SCHEMA = (
|
||||
sensor.sensor_schema(
|
||||
ADS1115Sensor,
|
||||
@@ -69,7 +60,7 @@ CONFIG_SCHEMA = (
|
||||
{
|
||||
cv.GenerateID(CONF_ADS1115_ID): cv.use_id(ADS1115Component),
|
||||
cv.Required(CONF_MULTIPLEXER): cv.enum(MUX, upper=True, space="_"),
|
||||
cv.Required(CONF_GAIN): validate_gain,
|
||||
cv.Required(CONF_GAIN): cv.enum(GAIN, string=True),
|
||||
cv.Optional(CONF_RESOLUTION, default="16_BITS"): cv.enum(
|
||||
RESOLUTION, upper=True, space="_"
|
||||
),
|
||||
@@ -80,13 +71,11 @@ CONFIG_SCHEMA = (
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_ADS1115_ID])
|
||||
var = cg.new_Pvariable(config[CONF_ID], paren)
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await sensor.register_sensor(var, config)
|
||||
await cg.register_component(var, config)
|
||||
await cg.register_parented(var, config[CONF_ADS1115_ID])
|
||||
|
||||
cg.add(var.set_multiplexer(config[CONF_MULTIPLEXER]))
|
||||
cg.add(var.set_gain(config[CONF_GAIN]))
|
||||
cg.add(var.set_resolution(config[CONF_RESOLUTION]))
|
||||
|
||||
cg.add(paren.register_sensor(var))
|
||||
30
esphome/components/ads1115/sensor/ads1115_sensor.cpp
Normal file
30
esphome/components/ads1115/sensor/ads1115_sensor.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "ads1115_sensor.h"
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ads1115 {
|
||||
|
||||
static const char *const TAG = "ads1115.sensor";
|
||||
|
||||
float ADS1115Sensor::sample() {
|
||||
return this->parent_->request_measurement(this->multiplexer_, this->gain_, this->resolution_);
|
||||
}
|
||||
|
||||
void ADS1115Sensor::update() {
|
||||
float v = this->sample();
|
||||
if (!std::isnan(v)) {
|
||||
ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
|
||||
this->publish_state(v);
|
||||
}
|
||||
}
|
||||
|
||||
void ADS1115Sensor::dump_config() {
|
||||
LOG_SENSOR(" ", "ADS1115 Sensor", this);
|
||||
ESP_LOGCONFIG(TAG, " Multiplexer: %u", this->multiplexer_);
|
||||
ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_);
|
||||
ESP_LOGCONFIG(TAG, " Resolution: %u", this->resolution_);
|
||||
}
|
||||
|
||||
} // namespace ads1115
|
||||
} // namespace esphome
|
||||
35
esphome/components/ads1115/sensor/ads1115_sensor.h
Normal file
35
esphome/components/ads1115/sensor/ads1115_sensor.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/voltage_sampler/voltage_sampler.h"
|
||||
|
||||
#include "../ads1115.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace ads1115 {
|
||||
|
||||
/// Internal holder class that is in instance of Sensor so that the hub can create individual sensors.
|
||||
class ADS1115Sensor : public sensor::Sensor,
|
||||
public PollingComponent,
|
||||
public voltage_sampler::VoltageSampler,
|
||||
public Parented<ADS1115Component> {
|
||||
public:
|
||||
void update() override;
|
||||
void set_multiplexer(ADS1115Multiplexer multiplexer) { this->multiplexer_ = multiplexer; }
|
||||
void set_gain(ADS1115Gain gain) { this->gain_ = gain; }
|
||||
void set_resolution(ADS1115Resolution resolution) { this->resolution_ = resolution; }
|
||||
float sample() override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
ADS1115Multiplexer multiplexer_;
|
||||
ADS1115Gain gain_;
|
||||
ADS1115Resolution resolution_;
|
||||
};
|
||||
|
||||
} // namespace ads1115
|
||||
} // namespace esphome
|
||||
@@ -316,17 +316,26 @@ def _parse_platform_version(value):
|
||||
|
||||
|
||||
def _detect_variant(value):
|
||||
if CONF_VARIANT not in value:
|
||||
board = value[CONF_BOARD]
|
||||
if board not in BOARDS:
|
||||
board = value[CONF_BOARD]
|
||||
if board in BOARDS:
|
||||
variant = BOARDS[board][KEY_VARIANT]
|
||||
if CONF_VARIANT in value and variant != value[CONF_VARIANT]:
|
||||
raise cv.Invalid(
|
||||
"This board is unknown, please set the variant manually",
|
||||
f"Option '{CONF_VARIANT}' does not match selected board.",
|
||||
path=[CONF_VARIANT],
|
||||
)
|
||||
value = value.copy()
|
||||
value[CONF_VARIANT] = variant
|
||||
else:
|
||||
if CONF_VARIANT not in value:
|
||||
raise cv.Invalid(
|
||||
"This board is unknown, if you are sure you want to compile with this board selection, "
|
||||
f"override with option '{CONF_VARIANT}'",
|
||||
path=[CONF_BOARD],
|
||||
)
|
||||
|
||||
value = value.copy()
|
||||
value[CONF_VARIANT] = BOARDS[board][KEY_VARIANT]
|
||||
|
||||
_LOGGER.warning(
|
||||
"This board is unknown. Make sure the chosen chip component is correct.",
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -364,7 +364,11 @@ void ESP32BLETracker::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_ga
|
||||
}
|
||||
|
||||
void ESP32BLETracker::gap_scan_set_param_complete_(const esp_ble_gap_cb_param_t::ble_scan_param_cmpl_evt_param ¶m) {
|
||||
this->scan_set_param_failed_ = param.status;
|
||||
if (param.status == ESP_BT_STATUS_DONE) {
|
||||
this->scan_set_param_failed_ = ESP_BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
this->scan_set_param_failed_ = param.status;
|
||||
}
|
||||
}
|
||||
|
||||
void ESP32BLETracker::gap_scan_start_complete_(const esp_ble_gap_cb_param_t::ble_scan_start_cmpl_evt_param ¶m) {
|
||||
|
||||
@@ -32,7 +32,7 @@ void FT63X6Touchscreen::setup() {
|
||||
if (this->interrupt_pin_ != nullptr) {
|
||||
this->interrupt_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
|
||||
this->interrupt_pin_->setup();
|
||||
this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_FALLING_EDGE);
|
||||
this->attach_interrupt_(this->interrupt_pin_, gpio::INTERRUPT_ANY_EDGE);
|
||||
}
|
||||
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
@@ -78,13 +78,12 @@ void FT63X6Touchscreen::update_touches() {
|
||||
uint16_t touch_id, x, y;
|
||||
|
||||
uint8_t touches = this->read_touch_number_();
|
||||
ESP_LOGV(TAG, "Touches found: %d", touches);
|
||||
if ((touches == 0x00) || (touches == 0xff)) {
|
||||
// ESP_LOGD(TAG, "No touches detected");
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "Touches found: %d", touches);
|
||||
|
||||
for (auto point = 0; point < touches; point++) {
|
||||
if (((this->read_touch_event_(point)) & 0x01) == 0) { // checking event flag bit 6 if it is null
|
||||
touch_id = this->read_touch_id_(point); // id1 = 0 or 1
|
||||
|
||||
@@ -55,11 +55,13 @@ void InternalTemperatureSensor::update() {
|
||||
uint32_t raw, result;
|
||||
result = temp_single_get_current_temperature(&raw);
|
||||
success = (result == 0);
|
||||
#ifdef USE_LIBRETINY_VARIANT_BK7231T
|
||||
#if defined(USE_LIBRETINY_VARIANT_BK7231N)
|
||||
temperature = raw * -0.38f + 156.0f;
|
||||
#elif defined(USE_LIBRETINY_VARIANT_BK7231T)
|
||||
temperature = raw * 0.04f;
|
||||
#else
|
||||
#else // USE_LIBRETINY_VARIANT
|
||||
temperature = raw * 0.128f;
|
||||
#endif // USE_LIBRETINY_VARIANT_BK7231T
|
||||
#endif // USE_LIBRETINY_VARIANT
|
||||
#endif // USE_BK72XX
|
||||
if (success && std::isfinite(temperature)) {
|
||||
this->publish_state(temperature);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import json
|
||||
import logging
|
||||
from os.path import dirname, isfile, join
|
||||
from os.path import (
|
||||
dirname,
|
||||
isfile,
|
||||
join,
|
||||
)
|
||||
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
@@ -55,15 +59,25 @@ def _detect_variant(value):
|
||||
component: LibreTinyComponent = CORE.data[KEY_LIBRETINY][KEY_COMPONENT_DATA]
|
||||
board = value[CONF_BOARD]
|
||||
# read board-default family if not specified
|
||||
if CONF_FAMILY not in value:
|
||||
if board not in component.boards:
|
||||
if board not in component.boards:
|
||||
if CONF_FAMILY not in value:
|
||||
raise cv.Invalid(
|
||||
"This board is unknown, please set the family manually. "
|
||||
"Also, make sure the chosen chip component is correct.",
|
||||
"This board is unknown, if you are sure you want to compile with this board selection, "
|
||||
f"override with option '{CONF_FAMILY}'",
|
||||
path=[CONF_BOARD],
|
||||
)
|
||||
_LOGGER.warning(
|
||||
"This board is unknown. Make sure the chosen chip component is correct.",
|
||||
)
|
||||
else:
|
||||
family = component.boards[board][KEY_FAMILY]
|
||||
if CONF_FAMILY in value and family != value[CONF_FAMILY]:
|
||||
raise cv.Invalid(
|
||||
f"Option '{CONF_FAMILY}' does not match selected board.",
|
||||
path=[CONF_FAMILY],
|
||||
)
|
||||
value = value.copy()
|
||||
value[CONF_FAMILY] = component.boards[board][KEY_FAMILY]
|
||||
value[CONF_FAMILY] = family
|
||||
# read component name matching this family
|
||||
value[CONF_COMPONENT_ID] = FAMILY_COMPONENT[value[CONF_FAMILY]]
|
||||
# make sure the chosen component matches the family
|
||||
@@ -72,11 +86,6 @@ def _detect_variant(value):
|
||||
f"The chosen family doesn't belong to '{component.name}' component. The correct component is '{value[CONF_COMPONENT_ID]}'",
|
||||
path=[CONF_FAMILY],
|
||||
)
|
||||
# warn anyway if the board wasn't found
|
||||
if board not in component.boards:
|
||||
_LOGGER.warning(
|
||||
"This board is unknown. Make sure the chosen chip component is correct.",
|
||||
)
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -359,11 +359,15 @@ OrFilter::OrFilter(std::vector<Filter *> filters) : filters_(std::move(filters))
|
||||
OrFilter::PhiNode::PhiNode(OrFilter *or_parent) : or_parent_(or_parent) {}
|
||||
|
||||
optional<float> OrFilter::PhiNode::new_value(float value) {
|
||||
this->or_parent_->output(value);
|
||||
if (!this->or_parent_->has_value_) {
|
||||
this->or_parent_->output(value);
|
||||
this->or_parent_->has_value_ = true;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
optional<float> OrFilter::new_value(float value) {
|
||||
this->has_value_ = false;
|
||||
for (Filter *filter : this->filters_)
|
||||
filter->input(value);
|
||||
|
||||
|
||||
@@ -388,6 +388,7 @@ class OrFilter : public Filter {
|
||||
};
|
||||
|
||||
std::vector<Filter *> filters_;
|
||||
bool has_value_{false};
|
||||
PhiNode phi_;
|
||||
};
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ async def to_code(config):
|
||||
cg.add(var.set_switch_id(switch_datapoint))
|
||||
|
||||
if active_state_config := config.get(CONF_ACTIVE_STATE):
|
||||
cg.add(var.set_active_state_id(CONF_DATAPOINT))
|
||||
cg.add(var.set_active_state_id(active_state_config.get(CONF_DATAPOINT)))
|
||||
if (heating_value := active_state_config.get(CONF_HEATING_VALUE)) is not None:
|
||||
cg.add(var.set_active_state_heating_value(heating_value))
|
||||
if (cooling_value := active_state_config.get(CONF_COOLING_VALUE)) is not None:
|
||||
@@ -219,14 +219,10 @@ async def to_code(config):
|
||||
cg.add(var.set_active_state_fanonly_value(fanonly_value))
|
||||
else:
|
||||
if heating_state_pin_config := config.get(CONF_HEATING_STATE_PIN):
|
||||
heating_state_pin = await cg.gpio_pin_expression(
|
||||
config(heating_state_pin_config)
|
||||
)
|
||||
heating_state_pin = await cg.gpio_pin_expression(heating_state_pin_config)
|
||||
cg.add(var.set_heating_state_pin(heating_state_pin))
|
||||
if cooling_state_pin_config := config.get(CONF_COOLING_STATE_PIN):
|
||||
cooling_state_pin = await cg.gpio_pin_expression(
|
||||
config(cooling_state_pin_config)
|
||||
)
|
||||
cooling_state_pin = await cg.gpio_pin_expression(cooling_state_pin_config)
|
||||
cg.add(var.set_cooling_state_pin(cooling_state_pin))
|
||||
|
||||
if target_temperature_datapoint := config.get(CONF_TARGET_TEMPERATURE_DATAPOINT):
|
||||
@@ -254,11 +250,11 @@ async def to_code(config):
|
||||
|
||||
if preset_config := config.get(CONF_PRESET, {}):
|
||||
if eco_config := preset_config.get(CONF_ECO, {}):
|
||||
cg.add(var.set_eco_id(CONF_DATAPOINT))
|
||||
cg.add(var.set_eco_id(eco_config.get(CONF_DATAPOINT)))
|
||||
if eco_temperature := eco_config.get(CONF_TEMPERATURE):
|
||||
cg.add(var.set_eco_temperature(eco_temperature))
|
||||
if CONF_SLEEP in preset_config:
|
||||
cg.add(var.set_sleep_id(CONF_DATAPOINT))
|
||||
if sleep_config := preset_config.get(CONF_SLEEP, {}):
|
||||
cg.add(var.set_sleep_id(sleep_config.get(CONF_DATAPOINT)))
|
||||
|
||||
if swing_mode_config := config.get(CONF_SWING_MODE):
|
||||
if swing_vertical_datapoint := swing_mode_config.get(CONF_VERTICAL_DATAPOINT):
|
||||
@@ -268,7 +264,7 @@ async def to_code(config):
|
||||
):
|
||||
cg.add(var.set_swing_horizontal_id(swing_horizontal_datapoint))
|
||||
if fan_mode_config := config.get(CONF_FAN_MODE):
|
||||
cg.add(var.set_fan_speed_id(CONF_DATAPOINT))
|
||||
cg.add(var.set_fan_speed_id(fan_mode_config.get(CONF_DATAPOINT)))
|
||||
if (fan_auto_value := fan_mode_config.get(CONF_AUTO_VALUE)) is not None:
|
||||
cg.add(var.set_fan_speed_auto_value(fan_auto_value))
|
||||
if (fan_low_value := fan_mode_config.get(CONF_LOW_VALUE)) is not None:
|
||||
|
||||
@@ -729,6 +729,7 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
|
||||
}
|
||||
|
||||
void VoiceAssistant::on_audio(const api::VoiceAssistantAudio &msg) {
|
||||
#ifdef USE_SPEAKER // We should never get to this function if there is no speaker anyway
|
||||
if (this->speaker_buffer_index_ + msg.data.length() < SPEAKER_BUFFER_SIZE) {
|
||||
memcpy(this->speaker_buffer_ + this->speaker_buffer_index_, msg.data.data(), msg.data.length());
|
||||
this->speaker_buffer_index_ += msg.data.length();
|
||||
@@ -737,6 +738,7 @@ void VoiceAssistant::on_audio(const api::VoiceAssistantAudio &msg) {
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Cannot receive audio, buffer is full");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
VoiceAssistant *global_voice_assistant = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
||||
@@ -128,7 +128,7 @@ void WiFiComponent::loop() {
|
||||
case WIFI_COMPONENT_STATE_COOLDOWN: {
|
||||
this->status_set_warning();
|
||||
if (millis() - this->action_started_ > 5000) {
|
||||
if (this->fast_connect_) {
|
||||
if (this->fast_connect_ || this->retry_hidden_) {
|
||||
this->start_connecting(this->sta_[0], false);
|
||||
} else {
|
||||
this->start_scanning();
|
||||
@@ -591,6 +591,9 @@ void WiFiComponent::check_connecting_finished() {
|
||||
return;
|
||||
}
|
||||
|
||||
// We won't retry hidden networks unless a reconnect fails more than three times again
|
||||
this->retry_hidden_ = false;
|
||||
|
||||
ESP_LOGI(TAG, "WiFi Connected!");
|
||||
this->print_connect_params_();
|
||||
|
||||
@@ -668,10 +671,11 @@ void WiFiComponent::retry_connect() {
|
||||
this->wifi_mode_(false, {});
|
||||
delay(100); // NOLINT
|
||||
this->num_retried_ = 0;
|
||||
this->retry_hidden_ = false;
|
||||
} else {
|
||||
// Try hidden networks after 3 failed retries
|
||||
ESP_LOGD(TAG, "Retrying with hidden networks...");
|
||||
this->fast_connect_ = true;
|
||||
this->retry_hidden_ = true;
|
||||
this->num_retried_++;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -371,6 +371,7 @@ class WiFiComponent : public Component {
|
||||
std::vector<WiFiSTAPriority> sta_priorities_;
|
||||
WiFiAP selected_ap_;
|
||||
bool fast_connect_{false};
|
||||
bool retry_hidden_{false};
|
||||
|
||||
bool has_ap_{false};
|
||||
WiFiAP ap_;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2024.4.0b1"
|
||||
__version__ = "2024.4.1"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
||||
@@ -134,7 +134,7 @@ class ProjectUpdateTrigger : public Trigger<std::string>, public Component {
|
||||
uint32_t hash = fnv1_hash(ESPHOME_PROJECT_NAME);
|
||||
ESPPreferenceObject pref = global_preferences->make_preference<char[30]>(hash, true);
|
||||
char previous_version[30];
|
||||
char current_version[30] = ESPHOME_PROJECT_VERSION;
|
||||
char current_version[30] = ESPHOME_PROJECT_VERSION_30;
|
||||
if (pref.load(&previous_version)) {
|
||||
int cmp = strcmp(previous_version, current_version);
|
||||
if (cmp < 0) {
|
||||
|
||||
@@ -394,6 +394,7 @@ async def to_code(config):
|
||||
if project_conf := config.get(CONF_PROJECT):
|
||||
cg.add_define("ESPHOME_PROJECT_NAME", project_conf[CONF_NAME])
|
||||
cg.add_define("ESPHOME_PROJECT_VERSION", project_conf[CONF_VERSION])
|
||||
cg.add_define("ESPHOME_PROJECT_VERSION_30", project_conf[CONF_VERSION][:30])
|
||||
for conf in project_conf.get(CONF_ON_UPDATE, []):
|
||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
|
||||
await cg.register_component(trigger, conf)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define ESPHOME_BOARD "dummy_board"
|
||||
#define ESPHOME_PROJECT_NAME "dummy project"
|
||||
#define ESPHOME_PROJECT_VERSION "v2"
|
||||
#define ESPHOME_PROJECT_VERSION_30 "v2"
|
||||
#define ESPHOME_VARIANT "ESP32"
|
||||
|
||||
// Feature flags
|
||||
|
||||
@@ -10,6 +10,7 @@ import paho.mqtt.client as mqtt
|
||||
|
||||
from esphome.const import (
|
||||
CONF_BROKER,
|
||||
CONF_CERTIFICATE_AUTHORITY,
|
||||
CONF_DISCOVERY_PREFIX,
|
||||
CONF_ESPHOME,
|
||||
CONF_LOG_TOPIC,
|
||||
@@ -99,7 +100,9 @@ def prepare(
|
||||
elif username:
|
||||
client.username_pw_set(username, password)
|
||||
|
||||
if config[CONF_MQTT].get(CONF_SSL_FINGERPRINTS):
|
||||
if config[CONF_MQTT].get(CONF_SSL_FINGERPRINTS) or config[CONF_MQTT].get(
|
||||
CONF_CERTIFICATE_AUTHORITY
|
||||
):
|
||||
if sys.version_info >= (2, 7, 13):
|
||||
tls_version = ssl.PROTOCOL_TLS # pylint: disable=no-member
|
||||
else:
|
||||
|
||||
@@ -12,7 +12,7 @@ pyserial==3.5
|
||||
platformio==6.1.13 # When updating platformio, also update Dockerfile
|
||||
esptool==4.7.0
|
||||
click==8.1.7
|
||||
esphome-dashboard==20240319.0
|
||||
esphome-dashboard==20240412.0
|
||||
aioesphomeapi==23.2.0
|
||||
zeroconf==0.131.0
|
||||
python-magic==0.4.27
|
||||
|
||||
3
tests/components/internal_temperature/test.bk72xx.yaml
Normal file
3
tests/components/internal_temperature/test.bk72xx.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
3
tests/components/internal_temperature/test.esp32-c3.yaml
Normal file
3
tests/components/internal_temperature/test.esp32-c3.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
3
tests/components/internal_temperature/test.esp32.yaml
Normal file
3
tests/components/internal_temperature/test.esp32.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
3
tests/components/internal_temperature/test.rp2040.yaml
Normal file
3
tests/components/internal_temperature/test.rp2040.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
sensor:
|
||||
- platform: internal_temperature
|
||||
name: "Internal Temperature"
|
||||
@@ -176,3 +176,11 @@ button:
|
||||
0x00,
|
||||
0x05,
|
||||
]
|
||||
- platform: template
|
||||
name: Dooya
|
||||
on_press:
|
||||
remote_transmitter.transmit_dooya:
|
||||
id: 0x123456
|
||||
channel: 1
|
||||
button: 1
|
||||
check: 1
|
||||
|
||||
Reference in New Issue
Block a user