mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Merge branch 'dev' into dashboard_port_from_enviromnent_var
This commit is contained in:
commit
8cde9fcbf9
8 changed files with 121 additions and 10 deletions
|
@ -169,6 +169,7 @@ esphome/components/he60r/* @clydebarrow
|
|||
esphome/components/heatpumpir/* @rob-deutsch
|
||||
esphome/components/hitachi_ac424/* @sourabhjaiswal
|
||||
esphome/components/hm3301/* @freekode
|
||||
esphome/components/hmac_md5/* @dwmw2
|
||||
esphome/components/homeassistant/* @OttoWinter @esphome/core
|
||||
esphome/components/homeassistant/number/* @landonr
|
||||
esphome/components/homeassistant/switch/* @Links2004
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "captive_portal.h"
|
||||
#ifdef USE_CAPTIVE_PORTAL
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/components/wifi/wifi_component.h"
|
||||
|
@ -91,3 +92,4 @@ CaptivePortal *global_captive_portal = nullptr; // NOLINT(cppcoreguidelines-avo
|
|||
|
||||
} // namespace captive_portal
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_CAPTIVE_PORTAL
|
||||
#include <memory>
|
||||
#ifdef USE_ARDUINO
|
||||
#include <DNSServer.h>
|
||||
|
@ -71,3 +72,4 @@ extern CaptivePortal *global_captive_portal; // NOLINT(cppcoreguidelines-avoid-
|
|||
|
||||
} // namespace captive_portal
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
|
2
esphome/components/hmac_md5/__init__.py
Normal file
2
esphome/components/hmac_md5/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
AUTO_LOAD = ["md5"]
|
||||
CODEOWNERS = ["@dwmw2"]
|
56
esphome/components/hmac_md5/hmac_md5.cpp
Normal file
56
esphome/components/hmac_md5/hmac_md5.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "hmac_md5.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace hmac_md5 {
|
||||
void HmacMD5::init(const uint8_t *key, size_t len) {
|
||||
uint8_t ipad[64], opad[64];
|
||||
|
||||
memset(ipad, 0, sizeof(ipad));
|
||||
if (len > 64) {
|
||||
md5::MD5Digest keymd5;
|
||||
keymd5.init();
|
||||
keymd5.add(key, len);
|
||||
keymd5.calculate();
|
||||
keymd5.get_bytes(ipad);
|
||||
} else {
|
||||
memcpy(ipad, key, len);
|
||||
}
|
||||
memcpy(opad, ipad, sizeof(opad));
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
ipad[i] ^= 0x36;
|
||||
opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
this->ihash_.init();
|
||||
this->ihash_.add(ipad, sizeof(ipad));
|
||||
|
||||
this->ohash_.init();
|
||||
this->ohash_.add(opad, sizeof(opad));
|
||||
}
|
||||
|
||||
void HmacMD5::add(const uint8_t *data, size_t len) { this->ihash_.add(data, len); }
|
||||
|
||||
void HmacMD5::calculate() {
|
||||
uint8_t ibytes[16];
|
||||
|
||||
this->ihash_.calculate();
|
||||
this->ihash_.get_bytes(ibytes);
|
||||
|
||||
this->ohash_.add(ibytes, sizeof(ibytes));
|
||||
this->ohash_.calculate();
|
||||
}
|
||||
|
||||
void HmacMD5::get_bytes(uint8_t *output) { this->ohash_.get_bytes(output); }
|
||||
|
||||
void HmacMD5::get_hex(char *output) { this->ohash_.get_hex(output); }
|
||||
|
||||
bool HmacMD5::equals_bytes(const uint8_t *expected) { return this->ohash_.equals_bytes(expected); }
|
||||
|
||||
bool HmacMD5::equals_hex(const char *expected) { return this->ohash_.equals_hex(expected); }
|
||||
|
||||
} // namespace hmac_md5
|
||||
} // namespace esphome
|
48
esphome/components/hmac_md5/hmac_md5.h
Normal file
48
esphome/components/hmac_md5/hmac_md5.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/components/md5/md5.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace esphome {
|
||||
namespace hmac_md5 {
|
||||
|
||||
class HmacMD5 {
|
||||
public:
|
||||
HmacMD5() = default;
|
||||
~HmacMD5() = default;
|
||||
|
||||
/// Initialize a new MD5 digest computation.
|
||||
void init(const uint8_t *key, size_t len);
|
||||
void init(const char *key, size_t len) { this->init((const uint8_t *) key, len); }
|
||||
void init(const std::string &key) { this->init(key.c_str(), key.length()); }
|
||||
|
||||
/// Add bytes of data for the digest.
|
||||
void add(const uint8_t *data, size_t len);
|
||||
void add(const char *data, size_t len) { this->add((const uint8_t *) data, len); }
|
||||
|
||||
/// Compute the digest, based on the provided data.
|
||||
void calculate();
|
||||
|
||||
/// Retrieve the HMAC-MD5 digest as bytes.
|
||||
/// The output must be able to hold 16 bytes or more.
|
||||
void get_bytes(uint8_t *output);
|
||||
|
||||
/// Retrieve the HMAC-MD5 digest as hex characters.
|
||||
/// The output must be able to hold 32 bytes or more.
|
||||
void get_hex(char *output);
|
||||
|
||||
/// Compare the digest against a provided byte-encoded digest (16 bytes).
|
||||
bool equals_bytes(const uint8_t *expected);
|
||||
|
||||
/// Compare the digest against a provided hex-encoded digest (32 bytes).
|
||||
bool equals_hex(const char *expected);
|
||||
|
||||
protected:
|
||||
md5::MD5Digest ihash_;
|
||||
md5::MD5Digest ohash_;
|
||||
};
|
||||
|
||||
} // namespace hmac_md5
|
||||
} // namespace esphome
|
|
@ -41,29 +41,29 @@ class ESPColorCorrection {
|
|||
if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
|
||||
return 0;
|
||||
uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
|
||||
uint8_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
||||
return res;
|
||||
uint16_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
||||
return (uint8_t) std::min(res, uint16_t(255));
|
||||
}
|
||||
inline uint8_t color_uncorrect_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
|
||||
if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
|
||||
return 0;
|
||||
uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
|
||||
uint8_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
||||
return res;
|
||||
uint16_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
||||
return (uint8_t) std::min(res, uint16_t(255));
|
||||
}
|
||||
inline uint8_t color_uncorrect_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
|
||||
if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
|
||||
return 0;
|
||||
uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
|
||||
uint8_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
||||
return res;
|
||||
uint16_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
||||
return (uint8_t) std::min(res, uint16_t(255));
|
||||
}
|
||||
inline uint8_t color_uncorrect_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
|
||||
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
|
||||
return 0;
|
||||
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
|
||||
uint8_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
|
||||
return res;
|
||||
uint16_t res = ((uncorrected / this->max_brightness_.white) * 255UL) / this->local_brightness_;
|
||||
return (uint8_t) std::min(res, uint16_t(255));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -1850,7 +1850,7 @@ def maybe_simple_value(*validators, **kwargs):
|
|||
if value == SCHEMA_EXTRACT:
|
||||
return (validator, key)
|
||||
|
||||
if isinstance(value, dict) and key in value:
|
||||
if isinstance(value, dict):
|
||||
return validator(value)
|
||||
return validator({key: value})
|
||||
|
||||
|
|
Loading…
Reference in a new issue