Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def try_login(username, password, vendor):
"""Try logging in to device and return any errors."""
this_vendor = None
if vendor == "vorwerk":
this_vendor = Vorwerk()
else: # Neato
this_vendor = Neato()
try:
Account(username, password, this_vendor)
except NeatoLoginException:
return "invalid_credentials"
except NeatoRobotException:
return "unexpected_error"
return None
async def async_setup_entry(hass, entry):
"""Set up config entry."""
hub = NeatoHub(hass, entry.data, Account)
await hass.async_add_executor_job(hub.login)
if not hub.logged_in:
_LOGGER.debug("Failed to login to Neato API")
return False
try:
await hass.async_add_executor_job(hub.update_robots)
except NeatoRobotException:
_LOGGER.debug("Failed to connect to Neato API")
raise ConfigEntryNotReady
hass.data[NEATO_LOGIN] = hub
for component in ("camera", "vacuum", "switch", "sensor"):
hass.async_add_job(
def try_login(username, password, vendor):
"""Try logging in to device and return any errors."""
this_vendor = None
if vendor == "vorwerk":
this_vendor = Vorwerk()
else: # Neato
this_vendor = Neato()
try:
Account(username, password, this_vendor)
except NeatoLoginException:
return "invalid_credentials"
except NeatoRobotException:
return "unexpected_error"
return None
async def async_setup_entry(hass, entry):
"""Set up config entry."""
hass.data[NEATO_LOGIN] = NeatoHub(hass, entry.data, Account)
hub = hass.data[NEATO_LOGIN]
await hass.async_add_executor_job(hub.login)
if not hub.logged_in:
_LOGGER.debug("Failed to login to Neato API")
return False
try:
await hass.async_add_executor_job(hub.update_robots)
except NeatoRobotException:
_LOGGER.debug("Failed to connect to Neato API")
return False
for component in ("camera", "vacuum", "switch", "sensor"):
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, component)
import sys
from pybotvac import Account, Vorwerk
if sys.version_info[0] < 3:
input = raw_input
email = input('Enter email\n')
password = input('Enter password\n')
vendor = Vorwerk()
account = Account(email, password, vendor)
print("Robots:")
for robot in account.robots:
print(robot)
print()
print("State:\n", robot.state)
print()
print("Schedule enabled:", robot.schedule_enabled)
print("Disabling schedule")
robot.schedule_enabled = False
print("Schedule enabled:", robot.schedule_enabled)
def setup(hass, config):
"""Set up the Neato component."""
from pybotvac import Account
hass.data[NEATO_LOGIN] = NeatoHub(hass, config[DOMAIN], Account)
hub = hass.data[NEATO_LOGIN]
if not hub.login():
_LOGGER.debug("Failed to login to Neato API")
return False
hub.update_robots()
for component in ('camera', 'vacuum', 'switch'):
discovery.load_platform(hass, component, DOMAIN, {}, config)
return True
def setup(hass, config):
"""Set up the Neato component."""
from pybotvac import Account
hass.data[NEATO_LOGIN] = NeatoHub(hass, config[DOMAIN], Account)
hub = hass.data[NEATO_LOGIN]
if not hub.login():
_LOGGER.debug("Failed to login to Neato API")
return False
hub.update_robots()
for component in ('camera', 'vacuum', 'switch'):
discovery.load_platform(hass, component, DOMAIN, {}, config)
return True