-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
402 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,22 +68,54 @@ robot.schedule_enabled = False | |
``` | ||
|
||
### Account | ||
If the serial and secret is unknown, they can be retrieved using the Account class. | ||
If the serial and secret are unknown, they can be retrieved using the Account class. | ||
You need a session instance to create an account. | ||
There are three different types of sessions available. | ||
It depends on your provider which session is suitable for you. | ||
|
||
* **PasswordSession** lets you authenticate via E-Mail and Password. Even though this works fine, it is not recommended. | ||
* **OAuthSession** lets you authenticate via OAuth2. You have to create an application [here](https://developers.neatorobotics.com/applications) in order to generate `client_id`, `client_secret` and `redirect_url`. | ||
* **PasswordlessSession** is known to work for users of the new MyKobold App. The only known `client_id` is `KY4YbVAvtgB7lp8vIbWQ7zLk3hssZlhR`. | ||
|
||
```python | ||
>>> from pybotvac import Account | ||
>>> # List all robots associated with account | ||
>>> for robot in Account('[email protected]', 'sample_password').robots: | ||
... print(robot) | ||
Name: my_robot_name, Serial: OPS01234-0123456789AB, Secret: 0123456789ABCDEF0123456789ABCDEF, Traits: ['maps'] | ||
from pybotvac import Account, Neato, OAuthSession, PasswordlessSession, PasswordSession, Vorwerk | ||
|
||
email = "Your email" | ||
password = "Your password" | ||
client_id = "Your client it" | ||
client_secret = "Your client secret" | ||
redirect_uri = "Your redirect URI" | ||
|
||
# Authenticate via Email and Password | ||
password_session = PasswordSession(email=email, password=password, vendor=Neato()) | ||
|
||
# Authenticate via OAuth2 | ||
oauth_session = OAuthSession(client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, vendor=Neato()) | ||
authorization_url = oauth_session.get_authorization_url() | ||
print("Visit: " + authorization_url) | ||
authorization_response = input("Enter the full callback URL: ") | ||
token = oauth_session.fetch_token(authorization_response) | ||
|
||
# Authenticate via One Time Password | ||
passwordless_session = PasswordlessSession(client_id=client_id, vendor=Vorwerk()) | ||
passwordless_session.send_email_otp(email) | ||
code = input("Enter the code: ") | ||
passwordless_session.fetch_token_passwordless(email, code) | ||
|
||
# Create an account with one of the generated sessions | ||
account = Account(password_session) | ||
|
||
# List all robots associated with account | ||
for robot in account.robots: | ||
print(robot) | ||
``` | ||
|
||
Information about maps and download of maps can be done from the Account class: | ||
|
||
```python | ||
>>> from pybotvac import Account | ||
>>> # List all maps associated with a specific robot | ||
>>> for map_info in Account('[email protected]', 'sample_password').maps: | ||
>>> for map_info in Account(PasswordSession('[email protected]', 'sample_password')).maps: | ||
... print(map_info) | ||
``` | ||
|
||
|
@@ -93,7 +125,7 @@ You need the url from the map output to do that: | |
```python | ||
>>> from pybotvac import Account | ||
>>> # List all maps associated with a specific robot | ||
>>> map = Account('[email protected]', 'sample_password').maps | ||
>>> map = Account(PasswordSession('[email protected]', 'sample_password')).maps | ||
>>> download_link = map['robot_serial']['maps'][0]['url'] | ||
>>> Account('[email protected]', 'sample_password').get_map_image(download_link) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from .account import Account | ||
from .neato import Neato | ||
from .robot import Robot | ||
from .session import OAuthSession, PasswordlessSession, PasswordSession | ||
from .version import __version__ | ||
from .vorwerk import Vorwerk | ||
from .neato import Neato |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
import os | ||
from dataclasses import dataclass | ||
from typing import List, Union | ||
|
||
|
||
class Neato: | ||
@dataclass(init=False, frozen=True) | ||
class Vendor: | ||
name: str | ||
endpoint: str | ||
auth_endpoint: str | ||
passwordless_endpoint: str | ||
token_endpoint: str | ||
scope: List[str] | ||
audience: str | ||
source: str | ||
cert_path: Union[str, bool] = False | ||
beehive_version: str = "application/vnd.neato.beehive.v1+json" | ||
nucleo_version: str = "application/vnd.neato.nucleo.v1" | ||
|
||
|
||
class Neato(Vendor): | ||
name = "neato" | ||
endpoint = "https://beehive.neatocloud.com/" | ||
headers = "application/vnd.neato.nucleo.v1" | ||
cert_path = cert_path = os.path.join( | ||
os.path.dirname(__file__), "cert", "neatocloud.com.crt" | ||
) | ||
auth_endpoint = "https://apps.neatorobotics.com/oauth2/authorize" | ||
token_endpoint = "https://beehive.neatocloud.com/oauth2/token" | ||
scope = ["public_profile", "control_robots", "maps"] | ||
cert_path = os.path.join(os.path.dirname(__file__), "cert", "neatocloud.com.crt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.