mirror of
https://github.com/esphome/esphome.git
synced 2026-02-27 17:34:22 -07:00
tweaks
This commit is contained in:
@@ -1537,8 +1537,8 @@ void APIConnection::on_home_assistant_state_response(const HomeAssistantStateRes
|
||||
for (auto &it : this->parent_->get_state_subs()) {
|
||||
// Compare entity_id and attribute with message fields
|
||||
bool entity_match = (strcmp(it.entity_id_, msg.entity_id.c_str()) == 0);
|
||||
bool attribute_match =
|
||||
it.has_attribute_ ? (strcmp(it.attribute_, msg.attribute.c_str()) == 0) : msg.attribute.empty();
|
||||
bool attribute_match = (it.has_attribute_ && strcmp(it.attribute_, msg.attribute.c_str()) == 0) ||
|
||||
(!it.has_attribute_ && msg.attribute.empty());
|
||||
|
||||
if (entity_match && attribute_match) {
|
||||
it.callback_(msg.state);
|
||||
|
||||
Reference in New Issue
Block a user