ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
xiaomi_lywsd03mmc.cpp
Go to the documentation of this file.
1#include "xiaomi_lywsd03mmc.h"
2#include "esphome/core/log.h"
3
4#include <cmath>
5
7
8ESPHOME_LOG_TAG(TAG, "xiaomi_lywsd03mmc");
9
11 ESP_LOGCONFIG(TAG, "Xiaomi LYWSD03MMC");
12 this->dump_bindkey_(TAG);
13 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
14 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
15 LOG_SENSOR(" ", "Battery Level", this->battery_level_sensor_);
16}
17
19 publish_optional(this->temperature_sensor_, res.temperature);
20 // see https://github.com/custom-components/sensor.mitemp_bt/issues/7#issuecomment-595948254
21 if (res.humidity.has_value() && this->humidity_sensor_ != nullptr)
22 this->humidity_sensor_->publish_state(truncf(*res.humidity));
23 publish_optional(this->battery_level_sensor_, res.battery_level);
24}
25
26} // namespace esphome::xiaomi_lywsd03mmc
virtual void dump_config()
void dump_bindkey_(const char *tag) const
void publish_result(const xiaomi_ble::XiaomiParseResult &res) override
ESPHOME_LOG_TAG(TAG, "xiaomi_lywsd03mmc")
void publish_optional(E *entity, const optional< V > &value)
Publish value to entity when the entity is configured and the value is set.