Add support for Supla switches (#26188)

* add support for Supla switches

* remove blank line at the end of file

* Add comma on last element of a list

* Remove unnecessary supla dependencies variable
pull/26332/head
Rocik 2019-09-01 10:42:17 +02:00 committed by Martin Hjelmare
parent 5ba436e3d8
commit 298aafc79d
3 changed files with 42 additions and 3 deletions

View File

@ -17,7 +17,10 @@ DOMAIN = "supla"
CONF_SERVER = "server"
CONF_SERVERS = "servers"
SUPLA_FUNCTION_HA_CMP_MAP = {"CONTROLLINGTHEROLLERSHUTTER": "cover"}
SUPLA_FUNCTION_HA_CMP_MAP = {
"CONTROLLINGTHEROLLERSHUTTER": "cover",
"LIGHTSWITCH": "switch",
}
SUPLA_CHANNELS = "supla_channels"
SUPLA_SERVERS = "supla_servers"

View File

@ -5,8 +5,6 @@ from pprint import pformat
from homeassistant.components.cover import ATTR_POSITION, CoverDevice
from homeassistant.components.supla import SuplaChannel
DEPENDENCIES = ["supla"]
_LOGGER = logging.getLogger(__name__)

View File

@ -0,0 +1,38 @@
"""Support for Supla cover - curtains, rollershutters etc."""
import logging
from pprint import pformat
from homeassistant.components.switch import SwitchDevice
from homeassistant.components.supla import SuplaChannel
_LOGGER = logging.getLogger(__name__)
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Supla switches."""
if discovery_info is None:
return
_LOGGER.debug("Discovery: %s", pformat(discovery_info))
add_entities([SuplaSwitch(device) for device in discovery_info])
class SuplaSwitch(SuplaChannel, SwitchDevice):
"""Representation of a Supla Switch."""
def turn_on(self, **kwargs):
"""Turn on the switch."""
self.action("TURN_ON")
def turn_off(self, **kwargs):
"""Turn off the switch."""
self.action("TURN_OFF")
@property
def is_on(self):
"""Return true if switch is on."""
state = self.channel_data.get("state")
if state:
return state["on"]
return False