mirror of
https://github.com/esphome/esphome.git
synced 2024-12-04 13:44:40 +01:00
make primary address optional so we can listen on ebus without ever sending messages
This commit is contained in:
parent
1f46a3fbbb
commit
3c885383c1
@ -48,7 +48,7 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Schema(
|
cv.Schema(
|
||||||
{
|
{
|
||||||
cv.GenerateID(): cv.declare_id(EbusComponent),
|
cv.GenerateID(): cv.declare_id(EbusComponent),
|
||||||
cv.Required(CONF_PRIMARY_ADDRESS): validate_primary_address,
|
cv.Optional(CONF_PRIMARY_ADDRESS): validate_primary_address,
|
||||||
cv.Optional(CONF_MAX_TRIES, default=2): cv.hex_uint8_t,
|
cv.Optional(CONF_MAX_TRIES, default=2): cv.hex_uint8_t,
|
||||||
cv.Optional(CONF_MAX_LOCK_COUNTER, default=4): cv.hex_uint8_t,
|
cv.Optional(CONF_MAX_LOCK_COUNTER, default=4): cv.hex_uint8_t,
|
||||||
cv.Optional(CONF_HISTORY_QUEUE_SIZE, default=20): cv.uint8_t,
|
cv.Optional(CONF_HISTORY_QUEUE_SIZE, default=20): cv.uint8_t,
|
||||||
@ -70,6 +70,7 @@ 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)
|
||||||
|
|
||||||
|
if CONF_PRIMARY_ADDRESS in config:
|
||||||
cg.add(var.set_primary_address(config[CONF_PRIMARY_ADDRESS]))
|
cg.add(var.set_primary_address(config[CONF_PRIMARY_ADDRESS]))
|
||||||
cg.add(var.set_max_tries(config[CONF_MAX_TRIES]))
|
cg.add(var.set_max_tries(config[CONF_MAX_TRIES]))
|
||||||
cg.add(var.set_max_lock_counter(config[CONF_MAX_LOCK_COUNTER]))
|
cg.add(var.set_max_lock_counter(config[CONF_MAX_LOCK_COUNTER]))
|
||||||
|
@ -9,7 +9,11 @@ namespace ebus {
|
|||||||
|
|
||||||
void EbusComponent::dump_config() {
|
void EbusComponent::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "EbusComponent");
|
ESP_LOGCONFIG(TAG, "EbusComponent");
|
||||||
|
if (this->primary_address_ == SYN) {
|
||||||
|
ESP_LOGCONFIG(TAG, " primary_addres: N/A");
|
||||||
|
} else {
|
||||||
ESP_LOGCONFIG(TAG, " primary_addres: 0x%02x", this->primary_address_);
|
ESP_LOGCONFIG(TAG, " primary_addres: 0x%02x", this->primary_address_);
|
||||||
|
}
|
||||||
ESP_LOGCONFIG(TAG, " max_tries: %d", this->max_tries_);
|
ESP_LOGCONFIG(TAG, " max_tries: %d", this->max_tries_);
|
||||||
ESP_LOGCONFIG(TAG, " max_lock_counter: %d", this->max_lock_counter_);
|
ESP_LOGCONFIG(TAG, " max_lock_counter: %d", this->max_lock_counter_);
|
||||||
ESP_LOGCONFIG(TAG, " history_queue_size: %d", this->history_queue_size_);
|
ESP_LOGCONFIG(TAG, " history_queue_size: %d", this->history_queue_size_);
|
||||||
@ -42,6 +46,10 @@ void EbusComponent::set_command_queue_size(uint8_t command_queue_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EbusComponent::add_sender(EbusSender *sender) {
|
void EbusComponent::add_sender(EbusSender *sender) {
|
||||||
|
if (this->primary_address_ == SYN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sender->set_primary_address(this->primary_address_);
|
sender->set_primary_address(this->primary_address_);
|
||||||
this->senders_.push_back(sender);
|
this->senders_.push_back(sender);
|
||||||
}
|
}
|
||||||
@ -151,6 +159,9 @@ void EbusComponent::handle_message_(Telegram &telegram) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EbusComponent::update() {
|
void EbusComponent::update() {
|
||||||
|
if (this->primary_address_ == SYN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (auto const &sender : this->senders_) {
|
for (auto const &sender : this->senders_) {
|
||||||
optional<SendCommand> command = sender->prepare_command();
|
optional<SendCommand> command = sender->prepare_command();
|
||||||
if (command.has_value()) {
|
if (command.has_value()) {
|
||||||
|
@ -52,7 +52,7 @@ class EbusComponent : public PollingComponent {
|
|||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t primary_address_;
|
uint8_t primary_address_ = SYN;
|
||||||
uint8_t max_tries_;
|
uint8_t max_tries_;
|
||||||
uint8_t max_lock_counter_;
|
uint8_t max_lock_counter_;
|
||||||
uint8_t history_queue_size_;
|
uint8_t history_queue_size_;
|
||||||
|
Loading…
Reference in New Issue
Block a user