diff --git a/homeassistant/components/rfxtrx.py b/homeassistant/components/rfxtrx.py index 0c5acd3f7fa..96dca7e2d78 100644 --- a/homeassistant/components/rfxtrx.py +++ b/homeassistant/components/rfxtrx.py @@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/rfxtrx/ """ +import asyncio import logging from collections import OrderedDict import voluptuous as vol @@ -395,6 +396,12 @@ class RfxtrxDevice(Entity): self._state = datas[ATTR_STATE] self._should_fire_event = datas[ATTR_FIREEVENT] self._brightness = 0 + self.added_to_hass = False + + @asyncio.coroutine + def async_added_to_hass(self): + """Subscribe RFXtrx events.""" + self.added_to_hass = True @property def should_poll(self): @@ -429,7 +436,8 @@ class RfxtrxDevice(Entity): """Update det state of the device.""" self._state = state self._brightness = brightness - self.schedule_update_ha_state() + if self.added_to_hass: + self.schedule_update_ha_state() def _send_command(self, command, brightness=0): if not self._event: @@ -469,4 +477,5 @@ class RfxtrxDevice(Entity): self._event.device.send_stop(self.hass.data[RFXOBJECT] .transport) - self.schedule_update_ha_state() + if self.added_to_hass: + self.schedule_update_ha_state()