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