divera.client package

Module contents

class divera.client.Client(config_folder: str = None, use_recommended_callbacks: bool = True)[source]

Bases: object

add_callback(callback: ~typing.Callable, filter_: [typing.Type[divera.triggers.Trigger], typing.Callable, <class 'Exception'>], model: [typing.Type[divera.models.Model], typing.List[typing.Type[divera.models.Model]]] = None)[source]

Add callbacks and rules on when and for which model they are to be called.

Parameters:
  • callback – The function to be called.

  • filter – The class of the trigger or a function that returns True if the function is to be called.

  • model – The type of object this callback should be used with. Use None for any model, or a list of models for any model in that list.

Returns:

None

async close()[source]
get_access_token()[source]
get_domain()[source]
async get_jwt(version: str = '')[source]

Get a new jason web token

Parameters:

version – If you add any of [‘ws’, ‘api’] to get the respective jwt

Returns:

jason web token as string

get_protocol()[source]
async get_ucr()[source]
get_url()[source]
get_username()[source]
async handle_socket_data(data)[source]
is_logged_in()[source]
async listen()[source]
async login(username, password, domain: str = None, url_websocket: str = None)[source]

Log in to an account.

Parameters:
  • username – email address of the user

  • password – password if the user

  • domain – domain of the server (needed if not set in config yet)

  • url_websocket – url of the websocket of the server for real time updated

Returns:

async login_with_access_token(username: str, access_token: str, domain: str)[source]

If the user should not be asked for a password, they can be asked for their access_token instead. This is also referred to as ‘access key’ and can be found in the DEBUG section of your account settings.

Parameters:
  • username – Your username (email)

  • access_token – The access token / access key from the DEBUG section of your account settings.

  • domain – The domain of your divera instance

logout()[source]

Delete the password from keyring.

async perform_web_request(request)[source]
async poll_once(models: [List[Type[divera.models.Model]], Tuple[Type[divera.models.Model]]] = None)[source]
async poll_until_stopped()[source]
async process_event(event: [<class 'divera.triggers.Trigger'>, <class 'Exception'>])[source]
read_config()[source]

Load the configuration data from the divera.json inside the folder specified on __init__. The configuration also gets updated to the latest version.

remove_object_from_config(obj)[source]
async request(endpoint: [<class 'divera.api.endpointwrappers.EndPoint'>, typing.AsyncGenerator, typing.Generator, typing.Any]) Any[source]
async set_access_token(access_token: str)[source]
Parameters:

access_token

Returns:

set_domain(domain: str)[source]
async set_status(status: [<class 'int'>, <class 'divera.models.status.Status'>] = None, note: str = None, vehicle: int = None, reset_date: [<class 'int'>, <class 'datetime.datetime'>] = None, reset_to: int = None, alarm_skip: bool = None, status_skip_statusplan: bool = None, status_skip_geofence: bool = None)[source]
setup_socket_callbacks()[source]

Setup all known events to call self.handle_socket_data

start_polling()[source]
store_config()[source]

Save the configuration data to the divera.json inside the folder specified on __init__.

store_object_to_config(obj)[source]
update_object_in_config(obj)[source]