Rfxtrx fix (#10128)

Rfxtrx fix (#10128)
This commit is contained in:
Daniel Høyer Iversen 2017-10-25 08:41:02 +02:00 committed by GitHub
parent 2bdad5388b
commit 00b9297082

View File

@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/rfxtrx/ https://home-assistant.io/components/rfxtrx/
""" """
import asyncio
import logging import logging
from collections import OrderedDict from collections import OrderedDict
import voluptuous as vol import voluptuous as vol
@ -395,6 +396,12 @@ class RfxtrxDevice(Entity):
self._state = datas[ATTR_STATE] self._state = datas[ATTR_STATE]
self._should_fire_event = datas[ATTR_FIREEVENT] self._should_fire_event = datas[ATTR_FIREEVENT]
self._brightness = 0 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 @property
def should_poll(self): def should_poll(self):
@ -429,7 +436,8 @@ class RfxtrxDevice(Entity):
"""Update det state of the device.""" """Update det state of the device."""
self._state = state self._state = state
self._brightness = brightness 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): def _send_command(self, command, brightness=0):
if not self._event: if not self._event:
@ -469,4 +477,5 @@ class RfxtrxDevice(Entity):
self._event.device.send_stop(self.hass.data[RFXOBJECT] self._event.device.send_stop(self.hass.data[RFXOBJECT]
.transport) .transport)
self.schedule_update_ha_state() if self.added_to_hass:
self.schedule_update_ha_state()