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/
"""
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,6 +436,7 @@ class RfxtrxDevice(Entity):
"""Update det state of the device."""
self._state = state
self._brightness = brightness
if self.added_to_hass:
self.schedule_update_ha_state()
def _send_command(self, command, brightness=0):
@ -469,4 +477,5 @@ class RfxtrxDevice(Entity):
self._event.device.send_stop(self.hass.data[RFXOBJECT]
.transport)
if self.added_to_hass:
self.schedule_update_ha_state()