Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Define exceptions."""
class MyQError(Exception):
"""Define a base exception."""
pass
class RequestError(MyQError):
"""Define an exception related to bad HTTP requests."""
pass
class UnsupportedBrandError(MyQError):
"""Define an exception related to unsupported brands."""
pass
print('Closing the device...')
await device.close()
print(' 0 Current State: {0}'.format(device.state))
for waited in range(1, 30):
if device.state == STATE_CLOSED:
break
await asyncio.sleep(1)
await device.update()
print(' {} Current State: {}'.format(
waited, device.state))
await asyncio.sleep(10)
await device.update()
print()
print('Current State: {0}'.format(device.state))
except MyQError as err:
print(err)
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the platform."""
websession = aiohttp_client.async_get_clientsession(hass)
username = config[CONF_USERNAME]
password = config[CONF_PASSWORD]
try:
myq = await login(username, password, websession)
except MyQError as err:
_LOGGER.error("There was an error while logging in: %s", err)
return
async_add_entities([MyQDevice(device) for device in myq.covers.values()], True)
"""Define exceptions."""
class MyQError(Exception):
"""Define a base exception."""
pass
class RequestError(MyQError):
"""Define an exception related to bad HTTP requests."""
pass
class UnsupportedBrandError(MyQError):
"""Define an exception related to unsupported brands."""
pass