mirror of
https://github.com/esphome/esphome.git
synced 2024-12-24 16:58:07 +01:00
Dallas improve warnings
This commit is contained in:
parent
5a76e61b1e
commit
840f599631
@ -132,10 +132,14 @@ void DallasComponent::update() {
|
|||||||
enable_interrupts();
|
enable_interrupts();
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
ESP_LOGW(TAG, "'%s' - Reseting bus for read failed!", sensor->get_name().c_str());
|
||||||
|
sensor->publish_state(NAN);
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!sensor->check_scratch_pad()) {
|
if (!sensor->check_scratch_pad()) {
|
||||||
|
ESP_LOGW(TAG, "'%s' - Scratch pad checksum invalid!", sensor->get_name().c_str());
|
||||||
|
sensor->publish_state(NAN);
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -244,11 +248,7 @@ bool DallasTemperatureSensor::check_scratch_pad() {
|
|||||||
this->scratch_pad_[5], this->scratch_pad_[6], this->scratch_pad_[7], this->scratch_pad_[8],
|
this->scratch_pad_[5], this->scratch_pad_[6], this->scratch_pad_[7], this->scratch_pad_[8],
|
||||||
crc8(this->scratch_pad_, 8));
|
crc8(this->scratch_pad_, 8));
|
||||||
#endif
|
#endif
|
||||||
if (crc8(this->scratch_pad_, 8) != this->scratch_pad_[8]) {
|
return crc8(this->scratch_pad_, 8) == this->scratch_pad_[8];
|
||||||
ESP_LOGE(TAG, "Reading scratchpad from Dallas Sensor failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
float DallasTemperatureSensor::get_temp_c() {
|
float DallasTemperatureSensor::get_temp_c() {
|
||||||
int16_t temp = (int16_t(this->scratch_pad_[1]) << 11) | (int16_t(this->scratch_pad_[0]) << 3);
|
int16_t temp = (int16_t(this->scratch_pad_[1]) << 11) | (int16_t(this->scratch_pad_[0]) << 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user