From 5b1c51bdf6f47b55e0f190d282f6569dacd397ef Mon Sep 17 00:00:00 2001 From: freol35241 Date: Tue, 30 Jan 2018 10:18:45 +0100 Subject: [PATCH] Handling of payload not for this entity. (#11836) * Handling of payload not for this entity. The update state-method should not be called if the payload is not intended for this entity. * Fixing linter errors * Adding warning for case when no matching payload is found --- homeassistant/components/binary_sensor/mqtt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/components/binary_sensor/mqtt.py b/homeassistant/components/binary_sensor/mqtt.py index 983c879338d..650179f676b 100644 --- a/homeassistant/components/binary_sensor/mqtt.py +++ b/homeassistant/components/binary_sensor/mqtt.py @@ -94,6 +94,11 @@ class MqttBinarySensor(MqttAvailability, BinarySensorDevice): self._state = True elif payload == self._payload_off: self._state = False + else: # Payload is not for this entity + _LOGGER.warning('No matching payload found' + ' for entity: %s with state_topic: %s', + self._name, self._state_topic) + return self.async_schedule_update_ha_state()