Fix Tado signal collisons (#34118)

* Fix signal collision in tado with multiple accounts

Tado signals were not unique enough to prevent collisions
between accounts with the same zone ids.

* Bump upstream to fix multiple tado accounts

* switch signal undo to async_on_remove

* Bump version now that upstream is released

* bump python-tado

* While its only the dep that changed since the last run, best to force another CI to be sure
This commit is contained in:
J. Nick Koston 2020-04-18 17:39:43 -05:00 committed by GitHub
parent 61a5793073
commit 37463d655a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 45 additions and 46 deletions

View file

@ -217,9 +217,16 @@ class TadoConnector:
self.data[sensor_type][sensor] = data
_LOGGER.debug("Dispatching update to %s %s: %s", sensor_type, sensor, data)
_LOGGER.debug(
"Dispatching update to %s %s %s: %s",
self.device_id,
sensor_type,
sensor,
data,
)
dispatcher_send(
self.hass, SIGNAL_TADO_UPDATE_RECEIVED.format(sensor_type, sensor)
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(self.device_id, sensor_type, sensor),
)
def get_capabilities(self, zone_id):

View file

@ -215,23 +215,21 @@ class TadoClimate(TadoZoneEntity, ClimateDevice):
self._current_tado_hvac_action = CURRENT_HVAC_OFF
self._current_tado_swing_mode = TADO_SWING_OFF
self._undo_dispatcher = None
self._tado_zone_data = None
self._async_update_zone_data()
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
if self._undo_dispatcher:
self._undo_dispatcher()
async def async_added_to_hass(self):
"""Register for sensor updates."""
self._undo_dispatcher = async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format("zone", self.zone_id),
self._async_update_callback,
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(
self._tado.device_id, "zone", self.zone_id
),
self._async_update_callback,
)
)
@property

View file

@ -139,7 +139,7 @@ TADO_SWING_ON = "ON"
DOMAIN = "tado"
SIGNAL_TADO_UPDATE_RECEIVED = "tado_update_received_{}_{}"
SIGNAL_TADO_UPDATE_RECEIVED = "tado_update_received_{}_{}_{}"
UNIQUE_ID = "unique_id"
DEFAULT_NAME = "Tado"

View file

@ -2,7 +2,7 @@
"domain": "tado",
"name": "Tado",
"documentation": "https://www.home-assistant.io/integrations/tado",
"requirements": ["python-tado==0.6.0"],
"requirements": ["python-tado==0.8.1"],
"codeowners": ["@michaelarnauts", "@bdraco"],
"config_flow": true,
"homekit": {

View file

@ -104,20 +104,18 @@ class TadoZoneSensor(TadoZoneEntity, Entity):
self._state = None
self._state_attributes = None
self._tado_zone_data = None
self._undo_dispatcher = None
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
if self._undo_dispatcher:
self._undo_dispatcher()
async def async_added_to_hass(self):
"""Register for sensor updates."""
self._undo_dispatcher = async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format("zone", self.zone_id),
self._async_update_callback,
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(
self._tado.device_id, "zone", self.zone_id
),
self._async_update_callback,
)
)
self._async_update_zone_data()
@ -245,20 +243,18 @@ class TadoDeviceSensor(Entity):
self._state = None
self._state_attributes = None
self._tado_device_data = None
self._undo_dispatcher = None
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
if self._undo_dispatcher:
self._undo_dispatcher()
async def async_added_to_hass(self):
"""Register for sensor updates."""
self._undo_dispatcher = async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format("device", self.device_id),
self._async_update_callback,
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(
self._tado.device_id, "device", self.device_id
),
self._async_update_callback,
)
)
self._async_update_device_data()

View file

@ -134,20 +134,18 @@ class TadoWaterHeater(TadoZoneEntity, WaterHeaterDevice):
self._current_tado_hvac_mode = CONST_MODE_SMART_SCHEDULE
self._overlay_mode = CONST_MODE_SMART_SCHEDULE
self._tado_zone_data = None
self._undo_dispatcher = None
async def async_will_remove_from_hass(self):
"""When entity will be removed from hass."""
if self._undo_dispatcher:
self._undo_dispatcher()
async def async_added_to_hass(self):
"""Register for sensor updates."""
self._undo_dispatcher = async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format("zone", self.zone_id),
self._async_update_callback,
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIGNAL_TADO_UPDATE_RECEIVED.format(
self._tado.device_id, "zone", self.zone_id
),
self._async_update_callback,
)
)
self._async_update_data()

View file

@ -1676,7 +1676,7 @@ python-songpal==0.11.2
python-synology==0.6.0
# homeassistant.components.tado
python-tado==0.6.0
python-tado==0.8.1
# homeassistant.components.telegram_bot
python-telegram-bot==11.1.0

View file

@ -643,7 +643,7 @@ python-nest==4.1.0
python-synology==0.6.0
# homeassistant.components.tado
python-tado==0.6.0
python-tado==0.8.1
# homeassistant.components.twitch
python-twitch-client==0.6.0