mirror of
https://github.com/esphome/esphome.git
synced 2026-02-08 00:31:58 +00:00
[mopeka_pro_check] Fix negative temperatures (#12198)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -116,7 +116,7 @@ bool MopekaProCheck::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
|
|||||||
|
|
||||||
// Get temperature of sensor
|
// Get temperature of sensor
|
||||||
if (this->temperature_ != nullptr) {
|
if (this->temperature_ != nullptr) {
|
||||||
uint8_t temp_in_c = this->parse_temperature_(manu_data.data);
|
int8_t temp_in_c = this->parse_temperature_(manu_data.data);
|
||||||
this->temperature_->publish_state(temp_in_c);
|
this->temperature_->publish_state(temp_in_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ uint32_t MopekaProCheck::parse_distance_(const std::vector<uint8_t> &message) {
|
|||||||
(MOPEKA_LPG_COEF[0] + MOPEKA_LPG_COEF[1] * raw_t + MOPEKA_LPG_COEF[2] * raw_t * raw_t));
|
(MOPEKA_LPG_COEF[0] + MOPEKA_LPG_COEF[1] * raw_t + MOPEKA_LPG_COEF[2] * raw_t * raw_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t MopekaProCheck::parse_temperature_(const std::vector<uint8_t> &message) { return (message[2] & 0x7F) - 40; }
|
int8_t MopekaProCheck::parse_temperature_(const std::vector<uint8_t> &message) { return (message[2] & 0x7F) - 40; }
|
||||||
|
|
||||||
SensorReadQuality MopekaProCheck::parse_read_quality_(const std::vector<uint8_t> &message) {
|
SensorReadQuality MopekaProCheck::parse_read_quality_(const std::vector<uint8_t> &message) {
|
||||||
// Since a 8 bit value is being shifted and truncated to 2 bits all possible values are defined as enumeration
|
// Since a 8 bit value is being shifted and truncated to 2 bits all possible values are defined as enumeration
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class MopekaProCheck : public Component, public esp32_ble_tracker::ESPBTDeviceLi
|
|||||||
|
|
||||||
uint8_t parse_battery_level_(const std::vector<uint8_t> &message);
|
uint8_t parse_battery_level_(const std::vector<uint8_t> &message);
|
||||||
uint32_t parse_distance_(const std::vector<uint8_t> &message);
|
uint32_t parse_distance_(const std::vector<uint8_t> &message);
|
||||||
uint8_t parse_temperature_(const std::vector<uint8_t> &message);
|
int8_t parse_temperature_(const std::vector<uint8_t> &message);
|
||||||
SensorReadQuality parse_read_quality_(const std::vector<uint8_t> &message);
|
SensorReadQuality parse_read_quality_(const std::vector<uint8_t> &message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user