58 if (calculated_checksum != received_checksum) {
59 ESP_LOGW(TAG,
"WTS01 Checksum doesn't match: 0x%02X != 0x%02X", received_checksum, calculated_checksum);
67 const bool negative = (
raw & 0x80) != 0;
68 const uint8_t magnitude =
raw & 0x7F;
70 const float decimal =
static_cast<float>(this->
buffer_[7]) / 100.0f;
72 float temperature =
static_cast<float>(magnitude) + decimal;
78 ESP_LOGV(TAG,
"Received new temperature: %.2f°C",
temperature);
void publish_state(float state)
Publish a new state to the front-end.
bool read_available(F &&on_byte)
Same as read_available_chunks(), calling on_byte(uint8_t) once per byte.
void handle_char_(uint8_t c)
uint8_t buffer_[PACKET_SIZE]
void dump_config() override
ESPHOME_LOG_TAG(TAG, "wts01")
constexpr uint8_t HEADER_4
constexpr uint8_t HEADER_3
constexpr uint8_t HEADER_2
constexpr uint8_t HEADER_1
constexpr uint8_t PACKET_SIZE
constexpr uint8_t sum_bytes(const uint8_t *data, size_t len, uint8_t sum=0)
Add up the bytes of data with size len, truncated to 8 bits: the checksum many serial and IR protocol...