mirror of
https://github.com/esphome/esphome.git
synced 2025-11-18 07:45:56 +00:00
Add new component for Tuya dimmers (#743)
* Add new component for Tuya dimmers * Update code * Class naming * Log output * Fixes * Lint * Format * Fix test * log setting datapoint values * remove in_setup_ and fix datapoint handling Co-authored-by: Samuel Sieb <samuel@sieb.net> Co-authored-by: Otto Winter <otto@otto-winter.com>
This commit is contained in:
@@ -314,4 +314,20 @@ std::array<uint8_t, 2> decode_uint16(uint16_t value) {
|
||||
return {msb, lsb};
|
||||
}
|
||||
|
||||
std::string hexencode(const uint8_t *data, uint32_t len) {
|
||||
char buf[20];
|
||||
std::string res;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (i + 1 != len) {
|
||||
sprintf(buf, "%02X.", data[i]);
|
||||
} else {
|
||||
sprintf(buf, "%02X ", data[i]);
|
||||
}
|
||||
res += buf;
|
||||
}
|
||||
sprintf(buf, "(%u)", len);
|
||||
res += buf;
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user