Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
async def main() -> None:
"""Create the aiohttp session and run the example."""
loglevels = dict((logging.getLevelName(level), level)
for level in [10, 20, 30, 40, 50])
logging.basicConfig(
level=loglevels[LOGLEVEL],
format='%(asctime)s:%(levelname)s:\t%(name)s\t%(message)s')
async with ClientSession() as websession:
try:
myq = await pymyq.login(
MYQ_ACCOUNT_EMAIL, MYQ_ACCOUNT_PASSWORD, MYQ_BRAND, websession)
devices = await myq.get_devices()
for idx, device in enumerate(devices):
print('Device #{0}: {1}'.format(idx + 1, device.name))
print('--------')
print('Brand: {0}'.format(device.brand))
print('Type: {0}'.format(device.type))
print('Serial: {0}'.format(device.serial))
print('Device ID: {0}'.format(device.device_id))
print('Parent ID: {0}'.format(device.parent_id))
print('Online: {0}'.format(device.available))
print('Unattended Open: {0}'.format(device.open_allowed))
print('Unattended Close: {0}'.format(device.close_allowed))
print()
print('Current State: {0}'.format(device.state))