Files
core/homeassistant/components/switch/tellduslive.py
T

43 lines
1.2 KiB
Python
Raw Normal View History

2015-12-27 12:32:08 +01:00
"""
2016-03-08 13:35:39 +01:00
Support for Tellstick switches using Tellstick Net.
This platform uses the Telldus Live online service.
2015-12-27 12:32:08 +01:00
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.tellduslive/
"""
import logging
2018-12-04 10:08:40 +01:00
from homeassistant.components import tellduslive
from homeassistant.components.tellduslive.entry import TelldusLiveEntity
2015-12-27 12:32:08 +01:00
from homeassistant.helpers.entity import ToggleEntity
_LOGGER = logging.getLogger(__name__)
2018-08-24 16:37:30 +02:00
def setup_platform(hass, config, add_entities, discovery_info=None):
2017-05-02 18:18:47 +02:00
"""Set up Tellstick switches."""
if discovery_info is None:
return
2018-12-04 10:08:40 +01:00
client = hass.data[tellduslive.DOMAIN]
add_entities(
TelldusLiveSwitch(client, switch) for switch in discovery_info)
2015-12-27 12:32:08 +01:00
2016-12-12 06:39:37 +01:00
class TelldusLiveSwitch(TelldusLiveEntity, ToggleEntity):
2016-03-08 13:35:39 +01:00
"""Representation of a Tellstick switch."""
2015-12-27 12:32:08 +01:00
@property
def is_on(self):
2016-03-08 13:35:39 +01:00
"""Return true if switch is on."""
return self.device.is_on
2015-12-27 12:32:08 +01:00
def turn_on(self, **kwargs):
2016-03-08 13:35:39 +01:00
"""Turn the switch on."""
self.device.turn_on()
2015-12-27 12:32:08 +01:00
def turn_off(self, **kwargs):
2016-03-08 13:35:39 +01:00
"""Turn the switch off."""
self.device.turn_off()