Exemplo n.º 1
0
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")
Exemplo n.º 2
0
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")
Exemplo n.º 3
0
    def onStart(self):

        # List all robots associated with account
        botvacSession = PasswordSession(email=Parameters['Username'],
                                        password=Parameters['Password'],
                                        vendor=Neato())
        botvacAccount = Account(botvacSession).robots
        botvacDevice = next((botvac for botvac in botvacAccount
                             if botvac.name == Parameters["Mode3"]), None)
        if botvacDevice is None:
            Domoticz.Log("No robot found")
        else:
            self.DEVICE_NAME = botvacDevice.name
            self.DEVICE_SERIAL = botvacDevice.serial
            self.API_SECRET = botvacDevice.secret

        if Parameters["Mode4"] == "Debug":
            Domoticz.Debugging(1)
            DumpConfigToLog()

        #if (self.iconName not in Images): Domoticz.Image('icons.zip').Create()
        #iconID = Images[self.iconName].ID

        # Check if images are in database
        if self.iconName not in Images:
            Domoticz.Image("icons.zip").Create()
        try:
            iconID = Images[self.iconName].ID
        except:
            iconID = 0
        Domoticz.Debug("Image created. ID: " + str(iconID))

        if self.statusUnit not in Devices:
            Domoticz.Device(Name='Status',
                            Unit=self.statusUnit,
                            Type=17,
                            Switchtype=17,
                            Image=iconID,
                            Used=1).Create()

        if self.controlUnit not in Devices:
            Domoticz.Device(Name='Control',
                            Unit=self.controlUnit,
                            TypeName='Selector Switch',
                            Image=iconID,
                            Options=self.controlOptions,
                            Used=1).Create()

        if self.scheduleUnit not in Devices:
            Domoticz.Device(Name='Schedule',
                            Unit=self.scheduleUnit,
                            TypeName='Switch',
                            Image=iconID,
                            Used=1).Create()

        self.botvacGetValues()
        Domoticz.Heartbeat(self.heartbeatsInterval)
        Domoticz.Debug("onStart called")
def startPairing(info):
    # Start OAuth2 session
    apiKey = apiKeyStorage().requestKey("neato")
    oauthSession = OAuthSession(client_id=apiKey.data("clientId"),
                                client_secret=apiKey.data("clientSecret"),
                                redirect_uri="https://127.0.0.1:8888",
                                vendor=Neato())
    oauthSessions[info.transactionId] = oauthSession
    authorizationUrl = oauthSession.get_authorization_url()
    info.oAuthUrl = authorizationUrl
    info.finish(nymea.ThingErrorNoError)
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
async def async_get_auth_implementation(
    hass: HomeAssistant, auth_domain: str, credential: ClientCredential
) -> config_entry_oauth2_flow.AbstractOAuth2Implementation:
    """Return auth implementation for a custom auth implementation."""
    vendor = Neato()
    return api.NeatoImplementation(
        hass,
        auth_domain,
        credential,
        AuthorizationServer(
            authorize_url=vendor.auth_endpoint,
            token_url=vendor.token_endpoint,
        ),
    )
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
    """Set up the Neato component."""
    hass.data[NEATO_DOMAIN] = {}

    if NEATO_DOMAIN not in config:
        return True

    hass.data[NEATO_CONFIG] = config[NEATO_DOMAIN]
    vendor = Neato()
    config_flow.OAuth2FlowHandler.async_register_implementation(
        hass,
        api.NeatoImplementation(
            hass,
            NEATO_DOMAIN,
            config[NEATO_DOMAIN][CONF_CLIENT_ID],
            config[NEATO_DOMAIN][CONF_CLIENT_SECRET],
            vendor.auth_endpoint,
            vendor.token_endpoint,
        ),
    )

    return True
Exemplo n.º 9
0
    PasswordlessSession,
    PasswordSession,
    Vorwerk,
)

# Set email and password if you plan to use password authentication.
# Set Client ID and Secret if you plan to use OAuth2.
# If you plan to use email OTP, all you need to do is specify your email and a Client ID.
email = "Your email"
password = "******"
client_id = "Your client it"
client_secret = "Your client secret"
redirect_uri = "Your redirect URI"

# Set your vendor
vendor = Neato()

##########################
# Authenticate via Email and Password
##########################
# session = PasswordSession(email=email, password=password, vendor=vendor)
# account = Account(session)

##########################
# Authenticate via OAuth2
##########################
session = OAuthSession(
    client_id=client_id,
    client_secret=client_secret,
    redirect_uri=redirect_uri,
    vendor=vendor,