def login(email, password, vendor): if (vendor == "Neato"): v = Neato() elif (vendor == "Vorwerk"): v = Vorwerk() try: account = Account(email, password, v) if (account is None): # failed login pyotherside.send("loginrequired") r_json = { "vendor": vendor, "token": account.access_token, "robots": [] } for robot in account.robots: r_json["robots"].append({ "name": robot.name, "serial": robot.serial, "secret": robot.secret }) with open(CACHE_FILE, "w") as write_file: json.dump(r_json, write_file) init() except requests.exceptions.HTTPError as e: # Whoops it wasn't a 200 pyotherside.send("loginrequired")
def init(): if not os.path.exists(CACHE_DIR): pyotherside.send("loginrequired") os.makedirs(CACHE_DIR) return if not os.path.exists(CACHE_FILE): pyotherside.send("loginrequired") return with open(CACHE_FILE, "r") as read_file: global account global robots global vendor robots = json.load(read_file) if (robots["vendor"] == "Neato"): vendor = Neato() elif (robots["vendor"] == "Vorwerk"): vendor = Vorwerk() account = Account(robots["token"], None, vendor) for r in robots["robots"]: pyotherside.send("rfound", r["name"]) pyotherside.send("loginsuccessful")
def __init__(self, hass, domain_config, neato): """Initialize the Neato hub.""" self.config = domain_config self._neato = neato self._hass = hass if self.config[CONF_VENDOR] == "vorwerk": self._vendor = Vorwerk() else: # Neato self._vendor = Neato() self.my_neato = None self.logged_in = False
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
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) print("Enabling schedule") robot.schedule_enabled = True