mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
s20 switch support
This commit is contained in:
parent
bc48e4f98e
commit
cf8e23adbc
@ -99,6 +99,7 @@ omit =
|
|||||||
homeassistant/components/switch/hikvisioncam.py
|
homeassistant/components/switch/hikvisioncam.py
|
||||||
homeassistant/components/switch/rest.py
|
homeassistant/components/switch/rest.py
|
||||||
homeassistant/components/switch/rpi_gpio.py
|
homeassistant/components/switch/rpi_gpio.py
|
||||||
|
homeassistant/components/switch/s20.py
|
||||||
homeassistant/components/switch/transmission.py
|
homeassistant/components/switch/transmission.py
|
||||||
homeassistant/components/switch/wemo.py
|
homeassistant/components/switch/wemo.py
|
||||||
homeassistant/components/thermostat/honeywell.py
|
homeassistant/components/thermostat/honeywell.py
|
||||||
|
73
homeassistant/components/switch/s20.py
Normal file
73
homeassistant/components/switch/s20.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
"""
|
||||||
|
homeassistant.components.switch.s20
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Support for Orvibo S20 Wifi Smart Switches.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/switch.s20/
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
|
||||||
|
from orvibo.s20 import S20, S20Exception
|
||||||
|
|
||||||
|
DEFAULT_NAME = "Orbivo S20 Switch"
|
||||||
|
REQUIREMENTS = ['orbivo==1.0.0']
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=unused-argument
|
||||||
|
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||||
|
""" Find and return S20 switches. """
|
||||||
|
if config.get('host') is None:
|
||||||
|
_LOGGER.error("Missing required variable: host")
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
s20 = S20(config.get('host'))
|
||||||
|
add_devices_callback([S20Switch(config.get('name', DEFAULT_NAME),
|
||||||
|
s20)])
|
||||||
|
except S20Exception as exception:
|
||||||
|
_LOGGER.error(exception)
|
||||||
|
|
||||||
|
|
||||||
|
class S20Switch(SwitchDevice):
|
||||||
|
""" Represents an S20 switch. """
|
||||||
|
def __init__(self, name, s20):
|
||||||
|
self._name = name
|
||||||
|
self._s20 = s20
|
||||||
|
|
||||||
|
@property
|
||||||
|
def should_poll(self):
|
||||||
|
""" No polling needed. """
|
||||||
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
""" The name of the switch. """
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self):
|
||||||
|
""" True if device is on. """
|
||||||
|
try:
|
||||||
|
return self._s20.on
|
||||||
|
except S20Exception as exception:
|
||||||
|
_LOGGER.error(exception)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def turn_on(self, **kwargs):
|
||||||
|
""" Turn the device on. """
|
||||||
|
try:
|
||||||
|
self._s20.on = True
|
||||||
|
except S20Exception as exception:
|
||||||
|
_LOGGER.error(exception)
|
||||||
|
self.update_ha_state()
|
||||||
|
|
||||||
|
def turn_off(self, **kwargs):
|
||||||
|
""" Turn the device off. """
|
||||||
|
try:
|
||||||
|
self._s20.on = False
|
||||||
|
except S20Exception as exception:
|
||||||
|
_LOGGER.error(exception)
|
||||||
|
self.update_ha_state()
|
@ -156,3 +156,6 @@ evohomeclient==0.2.3
|
|||||||
|
|
||||||
# Pushetta (notify.pushetta)
|
# Pushetta (notify.pushetta)
|
||||||
pushetta==1.0.15
|
pushetta==1.0.15
|
||||||
|
|
||||||
|
# Orbivo S10
|
||||||
|
orbivo==1.0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user