mirror of
https://github.com/esphome/esphome.git
synced 2024-11-13 02:37:47 +01:00
commit
546bfe6db5
4 changed files with 45 additions and 36 deletions
|
@ -148,7 +148,7 @@ WakeWordModel::WakeWordModel(const uint8_t *model_start, float probability_cutof
|
||||||
};
|
};
|
||||||
|
|
||||||
bool WakeWordModel::determine_detected() {
|
bool WakeWordModel::determine_detected() {
|
||||||
int32_t sum = 0;
|
uint32_t sum = 0;
|
||||||
for (auto &prob : this->recent_streaming_probabilities_) {
|
for (auto &prob : this->recent_streaming_probabilities_) {
|
||||||
sum += prob;
|
sum += prob;
|
||||||
}
|
}
|
||||||
|
@ -175,12 +175,14 @@ VADModel::VADModel(const uint8_t *model_start, float probability_cutoff, size_t
|
||||||
};
|
};
|
||||||
|
|
||||||
bool VADModel::determine_detected() {
|
bool VADModel::determine_detected() {
|
||||||
uint8_t max = 0;
|
uint32_t sum = 0;
|
||||||
for (auto &prob : this->recent_streaming_probabilities_) {
|
for (auto &prob : this->recent_streaming_probabilities_) {
|
||||||
max = std::max(prob, max);
|
sum += prob;
|
||||||
}
|
}
|
||||||
|
|
||||||
return max > this->probability_cutoff_;
|
float sliding_window_average = static_cast<float>(sum) / static_cast<float>(255 * this->sliding_window_size_);
|
||||||
|
|
||||||
|
return sliding_window_average > this->probability_cutoff_;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace micro_wake_word
|
} // namespace micro_wake_word
|
||||||
|
|
|
@ -110,7 +110,7 @@ void MitsubishiClimate::transmit_state() {
|
||||||
// Byte 15: HVAC specfic, i.e. POWERFUL, SMART SET, PLASMA, always 0x00
|
// Byte 15: HVAC specfic, i.e. POWERFUL, SMART SET, PLASMA, always 0x00
|
||||||
// Byte 16: Constant 0x00
|
// Byte 16: Constant 0x00
|
||||||
// Byte 17: Checksum: SUM[Byte0...Byte16]
|
// Byte 17: Checksum: SUM[Byte0...Byte16]
|
||||||
uint8_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x00, 0x00,
|
uint8_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||||
|
|
||||||
switch (this->mode) {
|
switch (this->mode) {
|
||||||
|
@ -136,6 +136,12 @@ void MitsubishiClimate::transmit_state() {
|
||||||
break;
|
break;
|
||||||
case climate::CLIMATE_MODE_OFF:
|
case climate::CLIMATE_MODE_OFF:
|
||||||
default:
|
default:
|
||||||
|
remote_state[6] = MITSUBISHI_MODE_COOL;
|
||||||
|
remote_state[8] = MITSUBISHI_MODE_A_COOL;
|
||||||
|
if (this->supports_heat_) {
|
||||||
|
remote_state[6] = MITSUBISHI_MODE_HEAT;
|
||||||
|
remote_state[8] = MITSUBISHI_MODE_A_HEAT;
|
||||||
|
}
|
||||||
remote_state[5] = MITSUBISHI_OFF;
|
remote_state[5] = MITSUBISHI_OFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,18 +72,18 @@ void PMWCS3Component::dump_config() {
|
||||||
LOG_SENSOR(" ", "vwc", this->vwc_sensor_);
|
LOG_SENSOR(" ", "vwc", this->vwc_sensor_);
|
||||||
}
|
}
|
||||||
void PMWCS3Component::read_data_() {
|
void PMWCS3Component::read_data_() {
|
||||||
uint8_t data[8];
|
|
||||||
float e25, ec, temperature, vwc;
|
|
||||||
|
|
||||||
/////// Super important !!!! first activate reading PMWCS3_REG_READ_START (if not, return always the same values) ////
|
/////// Super important !!!! first activate reading PMWCS3_REG_READ_START (if not, return always the same values) ////
|
||||||
|
|
||||||
if (!this->write_bytes(PMWCS3_REG_READ_START, nullptr, 0)) {
|
if (!this->write_bytes(PMWCS3_REG_READ_START, nullptr, 0)) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
ESP_LOGVV(TAG, "Failed to write into REG_READ_START register !!!");
|
ESP_LOGVV(TAG, "Failed to write into REG_READ_START register !!!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// NOLINT delay(100);
|
|
||||||
|
|
||||||
|
// Wait for the sensor to be ready.
|
||||||
|
// 80ms empirically determined (conservative).
|
||||||
|
this->set_timeout(80, [this] {
|
||||||
|
uint8_t data[8];
|
||||||
|
float e25, ec, temperature, vwc;
|
||||||
if (!this->read_bytes(PMWCS3_REG_GET_DATA, (uint8_t *) &data, 8)) {
|
if (!this->read_bytes(PMWCS3_REG_GET_DATA, (uint8_t *) &data, 8)) {
|
||||||
ESP_LOGVV(TAG, "Error reading PMWCS3_REG_GET_DATA registers");
|
ESP_LOGVV(TAG, "Error reading PMWCS3_REG_GET_DATA registers");
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
|
@ -109,6 +109,7 @@ void PMWCS3Component::read_data_() {
|
||||||
this->vwc_sensor_->publish_state(vwc);
|
this->vwc_sensor_->publish_state(vwc);
|
||||||
ESP_LOGVV(TAG, "vwc: data[6]=%d, data[7]=%d, result=%f", data[6], data[7], vwc);
|
ESP_LOGVV(TAG, "vwc: data[6]=%d, data[7]=%d, result=%f", data[6], data[7], vwc);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace pmwcs3
|
} // namespace pmwcs3
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2024.7.2"
|
__version__ = "2024.7.3"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||||
|
|
Loading…
Reference in a new issue