Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5823012259 | |||
| a62ae48001 | |||
| 7dec38109a | |||
| e6e471deae | |||
| b6ede1af3b | |||
| 6f02f0b925 | |||
| e38a402d44 | |||
| a05b5bdaa6 | |||
| 3053f2db69 | |||
| 859d962cae | |||
| 60254999df | |||
| 93f089c431 | |||
| e59cd77908 | |||
| 1275ffa882 | |||
| 6ab8749f11 | |||
| 9923f45a95 | |||
| 13df6822c8 | |||
| 9bb33b6020 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ __pycache__
|
|||||||
**/__pycache__
|
**/__pycache__
|
||||||
dist/
|
dist/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
|
build/
|
||||||
13
README.md
13
README.md
@@ -1,16 +1,18 @@
|
|||||||
# Georideapilib
|
# georideapilib
|
||||||

|

|
||||||
|
|
||||||
⚠️ this is not an official implementation
|
⚠️ this is not an official implementation
|
||||||
|
|
||||||
|
[](https://pypi.org/project/georideapilib/)
|
||||||
|
|
||||||
Official georide website: https://georide.fr/
|
Official georide website: https://georide.fr/
|
||||||
|
|
||||||
This library can control your georide tracker tracker
|
This library can control your georide tracker
|
||||||
|
|
||||||
|
|
||||||
Some code have been taken from @alexmohr https://github.com/alexmohr/sonyapilib
|
Some code have been taken from @alexmohr https://github.com/alexmohr/sonyapilib
|
||||||
|
|
||||||
This library is used as communication interface in a home assistant component to control media players, which can be found here:(Not ready yet ;))
|
This library is used as communication interface in a home assistant component to control media players, which can be found here: https://github.com/ptimatth/GeorideHA
|
||||||
|
|
||||||
At the moment not all functions offered by the api are implemented. If you miss a function feel free to create a pull request or open a feature request.
|
At the moment not all functions offered by the api are implemented. If you miss a function feel free to create a pull request or open a feature request.
|
||||||
|
|
||||||
@@ -25,8 +27,7 @@ This library has been tested with python 3.7 and above, functionality for older
|
|||||||
## Main repo:
|
## Main repo:
|
||||||
- https://git.tontontux.fr/mduval/pyGeoride
|
- https://git.tontontux.fr/mduval/pyGeoride
|
||||||
## Github repo:
|
## Github repo:
|
||||||
- https://github.com/ptimatth/pyGeoride
|
- https://github.com/ptimatth/georide-api
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
- [ ] Add support of SocketIO connection
|
|
||||||
- [ ] Add support of "Get a shared trip" endpoint
|
- [ ] Add support of "Get a shared trip" endpoint
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import time
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
logging.config.fileConfig('logging.conf')
|
logging.config.fileConfig('logging.conf')
|
||||||
from georideapilib.objects import GeorideAccount
|
from georideapilib.objects import GeoRideAccount
|
||||||
import georideapilib.api as GeorideApi
|
import georideapilib.api as GeoRideApi
|
||||||
from georideapilib.socket import GeorideSocket
|
from georideapilib.socket import GeoRideSocket
|
||||||
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
@@ -20,17 +20,17 @@ def example():
|
|||||||
# account = GeorideAccount(0, "<your_email>", False, token)
|
# account = GeorideAccount(0, "<your_email>", False, token)
|
||||||
|
|
||||||
|
|
||||||
account = GeorideApi.get_authorisation_token("<your_email>", "<your_password>")
|
account = GeoRideApi.get_authorisation_token("<your_email>", "<your_password>")
|
||||||
print("token 1: ", account.auth_token)
|
print("token 1: ", account.auth_token)
|
||||||
_LOGGER.info("token 1: %s", account.auth_token)
|
_LOGGER.info("token 1: %s", account.auth_token)
|
||||||
# pylint: disable=W0105
|
# pylint: disable=W0105
|
||||||
|
|
||||||
def locked_locked(data):
|
def locked_locked(data):
|
||||||
_LOGGER.info("Locke received")
|
_LOGGER.info("Lock received")
|
||||||
|
|
||||||
|
|
||||||
def connect_socket(account):
|
def connect_socket(account):
|
||||||
socket = GeorideSocket()
|
socket = GeoRideSocket()
|
||||||
socket.subscribe_locked(locked_locked)
|
socket.subscribe_locked(locked_locked)
|
||||||
socket.init()
|
socket.init()
|
||||||
socket.connect(account.auth_token)
|
socket.connect(account.auth_token)
|
||||||
@@ -41,52 +41,77 @@ def example():
|
|||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
account.auth_token = GeorideApi.renewToken(account.auth_token)
|
account.auth_token = GeoRideApi.renewToken(account.auth_token)
|
||||||
print("token 2: ", account.auth_token)
|
print("token 2: ", account.auth_token)
|
||||||
""" # pylint: disable=W0105
|
""" # pylint: disable=W0105
|
||||||
|
|
||||||
user = GeorideApi.get_user(account.auth_token)
|
user = GeoRideApi.get_user(account.auth_token)
|
||||||
_LOGGER.info("User: %s", user.first_name)
|
_LOGGER.info("User: %s", user.first_name)
|
||||||
|
|
||||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
trackers = GeoRideApi.get_trackers(account.auth_token)
|
||||||
tracker = trackers[0]
|
tracker = trackers[0]
|
||||||
_LOGGER.info("Tracker name: %s", tracker.tracker_name)
|
_LOGGER.info("Tracker name: %s", tracker.tracker_name)
|
||||||
|
|
||||||
trips = GeorideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24")
|
trips = GeoRideApi.get_trips(account.auth_token, tracker.tracker_id, "2019-10-10", "2019-10-24")
|
||||||
trip = trips[0]
|
trip = trips[0]
|
||||||
trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ')
|
trip_date = datetime.datetime.strptime("2019-10-10T06:45:34.000Z", '%Y-%m-%dT%H:%M:%S.%fZ')
|
||||||
_LOGGER.info("Trip date: %s, from: %s, to: %s", trip_date, trip.nice_start_address,
|
_LOGGER.info("Trip date: %s, from: %s, to: %s", trip_date, trip.nice_start_address,
|
||||||
trip.nice_end_address)
|
trip.nice_end_address)
|
||||||
|
|
||||||
positions = GeorideApi.get_positions(account.auth_token, tracker.tracker_id,
|
positions = GeoRideApi.get_positions(account.auth_token, tracker.tracker_id,
|
||||||
"2019-10-10", "2019-10-24")
|
"2019-10-10", "2019-10-24")
|
||||||
position = positions[0]
|
position = positions[0]
|
||||||
_LOGGER.info("Position speed: %s, lon: %s, lat: %s", position.speed, position.longitude,
|
_LOGGER.info("Position speed: %s, lon: %s, lat: %s", position.speed, position.longitude,
|
||||||
position.latitude)
|
position.latitude)
|
||||||
|
|
||||||
|
|
||||||
trip_shared = GeorideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id,
|
trip_shared = GeoRideApi.share_a_trip_by_date(account.auth_token, tracker.tracker_id,
|
||||||
"2019-10-10", "2019-10-24")
|
"2019-10-10", "2019-10-24")
|
||||||
_LOGGER.info("tripShared url: %s, id: %s", trip_shared.url, trip_shared.share_id)
|
_LOGGER.info("tripShared url: %s, id: %s", trip_shared.url, trip_shared.share_id)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
have_been_locked = GeorideApi.lock_tracker(account.auth_token, tracker.tracker_id)
|
have_been_locked = GeoRideApi.lock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
_LOGGER.info("Tracker have been locked: %s", have_been_locked)
|
_LOGGER.info("Tracker have been locked: %s", have_been_locked)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
have_been_unlocked = GeorideApi.unlock_tracker(account.auth_token, tracker.tracker_id)
|
have_been_unlocked = GeoRideApi.unlock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
_LOGGER.info("Tracker have been unlocked: %s", have_been_unlocked)
|
_LOGGER.info("Tracker have been unlocked: %s", have_been_unlocked)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
is_locked = GeorideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id)
|
is_locked = GeoRideApi.toogle_lock_tracker(account.auth_token, tracker.tracker_id)
|
||||||
_LOGGER.info("Tracker is locked: %s", is_locked)
|
_LOGGER.info("Tracker is locked: %s", is_locked)
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
trackers = GeorideApi.get_trackers(account.auth_token)
|
trackers = GeoRideApi.get_trackers(account.auth_token)
|
||||||
tracker = trackers[0]
|
tracker = trackers[0]
|
||||||
_LOGGER.info("Tracker name: %s is locked: %s", tracker.tracker_name, tracker.is_locked)
|
_LOGGER.info("Tracker name: %s is locked: %s", tracker.tracker_name, tracker.is_locked)
|
||||||
|
|
||||||
|
if tracker.version >= 3:
|
||||||
|
_LOGGER.info("Congrat for your new gen GeoRide \o/")
|
||||||
|
|
||||||
|
# Have been commented for your neighbor ;)
|
||||||
|
# time.sleep(10)
|
||||||
|
# have_been_siren_turned_on = GeoRideApi.change_tracker_siren_state(account.auth_token, tracker.tracker_id, True)
|
||||||
|
# _LOGGER.info("Tracker siren is on: %s", have_been_siren_turned_on)
|
||||||
|
|
||||||
|
# time.sleep(5)
|
||||||
|
# have_been_siren_turned_off = GeoRideApi.change_tracker_siren_state(account.auth_token, tracker.tracker_id, False)
|
||||||
|
# _LOGGER.info("Tracker siren is off: %s", have_been_siren_turned_off)
|
||||||
|
|
||||||
|
time.sleep(10)
|
||||||
|
changed_to_eco_mode = GeoRideApi.change_tracker_eco_mode_state(account.auth_token, tracker.tracker_id, True)
|
||||||
|
_LOGGER.info("Tracker eco mode is on: %s", changed_to_eco_mode)
|
||||||
|
|
||||||
|
time.sleep(5)
|
||||||
|
changed_to_normal_mode = GeoRideApi.change_tracker_eco_mode_state(account.auth_token, tracker.tracker_id, False)
|
||||||
|
_LOGGER.info("Tracker eco mode is off: %s", changed_to_normal_mode)
|
||||||
|
|
||||||
|
tracker_beacon = GeoRideApi.get_tracker_beacon(account.auth_token, tracker.tracker_id)
|
||||||
|
_LOGGER.info("Your tracker beacon state: %s", tracker_beacon)
|
||||||
|
|
||||||
|
#you can also shutdown your tracker with shutdown_tracker(<token>, tracker_id) but i d'on give you an example.
|
||||||
|
else:
|
||||||
|
_LOGGER.info("You are from the first wave ;)")
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from georideapilib.objects import (
|
from georideapilib.objects import (
|
||||||
GeorideTracker,
|
GeoRideTracker,
|
||||||
GeorideAccount,
|
GeoRideAccount,
|
||||||
GeorideUser,
|
GeoRideUser,
|
||||||
GeorideTrackerTrip,
|
GeoRideTrackerTrip,
|
||||||
GeorideTrackerPosition,
|
GeoRideTrackerPosition,
|
||||||
GeorideSharedTrip
|
GeoRideSharedTrip
|
||||||
)
|
)
|
||||||
|
|
||||||
from georideapilib.exception import (
|
from georideapilib.exception import (
|
||||||
@@ -27,13 +27,19 @@ GEORIDE_API_ENDPOINT_LOGIN = "/user/login"
|
|||||||
GEORIDE_API_ENDPOINT_NEW_TOKEN = "/user/new-token"
|
GEORIDE_API_ENDPOINT_NEW_TOKEN = "/user/new-token"
|
||||||
GEORIDE_API_ENDPOINT_LOGOUT = "/user/logout"
|
GEORIDE_API_ENDPOINT_LOGOUT = "/user/logout"
|
||||||
GEORIDE_API_ENDPOINT_USER = "/user"
|
GEORIDE_API_ENDPOINT_USER = "/user"
|
||||||
GEORIDE_API_ENDPOINT_TRAKERS = "/user/trackers"
|
GEORIDE_API_ENDPOINT_TRACKERS = "/user/trackers"
|
||||||
GEORIDE_API_ENDPOINT_TRIPS = "/tracker/:trackerId/trips"
|
GEORIDE_API_ENDPOINT_TRIPS = "/tracker/:trackerId/trips"
|
||||||
GEORIDE_API_ENDPOINT_LOCK = "/tracker/:trackerId/lock"
|
GEORIDE_API_ENDPOINT_LOCK = "/tracker/:trackerId/lock"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_BEACON = "/tracker/:trackerId/beacon"
|
||||||
GEORIDE_API_ENDPOINT_UNLOCK = "/tracker/:trackerId/unlock"
|
GEORIDE_API_ENDPOINT_UNLOCK = "/tracker/:trackerId/unlock"
|
||||||
GEORIDE_API_ENDPOINT_TOGGLE_LOCK = "/tracker/:trackerId/toggleLock"
|
GEORIDE_API_ENDPOINT_TOGGLE_LOCK = "/tracker/:trackerId/toggleLock"
|
||||||
GEORIDE_API_ENDPOINT_POSITIONS = "/tracker/:trackerId/trips/positions"
|
GEORIDE_API_ENDPOINT_POSITIONS = "/tracker/:trackerId/trips/positions"
|
||||||
GEORIDE_API_ENDPOINT_TRIP_SHARE = "/tracker/:trackerId/share/trip"
|
GEORIDE_API_ENDPOINT_TRIP_SHARE = "/tracker/:trackerId/share/trip"
|
||||||
|
GEORIDE_API_ENDPOINT_SHUTDOWN_TRACKER = "/tracker/:trackerId/shutdown"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ALARM_OFF = "/tracker/:trackerId/sonor-alarm/off"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ALARM_ON = "/tracker/:trackerId/sonor-alarm/on"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_OFF = "/tracker/:trackerId/eco-mode/off"
|
||||||
|
GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_ON = "/tracker/:trackerId/eco-mode/on"
|
||||||
|
|
||||||
_SESSION = requests.Session()
|
_SESSION = requests.Session()
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@@ -51,13 +57,14 @@ def get_authorisation_token(email, password):
|
|||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
_LOGGER.debug("Login success")
|
_LOGGER.debug("Login success")
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
account = GeorideAccount.from_json(response_data)
|
account = GeoRideAccount.from_json(response_data)
|
||||||
elif response.status_code == 403:
|
elif response.status_code == 403:
|
||||||
_LOGGER.warnning("Login failed")
|
_LOGGER.warning("Login failed")
|
||||||
raise LoginException("Login failed")
|
raise LoginException(get_authorisation_token, "Login failed")
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
||||||
raise SeverException("Georide login, http error code: {}".format(response.status_code))
|
raise SeverException(get_authorisation_token,
|
||||||
|
"Georide login, http error code: {}".format(response.status_code))
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
||||||
@@ -73,10 +80,11 @@ def renew_token(token):
|
|||||||
new_token = response_data['authToken']
|
new_token = response_data['authToken']
|
||||||
elif response.status_code == 401:
|
elif response.status_code == 401:
|
||||||
_LOGGER.warnning("Renew token refused")
|
_LOGGER.warnning("Renew token refused")
|
||||||
raise UnauthorizedException("Renew token refused")
|
raise UnauthorizedException(renew_token, "Renew token refused")
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
_LOGGER.error("Georide login, http error code: %s", response.status_code)
|
||||||
raise SeverException("Georide login, http error code: {}".format(response.status_code))
|
raise SeverException(renew_token,
|
||||||
|
"Georide login, http error code: {}".format(response.status_code))
|
||||||
return new_token
|
return new_token
|
||||||
|
|
||||||
def revoke_token(token):
|
def revoke_token(token):
|
||||||
@@ -87,7 +95,7 @@ def revoke_token(token):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
_LOGGER.warnning("Token allready revoked")
|
_LOGGER.warnning("Token allready revoked")
|
||||||
raise UnauthorizedException("Token allready revoked")
|
raise UnauthorizedException(revoke_token, "Token allready revoked")
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
_LOGGER.warnning("Token allready revoked")
|
_LOGGER.warnning("Token allready revoked")
|
||||||
return False
|
return False
|
||||||
@@ -102,22 +110,37 @@ def get_user(token):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
_LOGGER.debug(response_data)
|
_LOGGER.debug(response_data)
|
||||||
account = GeorideUser.from_json(response_data)
|
account = GeoRideUser.from_json(response_data)
|
||||||
return account
|
return account
|
||||||
|
|
||||||
def get_trackers(token):
|
def get_trackers(token):
|
||||||
""" get user trackers """
|
""" get user trackers """
|
||||||
|
|
||||||
headers = {"Authorization": "Bearer " + token}
|
headers = {"Authorization": "Bearer " + token}
|
||||||
response = _SESSION.get(
|
response = _SESSION.get(
|
||||||
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRAKERS,
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKERS,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
trackers = []
|
trackers = []
|
||||||
for json_tracker in response_data:
|
for json_tracker in response_data:
|
||||||
trackers.append(GeorideTracker.from_json(json_tracker))
|
_LOGGER.debug(json_tracker)
|
||||||
|
trackers.append(GeoRideTracker.from_json(json_tracker))
|
||||||
return trackers
|
return trackers
|
||||||
|
|
||||||
|
def get_tracker_beacon(token, tracker_id):
|
||||||
|
""" get user trackers """
|
||||||
|
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = _SESSION.get(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_BEACON.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
|
||||||
|
response_data = response.json()
|
||||||
|
if response.status_code == 200:
|
||||||
|
return GeoRideTrackerBeacon.from_json(response_data)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_trips(token, tracker_id, from_date, to_date):
|
def get_trips(token, tracker_id, from_date, to_date):
|
||||||
""" return all trips between two dates """
|
""" return all trips between two dates """
|
||||||
@@ -130,7 +153,7 @@ def get_trips(token, tracker_id, from_date, to_date):
|
|||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
trips = []
|
trips = []
|
||||||
for json_trip in response_data:
|
for json_trip in response_data:
|
||||||
trips.append(GeorideTrackerTrip.from_json(json_trip))
|
trips.append(GeoRideTrackerTrip.from_json(json_trip))
|
||||||
return trips
|
return trips
|
||||||
|
|
||||||
def get_positions(token, tracker_id, from_date, to_date):
|
def get_positions(token, tracker_id, from_date, to_date):
|
||||||
@@ -144,7 +167,7 @@ def get_positions(token, tracker_id, from_date, to_date):
|
|||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
positions = []
|
positions = []
|
||||||
for json_position in response_data:
|
for json_position in response_data:
|
||||||
positions.append(GeorideTrackerPosition.from_json(json_position))
|
positions.append(GeoRideTrackerPosition.from_json(json_position))
|
||||||
return positions
|
return positions
|
||||||
|
|
||||||
def share_a_trip_by_trip_id(token, tracker_id, trip_id):
|
def share_a_trip_by_trip_id(token, tracker_id, trip_id):
|
||||||
@@ -182,7 +205,7 @@ def _share_a_trip(token, tracker_id, trip_id=None, from_date=None, # pylint: dis
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
return GeorideSharedTrip.from_json(response_data)
|
return GeoRideSharedTrip.from_json(response_data)
|
||||||
|
|
||||||
def lock_tracker(token, tracker_id):
|
def lock_tracker(token, tracker_id):
|
||||||
""" used to lock a tracker """
|
""" used to lock a tracker """
|
||||||
@@ -213,5 +236,46 @@ def toogle_lock_tracker(token, tracker_id):
|
|||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
return response_data['locked']
|
return response_data['locked']
|
||||||
|
|
||||||
|
def change_tracker_siren_state(token, tracker_id, state: bool):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = None
|
||||||
|
if state == True:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ALARM_ON.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
else:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ALARM_OFF.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
if response.status_code != 204:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def change_tracker_eco_mode_state(token, tracker_id, state: bool):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = None
|
||||||
|
if state == True:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_ON.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
else:
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_TRACKER_ECO_MODE_OFF.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
if response.status_code != 204:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def shutdown_tracker(token, tracker_id):
|
||||||
|
""" used to toggle lock a tracker """
|
||||||
|
headers = {"Authorization": "Bearer " + token}
|
||||||
|
response = _SESSION.post(
|
||||||
|
GEORIDE_API_HOST + GEORIDE_API_ENDPOINT_SHUTDOWN_TRACKER.replace(':trackerId', str(tracker_id)),
|
||||||
|
headers=headers)
|
||||||
|
response_data = response.json()
|
||||||
|
return response_data['locked']
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print("Not a main module")
|
print("Not a main module")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
""" all geroide exception """
|
""" all GeoRide exception """
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""Base class for exceptions in this module."""
|
"""Base class for exceptions in this module."""
|
||||||
|
|||||||
@@ -3,7 +3,19 @@ Georide objects implementation
|
|||||||
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
@author Matthieu DUVAL <matthieu@duval-dev.fr>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class GeorideSharedTrip:
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class JsonMgtMetaClass(type):
|
||||||
|
@staticmethod
|
||||||
|
def json_field_protect(json, field_name, default_value = None):
|
||||||
|
return json[field_name] if field_name in json.keys() else default_value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GeoRideSharedTrip:
|
||||||
""" Shared trip object representation """
|
""" Shared trip object representation """
|
||||||
def __init__(self, url, shareId):
|
def __init__(self, url, shareId):
|
||||||
self._url = url
|
self._url = url
|
||||||
@@ -22,12 +34,12 @@ class GeorideSharedTrip:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
"""return new object fromjson"""
|
"""return new object fromjson"""
|
||||||
return GeorideSharedTrip(
|
return GeoRideSharedTrip(
|
||||||
json['url'],
|
json['url'],
|
||||||
json['shareId']
|
json['shareId']
|
||||||
)
|
)
|
||||||
|
|
||||||
class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
class GeoRideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
||||||
""" Trip object representation """
|
""" Trip object representation """
|
||||||
def __init__(self, trip_id, tracker_id, average_speed, max_speed, distance, duration, # pylint: disable=R0914, R0913
|
def __init__(self, trip_id, tracker_id, average_speed, max_speed, distance, duration, # pylint: disable=R0914, R0913
|
||||||
start_address, nice_start_address, start_lat, start_lon, end_address,
|
start_address, nice_start_address, start_lat, start_lon, end_address,
|
||||||
@@ -134,7 +146,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
"""return new object from json"""
|
"""return new object from json"""
|
||||||
return GeorideTrackerTrip(
|
return GeoRideTrackerTrip(
|
||||||
json['id'],
|
json['id'],
|
||||||
json['trackerId'],
|
json['trackerId'],
|
||||||
json['averageSpeed'],
|
json['averageSpeed'],
|
||||||
@@ -153,8 +165,7 @@ class GeorideTrackerTrip: # pylint: disable=too-many-instance-attributes
|
|||||||
json['endTime']
|
json['endTime']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class GeoRideTrackerPosition:
|
||||||
class GeorideTrackerPosition:
|
|
||||||
""" Tracker position object representation """
|
""" Tracker position object representation """
|
||||||
def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913
|
def __init__(self, fixtime, latitude, longitude, altitude, speed, address): # pylint: disable= R0913
|
||||||
self._fixtime = fixtime
|
self._fixtime = fixtime
|
||||||
@@ -197,7 +208,7 @@ class GeorideTrackerPosition:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
"""return new object fromjson"""
|
"""return new object fromjson"""
|
||||||
return GeorideTrackerPosition(
|
return GeoRideTrackerPosition(
|
||||||
json['fixtime'],
|
json['fixtime'],
|
||||||
json['latitude'],
|
json['latitude'],
|
||||||
json['longitude'],
|
json['longitude'],
|
||||||
@@ -206,10 +217,7 @@ class GeorideTrackerPosition:
|
|||||||
json['address']
|
json['address']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class GeoRideTracker(metaclass=JsonMgtMetaClass): # pylint: disable=R0904,R0902
|
||||||
|
|
||||||
|
|
||||||
class GeorideTracker: # pylint: disable=R0904,R0902
|
|
||||||
""" Tracker position object representation """
|
""" Tracker position object representation """
|
||||||
def __init__(self, tracker_id, tracker_name, device_button_action, device_button_delay, # pylint: disable= R0913, R0914, R0915
|
def __init__(self, tracker_id, tracker_name, device_button_action, device_button_delay, # pylint: disable= R0913, R0914, R0915
|
||||||
vibration_level, is_old_tracker, auto_lock_freezed_to, fixtime, role,
|
vibration_level, is_old_tracker, auto_lock_freezed_to, fixtime, role,
|
||||||
@@ -218,34 +226,37 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|||||||
longitude, altitude, locked_position_id, locked_latitude, locked_longitude,
|
longitude, altitude, locked_position_id, locked_latitude, locked_longitude,
|
||||||
is_locked, can_see_position, can_lock, can_unlock, can_share, can_unshare,
|
is_locked, can_see_position, can_lock, can_unlock, can_share, can_unshare,
|
||||||
can_check_speed, can_see_statistics, can_send_broken_down_signal,
|
can_check_speed, can_see_statistics, can_send_broken_down_signal,
|
||||||
can_send_stolen_signal, status):
|
can_send_stolen_signal, status, subscription_id, external_battery_voltage,
|
||||||
|
internal_battery_voltage, timezone, is_second_gen, is_up_to_date,
|
||||||
|
subscription, version, gift_card_expires, gift_card_months, odometer_updated_at,
|
||||||
|
maintenance_mode_until, battery_updated_at, is_in_eco, is_calibrated,
|
||||||
|
is_oldsubscription, software_version, has_beacon, has_outdated_beacons, ecall_activated):
|
||||||
self._tracker_id = tracker_id
|
self._tracker_id = tracker_id
|
||||||
self._tracker_name = tracker_name
|
self._tracker_name = tracker_name
|
||||||
self._device_button_action = device_button_action
|
self._device_button_action = device_button_action
|
||||||
self._device_button_delay = device_button_delay
|
self._device_button_delay = device_button_delay
|
||||||
self._vibration_level = vibration_level
|
self._vibration_level = vibration_level
|
||||||
self._is_old_tracker = is_old_tracker
|
self._is_old_tracker = is_old_tracker
|
||||||
self._auto_lock_freezed_to = auto_lock_freezed_to
|
|
||||||
self._fixtime = fixtime
|
|
||||||
self._role = role
|
|
||||||
self._last_payment_date = last_payment_date
|
|
||||||
self._gift_card_id = gift_card_id
|
|
||||||
self._expires = expires
|
|
||||||
self._activation_date = activation_date
|
|
||||||
self._odometer = odometer
|
|
||||||
self._is_stolen = is_stolen
|
|
||||||
self._is_crashed = is_crashed
|
|
||||||
self._crash_detection_disabled = crash_detection_disabled
|
|
||||||
self._speed = speed
|
|
||||||
self._moving = moving
|
|
||||||
self._position_id = position_id
|
self._position_id = position_id
|
||||||
|
self._fixtime = fixtime
|
||||||
self._latitude = latitude
|
self._latitude = latitude
|
||||||
self._longitude = longitude
|
self._longitude = longitude
|
||||||
self._altitude = altitude
|
self._altitude = altitude
|
||||||
self._locked_position_id = locked_position_id
|
self._locked_position_id = locked_position_id
|
||||||
self._locked_latitude = locked_latitude
|
self._locked_latitude = locked_latitude
|
||||||
self._locked_longitude = locked_longitude
|
self._locked_longitude = locked_longitude
|
||||||
|
self._role = role
|
||||||
|
self._last_payment_date = last_payment_date
|
||||||
|
self._gift_card_id = gift_card_id
|
||||||
|
self._expires = expires
|
||||||
|
self._activation_date = activation_date
|
||||||
|
self._odometer = odometer
|
||||||
self._is_locked = is_locked
|
self._is_locked = is_locked
|
||||||
|
self._is_stolen = is_stolen
|
||||||
|
self._is_crashed = is_crashed
|
||||||
|
self._crash_detection_disabled = crash_detection_disabled
|
||||||
|
self._speed = speed
|
||||||
|
self._moving = moving
|
||||||
self._can_see_position = can_see_position
|
self._can_see_position = can_see_position
|
||||||
self._can_lock = can_lock
|
self._can_lock = can_lock
|
||||||
self._can_unlock = can_unlock
|
self._can_unlock = can_unlock
|
||||||
@@ -256,6 +267,27 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|||||||
self._can_send_broken_down_signal = can_send_broken_down_signal
|
self._can_send_broken_down_signal = can_send_broken_down_signal
|
||||||
self._can_send_stolen_signal = can_send_stolen_signal
|
self._can_send_stolen_signal = can_send_stolen_signal
|
||||||
self._status = status
|
self._status = status
|
||||||
|
self._auto_lock_freezed_to = auto_lock_freezed_to
|
||||||
|
self._subscription_id = subscription_id
|
||||||
|
self._external_battery_voltage = external_battery_voltage
|
||||||
|
self._internal_battery_voltage = internal_battery_voltage
|
||||||
|
self._timezone = timezone
|
||||||
|
self._is_second_gen = is_second_gen
|
||||||
|
self._is_up_to_date = is_up_to_date
|
||||||
|
self._subscription = subscription
|
||||||
|
self._version = version
|
||||||
|
self._gift_card_expires = gift_card_expires
|
||||||
|
self._gift_card_months = gift_card_months
|
||||||
|
self._odometer_updated_at = odometer_updated_at
|
||||||
|
self._maintenance_mode_until = maintenance_mode_until
|
||||||
|
self._battery_updated_at = battery_updated_at
|
||||||
|
self._is_in_eco = is_in_eco
|
||||||
|
self._is_calibrated = is_calibrated
|
||||||
|
self._is_oldsubscription = is_oldsubscription
|
||||||
|
self._software_version = software_version
|
||||||
|
self._has_beacon = has_beacon
|
||||||
|
self._has_outdated_beacons = has_outdated_beacons
|
||||||
|
self._ecall_activated = ecall_activated
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tracker_id(self):
|
def tracker_id(self):
|
||||||
@@ -337,11 +369,21 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|||||||
""" is_stolen """
|
""" is_stolen """
|
||||||
return self._is_stolen
|
return self._is_stolen
|
||||||
|
|
||||||
|
@is_stolen.setter
|
||||||
|
def is_stolen(self, is_stolen):
|
||||||
|
""" is_stolen setter"""
|
||||||
|
self._is_stolen = is_stolen
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_crashed(self):
|
def is_crashed(self):
|
||||||
""" is_crashed """
|
""" is_crashed """
|
||||||
return self._is_crashed
|
return self._is_crashed
|
||||||
|
|
||||||
|
@is_crashed.setter
|
||||||
|
def is_crashed(self, is_crashed):
|
||||||
|
""" is_crashed setter"""
|
||||||
|
self._is_crashed = is_crashed
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def crash_detection_disabled(self):
|
def crash_detection_disabled(self):
|
||||||
""" crash_detection_disabled """
|
""" crash_detection_disabled """
|
||||||
@@ -487,51 +529,413 @@ class GeorideTracker: # pylint: disable=R0904,R0902
|
|||||||
""" status """
|
""" status """
|
||||||
self._status = status
|
self._status = status
|
||||||
|
|
||||||
@staticmethod
|
@property
|
||||||
def from_json(json):
|
def subscription_id(self):
|
||||||
|
"""subscription_id property"""
|
||||||
|
return self._subscription_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def external_battery_voltage(self):
|
||||||
|
"""_external_battery_voltage property"""
|
||||||
|
return self._external_battery_voltage
|
||||||
|
|
||||||
|
@property
|
||||||
|
def internal_battery_voltage(self):
|
||||||
|
"""internal_battery_voltage property"""
|
||||||
|
return self._internal_battery_voltage
|
||||||
|
|
||||||
|
@property
|
||||||
|
def timezone(self):
|
||||||
|
"""timezone property"""
|
||||||
|
return self._timezone
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_second_gen(self):
|
||||||
|
"""is_second_gen property"""
|
||||||
|
return self._is_second_gen
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_up_to_date(self):
|
||||||
|
"""is_up_to_date property"""
|
||||||
|
return self._is_up_to_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription(self):
|
||||||
|
""" subscription property """
|
||||||
|
return self._subscription
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version(self):
|
||||||
|
""" version property """
|
||||||
|
return self._version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gift_card_expires(self):
|
||||||
|
""" gift_card_expires property """
|
||||||
|
return self._gift_card_expires
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gift_card_months(self):
|
||||||
|
""" gift_card_months property """
|
||||||
|
return self._gift_card_months
|
||||||
|
|
||||||
|
@property
|
||||||
|
def odometer_updated_at(self):
|
||||||
|
""" odometer_updated_at property """
|
||||||
|
return self._odometer_updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def maintenance_mode_until(self):
|
||||||
|
""" maintenance_mode_until property """
|
||||||
|
return self._maintenance_mode_until
|
||||||
|
|
||||||
|
@property
|
||||||
|
def battery_updated_at(self):
|
||||||
|
""" battery_updated_at property """
|
||||||
|
return self._battery_updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_in_eco(self):
|
||||||
|
""" is_in_eco property """
|
||||||
|
return self._is_in_eco
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_calibrated(self):
|
||||||
|
""" is_calibrated property """
|
||||||
|
return self._is_calibrated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_oldsubscription(self):
|
||||||
|
""" is_oldsubscription property """
|
||||||
|
return self._is_oldsubscription
|
||||||
|
|
||||||
|
@property
|
||||||
|
def software_version(self):
|
||||||
|
""" software_version property """
|
||||||
|
return self._software_version
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_beacon(self):
|
||||||
|
""" has_beacon property """
|
||||||
|
return self._has_beacon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def has_outdated_beacons(self):
|
||||||
|
""" has_outdated_beacons property """
|
||||||
|
return self._has_outdated_beacons
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ecall_activated(self):
|
||||||
|
""" ecall_activated property """
|
||||||
|
return self._ecall_activated
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
"""return new object fromjson"""
|
"""return new object fromjson"""
|
||||||
return GeorideTracker(
|
return GeoRideTracker(
|
||||||
json['trackerId'],
|
json['trackerId'], # Mandatory
|
||||||
json['trackerName'],
|
json['trackerName'], # Mandatory
|
||||||
json['deviceButtonAction'],
|
cls.json_field_protect(json,'deviceButtonAction'),
|
||||||
json['deviceButtonDelay'],
|
cls.json_field_protect(json,'deviceButtonDelay'),
|
||||||
json['vibrationLevel'],
|
cls.json_field_protect(json,'vibrationLevel'),
|
||||||
json['isOldTracker'],
|
cls.json_field_protect(json,'isOldTracker', False),
|
||||||
json['autoLockFreezedTo'],
|
cls.json_field_protect(json,'autoLockFreezedTo'),
|
||||||
json['fixtime'],
|
cls.json_field_protect(json,'fixtime'),
|
||||||
json['role'],
|
json['role'], # Mandatory
|
||||||
json['lastPaymentDate'],
|
json['lastPaymentDate'],# Mandatory
|
||||||
json['giftCardId'],
|
cls.json_field_protect(json,'giftCardId'),
|
||||||
json['expires'],
|
cls.json_field_protect(json,'expires'),
|
||||||
json['activationDate'],
|
cls.json_field_protect(json,'activationDate'),
|
||||||
json['odometer'],
|
json['odometer'],#Mandatory
|
||||||
json['isStolen'],
|
cls.json_field_protect(json,'isStolen', False),
|
||||||
json['isCrashed'],
|
cls.json_field_protect(json,'isCrashed', False),
|
||||||
json['crashDetectionDisabled'],
|
cls.json_field_protect(json,'crashDetectionDisabled'),
|
||||||
json['speed'],
|
json['speed'], # Mandatory
|
||||||
json['moving'],
|
json['moving'], # Mandatory
|
||||||
json['positionId'],
|
cls.json_field_protect(json,'positionId', -1),
|
||||||
json['latitude'],
|
json['latitude'], # Mandatory
|
||||||
json['longitude'],
|
json['longitude'], # Mandatory
|
||||||
json['altitude'],
|
cls.json_field_protect(json,'altitude', 0),
|
||||||
json['lockedPositionId'],
|
cls.json_field_protect(json,'lockedPositionId'),
|
||||||
json['lockedLatitude'],
|
cls.json_field_protect(json,'lockedLatitude'),
|
||||||
json['lockedLongitude'],
|
cls.json_field_protect(json,'lockedLongitude'),
|
||||||
json['isLocked'],
|
json['isLocked'], # Mandatory
|
||||||
json['canSeePosition'],
|
json['canSeePosition'],# Mandatory
|
||||||
json['canLock'],
|
cls.json_field_protect(json,'canLock', False),
|
||||||
json['canUnlock'],
|
cls.json_field_protect(json,'canUnlock', False),
|
||||||
json['canShare'],
|
cls.json_field_protect(json,'canShare', False),
|
||||||
json['canUnshare'],
|
cls.json_field_protect(json,'canUnshare', False),
|
||||||
json['canCheckSpeed'],
|
cls.json_field_protect(json,'canCheckSpeed', False),
|
||||||
json['canSeeStatistics'],
|
cls.json_field_protect(json,'canSeeStatistics', False),
|
||||||
json['canSendBrokenDownSignal'],
|
cls.json_field_protect(json,'canSendBrokenDownSignal', False),
|
||||||
json['canSendStolenSignal'],
|
cls.json_field_protect(json,'canSendStolenSignal', False),
|
||||||
json['status']
|
json['status'],# Mandatory
|
||||||
|
cls.json_field_protect(json,'subscriptionId'),
|
||||||
|
cls.json_field_protect(json,'externalBatteryVoltage', -1.0),
|
||||||
|
cls.json_field_protect(json,'internalBatteryVoltage', -1.0),
|
||||||
|
cls.json_field_protect(json,'timezone', "Europe/Paris"),
|
||||||
|
cls.json_field_protect(json,'isSecondGen', False),
|
||||||
|
cls.json_field_protect(json,'isUpToDate', False),
|
||||||
|
GeoRideSubscription.from_json(json['subscription']) if cls.json_field_protect(json,'subscription') is not None else None,
|
||||||
|
cls.json_field_protect(json,'version', -1),
|
||||||
|
cls.json_field_protect(json,'giftCardExpires'),
|
||||||
|
cls.json_field_protect(json,'giftCardMonths'),
|
||||||
|
cls.json_field_protect(json,'odometerUpdatedAt'),
|
||||||
|
cls.json_field_protect(json,'maintenanceModeUntil'),
|
||||||
|
cls.json_field_protect(json,'batteryUpdatedAt'),
|
||||||
|
cls.json_field_protect(json,'isInEco', False),
|
||||||
|
cls.json_field_protect(json,'isCalibrated', True),
|
||||||
|
cls.json_field_protect(json,'isOldSubscription', True),
|
||||||
|
cls.json_field_protect(json,'softwareVersion', -1),
|
||||||
|
cls.json_field_protect(json,'hasBeacon', False),
|
||||||
|
cls.json_field_protect(json,'hasOutdatedBeacons', False),
|
||||||
|
cls.json_field_protect(json,'eCallActivated', False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_all_data(self, tracker):
|
||||||
|
"""update all data of th tracker from anew object"""
|
||||||
|
self._tracker_name = tracker.tracker_name
|
||||||
|
self._device_button_action = tracker.device_button_action
|
||||||
|
self._device_button_delay = tracker.device_button_delay
|
||||||
|
self._vibration_level = tracker.vibration_level
|
||||||
|
self._is_old_tracker = tracker.is_old_tracker
|
||||||
|
self._position_id = tracker.position_id
|
||||||
|
self._fixtime = tracker.fixtime
|
||||||
|
self._latitude = tracker.latitude
|
||||||
|
self._longitude = tracker.longitude
|
||||||
|
self._altitude = tracker.altitude
|
||||||
|
self._locked_position_id = tracker.locked_position_id
|
||||||
|
self._locked_latitude = tracker.locked_latitude
|
||||||
|
self._locked_longitude = tracker.locked_longitude
|
||||||
|
self._role = tracker.role
|
||||||
|
self._last_payment_date = tracker.last_payment_date
|
||||||
|
self._gift_card_id = tracker.gift_card_id
|
||||||
|
self._expires = tracker.expires
|
||||||
|
self._activation_date = tracker.activation_date
|
||||||
|
self._odometer = tracker.odometer
|
||||||
|
self._is_locked = tracker.is_locked
|
||||||
|
self._is_stolen = tracker.is_stolen
|
||||||
|
self._is_crashed = tracker.is_crashed
|
||||||
|
self._crash_detection_disabled = tracker.crash_detection_disabled
|
||||||
|
self._speed = tracker.speed
|
||||||
|
self._moving = tracker.moving
|
||||||
|
self._can_see_position = tracker.can_see_position
|
||||||
|
self._can_lock = tracker.can_lock
|
||||||
|
self._can_unlock = tracker.can_unlock
|
||||||
|
self._can_share = tracker.can_share
|
||||||
|
self._can_unshare = tracker.can_unshare
|
||||||
|
self._can_check_speed = tracker.can_check_speed
|
||||||
|
self._can_see_statistics = tracker.can_see_statistics
|
||||||
|
self._can_send_broken_down_signal = tracker.can_send_broken_down_signal
|
||||||
|
self._can_send_stolen_signal = tracker.can_send_stolen_signal
|
||||||
|
self._status = tracker.status
|
||||||
|
self._auto_lock_freezed_to = tracker.auto_lock_freezed_to
|
||||||
|
self._subscription_id = tracker.subscription_id
|
||||||
|
self._external_battery_voltage = tracker.external_battery_voltage
|
||||||
|
self._internal_battery_voltage = tracker.internal_battery_voltage
|
||||||
|
self._timezone = tracker.timezone
|
||||||
|
self._is_second_gen = tracker.is_second_gen
|
||||||
|
self._is_up_to_date = tracker.is_up_to_date
|
||||||
|
self._subscription = tracker.subscription
|
||||||
|
self._version = tracker.version
|
||||||
|
self._gift_card_expires = tracker.gift_card_expires
|
||||||
|
self._gift_card_months = tracker.gift_card_months
|
||||||
|
self._odometer_updated_at = tracker.odometer_updated_at
|
||||||
|
self._maintenance_mode_until = tracker.maintenance_mode_until
|
||||||
|
self._battery_updated_at = tracker.battery_updated_at
|
||||||
|
self._is_in_eco = tracker.is_in_eco
|
||||||
|
self._is_calibrated = tracker.is_calibrated
|
||||||
|
self._is_oldsubscription = tracker.is_oldsubscription
|
||||||
|
self._software_version = tracker.software_version
|
||||||
|
self._has_beacon = tracker.has_beacon
|
||||||
|
self._has_outdated_beacons = tracker.has_outdated_beacons
|
||||||
|
self._ecall_activated = tracker.ecall_activated
|
||||||
|
|
||||||
class GeorideAccount:
|
class GeoRideTrackerBeacon:
|
||||||
|
""" GeoRideTrackerBeacon representation """
|
||||||
|
def __init__(self, beacon_id, name, created_at, updated_at, mac_address,
|
||||||
|
battery_level, last_battery_level_update, sleep_delay,
|
||||||
|
is_updated, power):
|
||||||
|
self._beacon_id = beacon_id
|
||||||
|
self._name = name
|
||||||
|
self._created_at = created_at
|
||||||
|
self._updated_at = updated_at
|
||||||
|
self._mac_address = mac_address
|
||||||
|
self._battery_level = battery_level
|
||||||
|
self._last_battery_level_update = last_battery_level_update
|
||||||
|
self._sleep_delay = sleep_delay
|
||||||
|
self._is_updated = is_updated
|
||||||
|
self._power = power
|
||||||
|
@property
|
||||||
|
def beacon_id(self):
|
||||||
|
"""beacon_id property"""
|
||||||
|
return self._beacon_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
"""name property"""
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def created_at(self):
|
||||||
|
"""created_at property"""
|
||||||
|
return self._created_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updated_at(self):
|
||||||
|
"""updated_at property"""
|
||||||
|
return self._updated_at
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mac_address(self):
|
||||||
|
"""mac_address property"""
|
||||||
|
return self._mac_address
|
||||||
|
|
||||||
|
@property
|
||||||
|
def battery_level(self):
|
||||||
|
"""battery_level property"""
|
||||||
|
return self._battery_level
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_battery_level_update(self):
|
||||||
|
"""last_battery_level_update property"""
|
||||||
|
return self._last_battery_level_update
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sleep_delay(self):
|
||||||
|
"""sleep_delay property"""
|
||||||
|
return self._sleep_delay
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_updated(self):
|
||||||
|
"""is_updated property"""
|
||||||
|
return self._is_updated
|
||||||
|
|
||||||
|
@property
|
||||||
|
def power(self):
|
||||||
|
"""power property"""
|
||||||
|
return self._power
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideTrackerBeacon(
|
||||||
|
json['id'],
|
||||||
|
json['name'],
|
||||||
|
json['createdAt'],
|
||||||
|
json['updatedAt'],
|
||||||
|
json['macAddress'],
|
||||||
|
json['batteryLevel'],
|
||||||
|
json['lastBatteryLevelUpdate'],
|
||||||
|
json['sleepDelay'],
|
||||||
|
json['isUpdated'],
|
||||||
|
json['power'])
|
||||||
|
|
||||||
|
class GeoRideSubscription:
|
||||||
|
""" Account object representation """
|
||||||
|
def __init__(self, subscription_id, subscription_type, initial_date, next_payment_date,
|
||||||
|
status, paused_since, cancel_requested, price, first_name, last_name, card_information):
|
||||||
|
self._subscription_id = subscription_id
|
||||||
|
self._subscription_type = subscription_type
|
||||||
|
self._initial_date = initial_date
|
||||||
|
self._next_payment_date = next_payment_date
|
||||||
|
self._status = status
|
||||||
|
self._paused_since = paused_since
|
||||||
|
self._cancel_requested = cancel_requested
|
||||||
|
self._price = price
|
||||||
|
self._first_name = first_name
|
||||||
|
self._last_name = last_name
|
||||||
|
self._card_information = card_information
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription_id(self):
|
||||||
|
"""subscription_id property"""
|
||||||
|
return self._subscription_id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def subscription_type(self):
|
||||||
|
"""subscription_type property"""
|
||||||
|
return self._subscription_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def initial_date(self):
|
||||||
|
"""initial_date property"""
|
||||||
|
return self._initial_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def next_payment_date(self):
|
||||||
|
"""next_payment_date property"""
|
||||||
|
return self._next_payment_date
|
||||||
|
|
||||||
|
@property
|
||||||
|
def status(self):
|
||||||
|
"""status property"""
|
||||||
|
return self._status
|
||||||
|
|
||||||
|
@property
|
||||||
|
def paused_since(self):
|
||||||
|
"""paused_since property"""
|
||||||
|
return self._paused_since
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cancel_requested(self):
|
||||||
|
"""cancel_requested property"""
|
||||||
|
return self._cancel_requested
|
||||||
|
|
||||||
|
@property
|
||||||
|
def price(self):
|
||||||
|
"""price property"""
|
||||||
|
return self._price
|
||||||
|
|
||||||
|
@property
|
||||||
|
def first_name(self):
|
||||||
|
"""first_name property"""
|
||||||
|
return self._first_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def last_name(self):
|
||||||
|
"""last_name property"""
|
||||||
|
return self._last_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def card_information(self):
|
||||||
|
"""card_information property"""
|
||||||
|
return self._card_information
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideSubscription(
|
||||||
|
json['id'],
|
||||||
|
json['type'],
|
||||||
|
json['initialDate'],
|
||||||
|
json['nextPaymentDate'],
|
||||||
|
json['status'],
|
||||||
|
json['pausedSince'],
|
||||||
|
json['cancelRequested'],
|
||||||
|
json['price'],
|
||||||
|
json['firstName'],
|
||||||
|
json['lastName'],
|
||||||
|
GeoRideSubscription_CardInfo.from_json(json['cardInformation'])
|
||||||
|
)
|
||||||
|
|
||||||
|
class GeoRideSubscription_CardInfo:
|
||||||
|
""" Account object representation """
|
||||||
|
def __init__(self, last_digits, expiry, brand):
|
||||||
|
self._last_digits = last_digits
|
||||||
|
self._expiry = expiry
|
||||||
|
self._brand = brand
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_json(cls, json):
|
||||||
|
"""return new object from_json"""
|
||||||
|
return GeoRideSubscription_CardInfo(
|
||||||
|
json['lastDigits'],
|
||||||
|
json['expiry'],
|
||||||
|
json['brand']
|
||||||
|
)
|
||||||
|
|
||||||
|
class GeoRideAccount:
|
||||||
""" Account object representation """
|
""" Account object representation """
|
||||||
def __init__(self, account_id, email, is_admin, auth_token):
|
def __init__(self, account_id, email, is_admin, auth_token):
|
||||||
self._account_id = account_id
|
self._account_id = account_id
|
||||||
@@ -567,15 +971,14 @@ class GeorideAccount:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
"""return new object from_json"""
|
"""return new object from_json"""
|
||||||
return GeorideAccount(
|
return GeoRideAccount(
|
||||||
json['id'],
|
json['id'],
|
||||||
json['email'],
|
json['email'],
|
||||||
json['isAdmin'],
|
json['isAdmin'],
|
||||||
json['authToken']
|
json['authToken']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class GeoRideUser: # pylint: disable= R0902
|
||||||
class GeorideUser: # pylint: disable= R0902
|
|
||||||
""" User object representation """
|
""" User object representation """
|
||||||
def __init__(self, user_id, email, first_name, created_at, phone_number, # pylint: disable= R0913
|
def __init__(self, user_id, email, first_name, created_at, phone_number, # pylint: disable= R0913
|
||||||
push_user_token, legal, date_of_birth):
|
push_user_token, legal, date_of_birth):
|
||||||
@@ -631,7 +1034,7 @@ class GeorideUser: # pylint: disable= R0902
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
"""return new object fromjson"""
|
"""return new object fromjson"""
|
||||||
return GeorideUser(
|
return GeoRideUser(
|
||||||
json['id'],
|
json['id'],
|
||||||
json['email'],
|
json['email'],
|
||||||
json['firstName'],
|
json['firstName'],
|
||||||
@@ -641,3 +1044,95 @@ class GeorideUser: # pylint: disable= R0902
|
|||||||
json['legal'],
|
json['legal'],
|
||||||
json['dateOfBirth']
|
json['dateOfBirth']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#TODO: remove in v0.8.0
|
||||||
|
class GeorideSharedTrip(GeoRideSharedTrip):
|
||||||
|
""" Shared trip object representation """
|
||||||
|
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideSharedTrip is deprecated, modify %s to use GeoRideSharedTrip",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideSharedTrip is deprecated, modify your code to use GeoRideSharedTrip")
|
||||||
|
|
||||||
|
class GeorideTrackerTrip(GeoRideTrackerTrip):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTrackerTrip is deprecated, modify %s to use GeoRideTrackerTrip",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTrackerTrip is deprecated, modify your code to use GeoRideTrackerTrip")
|
||||||
|
|
||||||
|
class GeorideTrackerPosition(GeoRideTrackerPosition):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTrackerPosition is deprecated, modify %s to use GeoRideTrackerPosition",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTrackerPosition is deprecated, modify your code to use GeoRideTrackerPosition")
|
||||||
|
|
||||||
|
class GeorideTracker(GeoRideTracker):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideTracker is deprecated, modify %s to use GeoRideTracker",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideTracker is deprecated, modify your code to use GeoRideTracker")
|
||||||
|
|
||||||
|
|
||||||
|
class GeorideAccount(GeoRideAccount):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideAccount is deprecated, modify %s to use GeoRideAccount",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideAccount is deprecated, modify your code to use GeoRideAccount")
|
||||||
|
|
||||||
|
class GeorideUser(GeoRideUser):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideUser is deprecated, modify %s to use GeoRideUser",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideUser is deprecated, modify your code to use GeoRideUser")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
""" Georide socket-io implementation """
|
""" GeoRide socket-io implementation """
|
||||||
import logging
|
import logging
|
||||||
import socketio
|
import socketio
|
||||||
|
|
||||||
@@ -19,8 +19,8 @@ def on_disconnect():
|
|||||||
_LOGGER.debug('GeoRide socket disconnected')
|
_LOGGER.debug('GeoRide socket disconnected')
|
||||||
|
|
||||||
|
|
||||||
class GeorideSocket():
|
class GeoRideSocket():
|
||||||
"""docstring for GeorideSocket"""
|
"""docstring for GeoRideSocket"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._on_message_callback = None
|
self._on_message_callback = None
|
||||||
self._on_device_callback = None
|
self._on_device_callback = None
|
||||||
@@ -99,9 +99,6 @@ class GeorideSocket():
|
|||||||
_LOGGER.debug('Locked received: %s', data)
|
_LOGGER.debug('Locked received: %s', data)
|
||||||
if self._on_locked_callback is not None:
|
if self._on_locked_callback is not None:
|
||||||
self._on_locked_callback(data)
|
self._on_locked_callback(data)
|
||||||
else:
|
|
||||||
_LOGGER.debug('Lallback is none')
|
|
||||||
|
|
||||||
self._initialised = True
|
self._initialised = True
|
||||||
|
|
||||||
def connect(self, auth_token):
|
def connect(self, auth_token):
|
||||||
@@ -115,3 +112,19 @@ class GeorideSocket():
|
|||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
"""disconnect from the georide socket"""
|
"""disconnect from the georide socket"""
|
||||||
sio.disconnect()
|
sio.disconnect()
|
||||||
|
|
||||||
|
|
||||||
|
#TODO: remove in v0.8.0
|
||||||
|
class GeorideSocket(GeoRideSocket):
|
||||||
|
""" Trip object representation """
|
||||||
|
def __init_subclass__(cls, **kwargs):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init_subclass__(**kwargs)
|
||||||
|
_LOGGER.warning(
|
||||||
|
"GeorideSocket is deprecated, modify %s to use GeoRideSocket",
|
||||||
|
cls.__name__,
|
||||||
|
)
|
||||||
|
def __init__(self, *argv):
|
||||||
|
"""Print deprecation warning."""
|
||||||
|
super().__init__(*argv)
|
||||||
|
_LOGGER.warning("GeorideSocket is deprecated, modify your code to use GeoRideSocket")
|
||||||
@@ -17,6 +17,11 @@ handlers=consoleHandler
|
|||||||
qualname=simpleExample
|
qualname=simpleExample
|
||||||
propagate=0
|
propagate=0
|
||||||
|
|
||||||
|
[logger_engine_io]
|
||||||
|
level=ERROR
|
||||||
|
handlers=consoleHandler
|
||||||
|
qualname=engineio.client
|
||||||
|
propagate=0
|
||||||
|
|
||||||
[handler_consoleHandler]
|
[handler_consoleHandler]
|
||||||
class=StreamHandler
|
class=StreamHandler
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
description-file = README.md
|
description_file = README.md
|
||||||
12
setup.py
12
setup.py
@@ -19,16 +19,16 @@ CURRENT_DIR = os.path.dirname(__file__)
|
|||||||
setup(
|
setup(
|
||||||
name='georideapilib',
|
name='georideapilib',
|
||||||
packages=['georideapilib'], # this must be the same as the name above
|
packages=['georideapilib'], # this must be the same as the name above
|
||||||
version='0.4.1',
|
version='0.7.1',
|
||||||
description='Lib to control georide tracker devices with their rest api',
|
description='Lib to control GeoRide tracker devices with theire rest api',
|
||||||
author='Matthieu DUVAL',
|
author='Matthieu DUVAL',
|
||||||
author_email='georideapilib@duval-dev.fr',
|
author_email='georideapilib@duval-dev.fr',
|
||||||
# use the URL to the github repo
|
# use the URL to the github repo
|
||||||
url='https://github.com/ptimatth/pyGeoride',
|
url='https://github.com/hacf/georide-api',
|
||||||
download_url='https://codeload.github.com/ptimatth/pyGeoride/tar.gz/0.1.0',
|
download_url='https://codeload.github.com/hacf/georide-api/tar.gz/0.7.1',
|
||||||
keywords=['rest', 'georide', 'api', 'grutier'], # arbitrary keywords
|
keywords=['rest', 'georide', 'api', 'grutier', 'GeoRide'], # arbitrary keywords
|
||||||
classifiers=[],
|
classifiers=[],
|
||||||
install_requires=["python-socketio[client]"],
|
install_requires=["python-socketio[client]==4.6.1"],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
'pytest>=3.7',
|
'pytest>=3.7',
|
||||||
'pytest-pep8',
|
'pytest-pep8',
|
||||||
|
|||||||
Reference in New Issue
Block a user