mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 17:27:45 +01:00
commit
0709367587
8 changed files with 631 additions and 604 deletions
|
@ -57,6 +57,10 @@ void MDNSComponent::compile_records_() {
|
||||||
service.txt_records.push_back({"network", "ethernet"});
|
service.txt_records.push_back({"network", "ethernet"});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_API_NOISE
|
||||||
|
service.txt_records.push_back({"api_encryption", "Noise_NNpsk0_25519_ChaChaPoly_SHA256"});
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ESPHOME_PROJECT_NAME
|
#ifdef ESPHOME_PROJECT_NAME
|
||||||
service.txt_records.push_back({"project_name", ESPHOME_PROJECT_NAME});
|
service.txt_records.push_back({"project_name", ESPHOME_PROJECT_NAME});
|
||||||
service.txt_records.push_back({"project_version", ESPHOME_PROJECT_VERSION});
|
service.txt_records.push_back({"project_version", ESPHOME_PROJECT_VERSION});
|
||||||
|
|
|
@ -42,13 +42,18 @@ void SCD30Component::setup() {
|
||||||
ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8),
|
ESP_LOGD(TAG, "SCD30 Firmware v%0d.%02d", (uint16_t(raw_firmware_version[0]) >> 8),
|
||||||
uint16_t(raw_firmware_version[0] & 0xFF));
|
uint16_t(raw_firmware_version[0] & 0xFF));
|
||||||
|
|
||||||
if (this->temperature_offset_ != 0) {
|
uint16_t temp_offset;
|
||||||
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, (uint16_t) (temperature_offset_ * 100.0))) {
|
if (this->temperature_offset_ > 0) {
|
||||||
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
|
temp_offset = (this->temperature_offset_ * 100);
|
||||||
this->error_code_ = MEASUREMENT_INIT_FAILED;
|
} else {
|
||||||
this->mark_failed();
|
temp_offset = 0;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
if (!this->write_command(SCD30_CMD_TEMPERATURE_OFFSET, temp_offset)) {
|
||||||
|
ESP_LOGE(TAG, "Sensor SCD30 error setting temperature offset.");
|
||||||
|
this->error_code_ = MEASUREMENT_INIT_FAILED;
|
||||||
|
this->mark_failed();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
// According ESP32 clock stretching is typically 30ms and up to 150ms "due to
|
// According ESP32 clock stretching is typically 30ms and up to 150ms "due to
|
||||||
|
|
|
@ -68,7 +68,10 @@ CONFIG_SCHEMA = (
|
||||||
cv.int_range(min=0, max=0xFFFF, max_included=False),
|
cv.int_range(min=0, max=0xFFFF, max_included=False),
|
||||||
),
|
),
|
||||||
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure,
|
cv.Optional(CONF_AMBIENT_PRESSURE_COMPENSATION, default=0): cv.pressure,
|
||||||
cv.Optional(CONF_TEMPERATURE_OFFSET): cv.temperature,
|
cv.Optional(CONF_TEMPERATURE_OFFSET): cv.All(
|
||||||
|
cv.temperature,
|
||||||
|
cv.float_range(min=0, max=655.35),
|
||||||
|
),
|
||||||
cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All(
|
cv.Optional(CONF_UPDATE_INTERVAL, default="60s"): cv.All(
|
||||||
cv.positive_time_period_seconds,
|
cv.positive_time_period_seconds,
|
||||||
cv.Range(
|
cv.Range(
|
||||||
|
|
|
@ -6,11 +6,21 @@ namespace template_ {
|
||||||
|
|
||||||
static const char *const TAG = "template.binary_sensor";
|
static const char *const TAG = "template.binary_sensor";
|
||||||
|
|
||||||
void TemplateBinarySensor::loop() {
|
void TemplateBinarySensor::setup() {
|
||||||
if (!this->f_.has_value())
|
if (!this->publish_initial_state_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto s = (*this->f_)();
|
if (this->f_ != nullptr) {
|
||||||
|
this->publish_initial_state(*this->f_());
|
||||||
|
} else {
|
||||||
|
this->publish_initial_state(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void TemplateBinarySensor::loop() {
|
||||||
|
if (this->f_ == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto s = this->f_();
|
||||||
if (s.has_value()) {
|
if (s.has_value()) {
|
||||||
this->publish_state(*s);
|
this->publish_state(*s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,14 @@ class TemplateBinarySensor : public Component, public binary_sensor::BinarySenso
|
||||||
public:
|
public:
|
||||||
void set_template(std::function<optional<bool>()> &&f) { this->f_ = f; }
|
void set_template(std::function<optional<bool>()> &&f) { this->f_ = f; }
|
||||||
|
|
||||||
|
void setup() override;
|
||||||
void loop() override;
|
void loop() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
optional<std::function<optional<bool>()>> f_{};
|
std::function<optional<bool>()> f_{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace template_
|
} // namespace template_
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -108,6 +108,7 @@ ROOT_CONFIG_PATH = object()
|
||||||
|
|
||||||
RESERVED_IDS = [
|
RESERVED_IDS = [
|
||||||
# C++ keywords http://en.cppreference.com/w/cpp/keyword
|
# C++ keywords http://en.cppreference.com/w/cpp/keyword
|
||||||
|
"alarm",
|
||||||
"alignas",
|
"alignas",
|
||||||
"alignof",
|
"alignof",
|
||||||
"and",
|
"and",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2023.6.3"
|
__version__ = "2023.6.4"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|
Loading…
Reference in a new issue