Skip to content

Commit

Permalink
Ensure dispatcher topic contains the domain
Browse files Browse the repository at this point in the history
  • Loading branch information
bachya committed Feb 3, 2020
1 parent 2eb6cfc commit ad986ce
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions homeassistant/components/simplisafe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Support for SimpliSafe alarm systems."""
import asyncio
from functools import partial
import logging

from simplipy import API
Expand Down Expand Up @@ -56,7 +57,7 @@
CONF_ACCOUNTS = "accounts"

DATA_LISTENER = "listener"
TOPIC_UPDATE = "update_{0}"
TOPIC_UPDATE = partial("{domain}_update_{system_id}".format, domain=DOMAIN)

DEFAULT_SOCKET_MIN_RETRY = 15
DEFAULT_WATCHDOG_SECONDS = 5 * 60
Expand Down Expand Up @@ -389,7 +390,7 @@ async def update_system(system):
"""Update a system."""
await system.update()
_LOGGER.debug('Updated REST API data for "%s"', system.name)
async_dispatcher_send(self._hass, TOPIC_UPDATE.format(system.system_id))
async_dispatcher_send(self._hass, TOPIC_UPDATE(system_id=system.system_id))

tasks = [update_system(system) for system in self.systems.values()]

Expand Down Expand Up @@ -466,7 +467,7 @@ def on_event(data):
self.last_websocket_data[data["sid"]] = event
system = self.systems[data["sid"]]
_LOGGER.debug('Updated websocket data for "%s"', system.name)
async_dispatcher_send(self._hass, TOPIC_UPDATE.format(data["sid"]))
async_dispatcher_send(self._hass, TOPIC_UPDATE(system_id=data["sid"]))

_LOGGER.debug("Resetting websocket watchdog")
self._websocket_watchdog_listener()
Expand Down Expand Up @@ -550,7 +551,7 @@ def update():
self.async_schedule_update_ha_state(True)

self._async_unsub_dispatcher_connect = async_dispatcher_connect(
self.hass, TOPIC_UPDATE.format(self._system.system_id), update
self.hass, TOPIC_UPDATE(system_id=self._system.system_id), update
)

async def async_update(self):
Expand Down

0 comments on commit ad986ce

Please sign in to comment.