Move dispatcher out of init. (#6355)

This commit is contained in:
Pascal Vizeli 2017-03-02 10:20:57 +01:00 committed by GitHub
parent 8743f23f13
commit 50887e7e2c
3 changed files with 14 additions and 5 deletions

View file

@ -94,10 +94,13 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
_LOGGER.debug("Setting up alarm: %s", alarm_name)
super().__init__(alarm_name, info, controller)
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
async_dispatcher_connect(
hass, SIGNAL_PARTITION_UPDATE, self._update_callback)
self.hass, SIGNAL_PARTITION_UPDATE, self._update_callback)
@callback
def _update_callback(self, partition):

View file

@ -52,8 +52,11 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
_LOGGER.debug('Setting up zone: ' + zone_name)
super().__init__(zone_name, info, controller)
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
hass, SIGNAL_ZONE_UPDATE, self._update_callback)
self.hass, SIGNAL_ZONE_UPDATE, self._update_callback)
@property
def device_state_attributes(self):

View file

@ -49,10 +49,13 @@ class EnvisalinkSensor(EnvisalinkDevice, Entity):
_LOGGER.debug('Setting up sensor for partition: ' + partition_name)
super().__init__(partition_name + ' Keypad', info, controller)
@asyncio.coroutine
def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
self.hass, SIGNAL_KEYPAD_UPDATE, self._update_callback)
async_dispatcher_connect(
hass, SIGNAL_PARTITION_UPDATE, self._update_callback)
self.hass, SIGNAL_PARTITION_UPDATE, self._update_callback)
@property
def icon(self):