diff --git a/esphome/components/optolink/datapoint_component.cpp b/esphome/components/optolink/datapoint_component.cpp index cab7a2abdc..3b552e1c01 100644 --- a/esphome/components/optolink/datapoint_component.cpp +++ b/esphome/components/optolink/datapoint_component.cpp @@ -272,9 +272,12 @@ void DatapointComponent::subscribe_hass(std::string entity_id, std::function(), [this, entity_id](const std::string &state) { ESP_LOGD(TAG, "received schedule plan from HASS entity '%s': %s", entity_id.c_str(), state.c_str()); for (auto &subscription : hass_subscriptions_) { - if (subscription.entity_id == entity_id) { - for (auto callback : subscription.callbacks) { - callback(state); + if (subscription.last_state != state) { + if (subscription.entity_id == entity_id) { + subscription.last_state = state; + for (auto callback : subscription.callbacks) { + callback(state); + } } } } diff --git a/esphome/components/optolink/datapoint_component.h b/esphome/components/optolink/datapoint_component.h index bfa771a829..a0548bcefa 100644 --- a/esphome/components/optolink/datapoint_component.h +++ b/esphome/components/optolink/datapoint_component.h @@ -13,6 +13,7 @@ class Optolink; struct HassSubscription { std::string entity_id; + std::string last_state; std::vector> callbacks; };