Tellduslive refactoring (#18780)

* move component to a package

* move TelldusLiveEntry to separate file

* refactor

* move entities from a shared container
* using the dispatch helper instead for communication between component and platforms

* updated covereagerc and codeowners

* suggestions from MartinHjelmare

* don't make update async

* "Strip is good!"
This commit is contained in:
Fredrik Erlandsson authored and Martin Hjelmare committed 2018-12-04 10:08:40 +01:00
1 parent a6511fc0b9
commit d6a4e106a9
10 files changed
+168 -153

No files matched your search

@@ -8,9 +8,10 @@ https://home-assistant.io/components/light.tellduslive/
"""
import logging
from homeassistant.components import tellduslive
from homeassistant.components.light import (
ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light)
from homeassistant.components.tellduslive import TelldusLiveEntity
from homeassistant.components.tellduslive.entry import TelldusLiveEntity
_LOGGER = logging.getLogger(__name__)
@@ -19,21 +20,21 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Tellstick Net lights."""
if discovery_info is None:
return
add_entities(TelldusLiveLight(hass, light) for light in discovery_info)
client = hass.data[tellduslive.DOMAIN]
add_entities(TelldusLiveLight(client, light) for light in discovery_info)
class TelldusLiveLight(TelldusLiveEntity, Light):
"""Representation of a Tellstick Net light."""
def __init__(self, hass, device_id):
def __init__(self, client, device_id):
"""Initialize the Tellstick Net light."""
super().__init__(hass, device_id)
super().__init__(client, device_id)
self._last_brightness = self.brightness
def changed(self):
"""Define a property of the device that might have changed."""
self._last_brightness = self.brightness
super().changed()
@property
def brightness(self):