ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
xiaomi_cgg1.cpp
Go to the documentation of this file.
1#include "xiaomi_cgg1.h"
2#include "esphome/core/log.h"
3
4#include <algorithm>
5#include <iterator>
6
8
9ESPHOME_LOG_TAG(TAG, "xiaomi_cgg1");
10
12 ESP_LOGCONFIG(TAG, "Xiaomi CGG1");
13 // The bindkey is optional on the CGG1; without one it stays all zero
14 if (std::any_of(std::begin(this->bindkey_), std::end(this->bindkey_), [](uint8_t b) { return b != 0; }))
15 this->dump_bindkey_(TAG);
16 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
17 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
18 LOG_SENSOR(" ", "Battery Level", this->battery_level_sensor_);
19}
20
22 publish_optional(this->temperature_sensor_, res.temperature);
23 publish_optional(this->humidity_sensor_, res.humidity);
24 publish_optional(this->battery_level_sensor_, res.battery_level);
25}
26
27} // namespace esphome::xiaomi_cgg1
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_cgg1")
void publish_optional(E *entity, const optional< V > &value)
Publish value to entity when the entity is configured and the value is set.