mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 17:05:21 +01:00
commit
52db40eb41
5 changed files with 18 additions and 4 deletions
|
@ -33,7 +33,7 @@ CONFIG_SCHEMA = cv.All(
|
||||||
cv.COMPONENT_SCHEMA.extend(
|
cv.COMPONENT_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(KeyCollector),
|
cv.GenerateID(): cv.declare_id(KeyCollector),
|
||||||
cv.GenerateID(CONF_SOURCE_ID): cv.use_id(key_provider.KeyProvider),
|
cv.Optional(CONF_SOURCE_ID): cv.use_id(key_provider.KeyProvider),
|
||||||
cv.Optional(CONF_MIN_LENGTH): cv.int_,
|
cv.Optional(CONF_MIN_LENGTH): cv.int_,
|
||||||
cv.Optional(CONF_MAX_LENGTH): cv.int_,
|
cv.Optional(CONF_MAX_LENGTH): cv.int_,
|
||||||
cv.Optional(CONF_START_KEYS): cv.string,
|
cv.Optional(CONF_START_KEYS): cv.string,
|
||||||
|
@ -55,8 +55,9 @@ CONFIG_SCHEMA = cv.All(
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
await cg.register_component(var, config)
|
await cg.register_component(var, config)
|
||||||
source = await cg.get_variable(config[CONF_SOURCE_ID])
|
if CONF_SOURCE_ID in config:
|
||||||
cg.add(var.set_provider(source))
|
source = await cg.get_variable(config[CONF_SOURCE_ID])
|
||||||
|
cg.add(var.set_provider(source))
|
||||||
if CONF_MIN_LENGTH in config:
|
if CONF_MIN_LENGTH in config:
|
||||||
cg.add(var.set_min_length(config[CONF_MIN_LENGTH]))
|
cg.add(var.set_min_length(config[CONF_MIN_LENGTH]))
|
||||||
if CONF_MAX_LENGTH in config:
|
if CONF_MAX_LENGTH in config:
|
||||||
|
|
|
@ -52,6 +52,8 @@ void KeyCollector::clear(bool progress_update) {
|
||||||
this->progress_trigger_->trigger(this->result_, 0);
|
this->progress_trigger_->trigger(this->result_, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeyCollector::send_key(uint8_t key) { this->key_pressed_(key); }
|
||||||
|
|
||||||
void KeyCollector::key_pressed_(uint8_t key) {
|
void KeyCollector::key_pressed_(uint8_t key) {
|
||||||
this->last_key_time_ = millis();
|
this->last_key_time_ = millis();
|
||||||
if (!this->start_keys_.empty() && !this->start_key_) {
|
if (!this->start_keys_.empty() && !this->start_key_) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class KeyCollector : public Component {
|
||||||
void set_timeout(int timeout) { this->timeout_ = timeout; };
|
void set_timeout(int timeout) { this->timeout_ = timeout; };
|
||||||
|
|
||||||
void clear(bool progress_update = true);
|
void clear(bool progress_update = true);
|
||||||
|
void send_key(uint8_t key);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void key_pressed_(uint8_t key);
|
void key_pressed_(uint8_t key);
|
||||||
|
|
|
@ -102,6 +102,16 @@ void Wiegand::loop() {
|
||||||
uint8_t key = KEYS[value];
|
uint8_t key = KEYS[value];
|
||||||
this->send_key_(key);
|
this->send_key_(key);
|
||||||
}
|
}
|
||||||
|
} else if (count == 8) {
|
||||||
|
if ((value ^ 0xf0) >> 4 == (value & 0xf)) {
|
||||||
|
value &= 0xf;
|
||||||
|
for (auto *trigger : this->key_triggers_)
|
||||||
|
trigger->trigger(value);
|
||||||
|
if (value < 12) {
|
||||||
|
uint8_t key = KEYS[value];
|
||||||
|
this->send_key_(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "received unknown %d-bit value: %llx", count, value);
|
ESP_LOGD(TAG, "received unknown %d-bit value: %llx", count, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Constants used by esphome."""
|
"""Constants used by esphome."""
|
||||||
|
|
||||||
__version__ = "2023.5.0b4"
|
__version__ = "2023.5.0b5"
|
||||||
|
|
||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue