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:
1 parent
a6511fc0b9
commit
d6a4e106a9
10 files changed
+168
-153
No files matched your search
@@ -9,7 +9,8 @@ https://home-assistant.io/components/switch.tellduslive/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.tellduslive import TelldusLiveEntity
|
||||
from homeassistant.components import tellduslive
|
||||
from homeassistant.components.tellduslive.entry import TelldusLiveEntity
|
||||
from homeassistant.helpers.entity import ToggleEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -19,7 +20,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up Tellstick switches."""
|
||||
if discovery_info is None:
|
||||
return
|
||||
add_entities(TelldusLiveSwitch(hass, switch) for switch in discovery_info)
|
||||
client = hass.data[tellduslive.DOMAIN]
|
||||
add_entities(
|
||||
TelldusLiveSwitch(client, switch) for switch in discovery_info)
|
||||
|
||||
|
||||
class TelldusLiveSwitch(TelldusLiveEntity, ToggleEntity):
|
||||
@@ -33,9 +36,7 @@ class TelldusLiveSwitch(TelldusLiveEntity, ToggleEntity):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the switch on."""
|
||||
self.device.turn_on()
|
||||
self.changed()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
self.device.turn_off()
|
||||
self.changed()
|
||||
Reference in new issue
Block a user