mirror of
https://github.com/esphome/esphome.git
synced 2024-12-27 16:01:43 +01:00
commit
7be9291b13
8 changed files with 23 additions and 7 deletions
|
@ -104,21 +104,21 @@ void AnovaCodec::decode(const uint8_t *data, uint16_t length) {
|
|||
break;
|
||||
}
|
||||
case READ_TARGET_TEMPERATURE: {
|
||||
this->target_temp_ = parse_number<float>(buf, sizeof(buf)).value_or(0.0f);
|
||||
this->target_temp_ = parse_number<float>(str_until(buf, '\r')).value_or(0.0f);
|
||||
if (this->fahrenheit_)
|
||||
this->target_temp_ = ftoc(this->target_temp_);
|
||||
this->has_target_temp_ = true;
|
||||
break;
|
||||
}
|
||||
case SET_TARGET_TEMPERATURE: {
|
||||
this->target_temp_ = parse_number<float>(buf, sizeof(buf)).value_or(0.0f);
|
||||
this->target_temp_ = parse_number<float>(str_until(buf, '\r')).value_or(0.0f);
|
||||
if (this->fahrenheit_)
|
||||
this->target_temp_ = ftoc(this->target_temp_);
|
||||
this->has_target_temp_ = true;
|
||||
break;
|
||||
}
|
||||
case READ_CURRENT_TEMPERATURE: {
|
||||
this->current_temp_ = parse_number<float>(buf, sizeof(buf)).value_or(0.0f);
|
||||
this->current_temp_ = parse_number<float>(str_until(buf, '\r')).value_or(0.0f);
|
||||
if (this->fahrenheit_)
|
||||
this->current_temp_ = ftoc(this->current_temp_);
|
||||
this->has_current_temp_ = true;
|
||||
|
|
|
@ -42,7 +42,7 @@ class ColorUtil {
|
|||
? esp_scale(((colorcode >> third_bits) & ((1 << second_bits) - 1)), ((1 << second_bits) - 1))
|
||||
: esp_scale(((colorcode >> 8) & 0xFF), ((1 << second_bits) - 1));
|
||||
|
||||
third_color = (right_bit_aligned ? esp_scale(((colorcode >> 0) & 0xFF), ((1 << third_bits) - 1))
|
||||
third_color = (right_bit_aligned ? esp_scale(((colorcode >> 0) & ((1 << third_bits) - 1)), ((1 << third_bits) - 1))
|
||||
: esp_scale(((colorcode >> 0) & 0xFF), (1 << third_bits) - 1));
|
||||
|
||||
Color color_return;
|
||||
|
|
|
@ -74,6 +74,11 @@ void EZOSensor::loop() {
|
|||
if (buf[0] != 1)
|
||||
return;
|
||||
|
||||
// some sensors return multiple comma-separated values, terminate string after first one
|
||||
for (int i = 1; i < sizeof(buf) - 1; i++)
|
||||
if (buf[i] == ',')
|
||||
buf[i] = '\0';
|
||||
|
||||
float val = parse_number<float>((char *) &buf[1], sizeof(buf) - 2).value_or(0);
|
||||
this->publish_state(val);
|
||||
}
|
||||
|
|
|
@ -200,6 +200,7 @@ bool SCD30Component::is_data_ready_() {
|
|||
if (!this->write_command_(SCD30_CMD_GET_DATA_READY_STATUS)) {
|
||||
return false;
|
||||
}
|
||||
delay(4);
|
||||
uint16_t is_data_ready;
|
||||
if (!this->read_data_(&is_data_ready, 1)) {
|
||||
return false;
|
||||
|
|
|
@ -375,8 +375,7 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
|
|||
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_set_password failed! %d", err);
|
||||
}
|
||||
}
|
||||
esp_wpa2_config_t wpa2_config = WPA2_CONFIG_INIT_DEFAULT();
|
||||
err = esp_wifi_sta_wpa2_ent_enable(&wpa2_config);
|
||||
err = esp_wifi_sta_wpa2_ent_enable();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGV(TAG, "esp_wifi_sta_wpa2_ent_enable failed! %d", err);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2021.11.3"
|
||||
__version__ = "2021.11.4"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
|
|
|
@ -444,6 +444,11 @@ IRAM_ATTR InterruptLock::~InterruptLock() { portENABLE_INTERRUPTS(); }
|
|||
std::string str_truncate(const std::string &str, size_t length) {
|
||||
return str.length() > length ? str.substr(0, length) : str;
|
||||
}
|
||||
std::string str_until(const char *str, char ch) {
|
||||
char *pos = strchr(str, ch);
|
||||
return pos == nullptr ? std::string(str) : std::string(str, pos - str);
|
||||
}
|
||||
std::string str_until(const std::string &str, char ch) { return str.substr(0, str.find(ch)); }
|
||||
std::string str_snake_case(const std::string &str) {
|
||||
std::string result;
|
||||
result.resize(str.length());
|
||||
|
|
|
@ -351,6 +351,12 @@ template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> constexpr
|
|||
/// Truncate a string to a specific length.
|
||||
std::string str_truncate(const std::string &str, size_t length);
|
||||
|
||||
/// Extract the part of the string until either the first occurence of the specified character, or the end (requires str
|
||||
/// to be null-terminated).
|
||||
std::string str_until(const char *str, char ch);
|
||||
/// Extract the part of the string until either the first occurence of the specified character, or the end.
|
||||
std::string str_until(const std::string &str, char ch);
|
||||
|
||||
/// Convert the string to snake case (lowercase with underscores).
|
||||
std::string str_snake_case(const std::string &str);
|
||||
|
||||
|
|
Loading…
Reference in a new issue