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
pull/12057/head
freol35241 2018-01-30 10:18:45 +01:00 committed by Pascal Vizeli
parent 8624799c45
commit 5b1c51bdf6
1 changed files with 5 additions and 0 deletions

View File

@ -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()