This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+14 -11
View File
@@ -11,19 +11,20 @@ import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
DEFAULT_NAME = 'RecSwitch {0}'
DEFAULT_NAME = "RecSwitch {0}"
DATA_RSN = 'RSN'
DATA_RSN = "RSN"
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_MAC): vol.All(cv.string, vol.Upper),
vol.Optional(CONF_NAME): cv.string,
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_HOST): cv.string,
vol.Required(CONF_MAC): vol.All(cv.string, vol.Upper),
vol.Optional(CONF_NAME): cv.string,
}
)
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the device."""
from pyrecswitch import RSNetwork
@@ -78,17 +79,19 @@ class RecSwitchSwitch(SwitchDevice):
async def async_set_gpio_status(self, status):
"""Set the switch status."""
from pyrecswitch import RSNetworkError
try:
ret = await self.device.set_gpio_status(status)
self.gpio_state = ret.state
except RSNetworkError as error:
_LOGGER.error('Setting status to %s: %r', self.name, error)
_LOGGER.error("Setting status to %s: %r", self.name, error)
async def async_update(self):
"""Update the current switch status."""
from pyrecswitch import RSNetworkError
try:
ret = await self.device.get_gpio_status()
self.gpio_state = ret.state
except RSNetworkError as error:
_LOGGER.error('Reading status from %s: %r', self.name, error)
_LOGGER.error("Reading status from %s: %r", self.name, error)