Fixed a but in node discovery

This commit is contained in:
Pieter Kokx 2024-12-04 23:25:28 +01:00
parent bc14026f96
commit 376cfa12c2
No known key found for this signature in database
GPG Key ID: BD73BAB527D54451
2 changed files with 14 additions and 9 deletions

View File

@ -22,6 +22,16 @@ CONF_DISCOVERY = "discovery"
# A schema for components like sensors
DUCO_COMPONENT_SCHEMA = cv.Schema({cv.GenerateID(CONF_DUCO_ID): cv.use_id(Duco)})
DISCOVERY_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(DucoDiscovery),
}
)
.extend(cv.polling_component_schema("60s"))
.extend(DUCO_COMPONENT_SCHEMA)
)
CONFIG_SCHEMA = (
cv.Schema(
{
@ -30,13 +40,7 @@ CONFIG_SCHEMA = (
CONF_SEND_WAIT_TIME, default="250ms"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_DISABLE_CRC, default=False): cv.boolean,
cv.Optional(CONF_DISCOVERY): cv.Schema(
{
cv.GenerateID(): cv.declare_id(DucoDiscovery),
}
)
.extend(cv.polling_component_schema("60s"))
.extend(DUCO_COMPONENT_SCHEMA),
cv.Optional(CONF_DISCOVERY): DISCOVERY_SCHEMA,
}
)
.extend(cv.COMPONENT_SCHEMA)

View File

@ -197,8 +197,9 @@ const std::string friendly_node_type(uint8_t type_code) {
void DucoDiscovery::update() {
// display all found nodes
ESP_LOGI(TAG, "Discovered nodes:");
for (auto &node : nodes_) {
ESP_LOGI(TAG, "Node %d: type %d (%s)", std::get<0>(node), std::get<1>(node),
ESP_LOGI(TAG, " Node %d: type %d (%s)", std::get<0>(node), std::get<1>(node),
friendly_node_type(std::get<1>(node)).c_str());
}
}
@ -225,7 +226,7 @@ void DucoDiscovery::loop() {
}
void DucoDiscovery::receive_response(DucoMessage message) {
if (message.id == 0x0e) {
if (message.function == 0x0e) {
ESP_LOGV(TAG, "Discovery response message: %s", format_hex_pretty(message).c_str());
this->parent_->stop_waiting(message.id);