Allow generating requirements_all.txt
This commit is contained in:
1 parent
8be53af78f
commit
377d2c6e5a
17 files changed
+283
-206
No files matched your search
@@ -10,8 +10,6 @@ import logging
|
||||
|
||||
from homeassistant.components.switch import SwitchDevice
|
||||
|
||||
from orvibo.s20 import S20, S20Exception
|
||||
|
||||
DEFAULT_NAME = "Orvibo S20 Switch"
|
||||
REQUIREMENTS = ['orvibo==1.0.0']
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -20,6 +18,8 @@ _LOGGER = logging.getLogger(__name__)
|
||||
# pylint: disable=unused-argument
|
||||
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
""" Find and return S20 switches. """
|
||||
from orvibo.s20 import S20, S20Exception
|
||||
|
||||
if config.get('host') is None:
|
||||
_LOGGER.error("Missing required variable: host")
|
||||
return
|
||||
@@ -34,9 +34,12 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None):
|
||||
class S20Switch(SwitchDevice):
|
||||
""" Represents an S20 switch. """
|
||||
def __init__(self, name, s20):
|
||||
from orvibo.s20 import S20Exception
|
||||
|
||||
self._name = name
|
||||
self._s20 = s20
|
||||
self._state = False
|
||||
self._exc = S20Exception
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
@@ -57,19 +60,19 @@ class S20Switch(SwitchDevice):
|
||||
""" Update device state. """
|
||||
try:
|
||||
self._state = self._s20.on
|
||||
except S20Exception:
|
||||
except self._exc:
|
||||
_LOGGER.exception("Error while fetching S20 state")
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
""" Turn the device on. """
|
||||
try:
|
||||
self._s20.on = True
|
||||
except S20Exception:
|
||||
except self._exc:
|
||||
_LOGGER.exception("Error while turning on S20")
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
""" Turn the device off. """
|
||||
try:
|
||||
self._s20.on = False
|
||||
except S20Exception:
|
||||
except self._exc:
|
||||
_LOGGER.exception("Error while turning off S20")
|
||||
Reference in new issue
Block a user