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 variablepull/26332/head
parent
5ba436e3d8
commit
298aafc79d
|
@ -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"
|
||||
|
||||
|
|
|
@ -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__)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue