Correct calls to subscription.async_unsubscribe_topics (#19414)

* Correct calls to subscription.async_unsubscribe_topics

* Review comments

* Add testcases
This commit is contained in:
emontnemery 2018-12-19 14:05:24 +01:00 committed by Paulus Schoutsen
parent 8cec559103
commit 1568de62df
20 changed files with 333 additions and 29 deletions

View file

@ -178,7 +178,8 @@ class MqttSensor(MqttAttributes, MqttAvailability, MqttDiscoveryUpdate,
async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
await subscription.async_unsubscribe_topics(self.hass, self._sub_state)
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_from_hass(self)