]> git.giorgioravera.it Git - mercedes_me_api.git/commitdiff
Add PayAsYouDrive API
authorDaniel Rheinbay <danielrheinbay@gmail.com>
Wed, 23 Dec 2020 23:04:11 +0000 (00:04 +0100)
committerDaniel Rheinbay <danielrheinbay@gmail.com>
Wed, 23 Dec 2020 23:04:11 +0000 (00:04 +0100)
Add support for PayAsYouDrive API to get odometer readings.

const.py
custom_components/mercedesmeapi/const.py
mercedes_me_api.sh

index 5c9902b45558958ac3b825ccbf6319f5152a7d1f..e03ee930b926e73909ce40f4a5e6bb59ea8944d9 100644 (file)
--- a/const.py
+++ b/const.py
@@ -16,7 +16,7 @@ CREDENTIALS_FILE = ".mercedesme_credentials"
 RESOURCES_FILE = ".mercedesme_resources"
 # Mercedes me Application Parameters
 REDIRECT_URL = "https://localhost"
-SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access"
+SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access"
 URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2"
 
 # File Parameters
index ddfb2cfe2c181af42c227e993a66cbb245b728f0..c937c2d7346b63d9c4b9352d4432bde24a718d2f 100644 (file)
@@ -16,7 +16,7 @@ CREDENTIALS_FILE = ".mercedesme_credentials"
 RESOURCES_FILE = ".mercedesme_resources"
 # Mercedes me Application Parameters
 REDIRECT_URL = "https://localhost"
-SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access"
+SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access"
 URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2"
 #UPDATE_SIGNAL = "mercedesmeapi_update"
 
index cfa7dfeb5e0cc2630754c08eeceb6e3a0431a3eb..e9e0d9bdcf19480614b443a2987b72fb3d6371a5 100755 (executable)
@@ -10,6 +10,7 @@
 #             03/12/2020 - 0.3 - Fix in resources list
 #             18/12/2020 - 0.4 - Added macOS support (robert@klep.name)
 #             19/12/2020 - 0.5 - Added Electric Vehicle Status support
+#             23/12/2020 - 0.6 - Added PayAsYouDrive support (danielrheinbay@gmail.com)
 
 # Script Name & Version
 NAME="mercedes_me_api.sh"
@@ -20,7 +21,7 @@ TOKEN_FILE=".mercedesme_token"
 CREDENTIALS_FILE=".mercedesme_credentials"
 # Mercedes me Application Parameters
 REDIRECT_URL="https://localhost"
-SCOPE="mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access"
+SCOPE="mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access"
 URL_RES_PREFIX="https://api.mercedes-benz.com/vehicledata/v2"
 # Resources
 RES_FUEL=(rangeliquid tanklevelpercent)
@@ -31,6 +32,7 @@ RES_STAT=(decklidstatus doorstatusfrontleft doorstatusfrontright doorstatusrearl
           windowstatusfrontleft windowstatusfrontright windowstatusrearleft windowstatusrearright
 )
 RES_ELECTRIC=(soc rangeelectric)
+RES_ODO=(odo)
 
 # set "extended regular expression" argument for sed based on OS
 if [ "X$(uname -s)" = "XDarwin" ]
@@ -53,7 +55,6 @@ if [ -z $CLIENT_ID ] | [ -z $CLIENT_ID ] | [ -z $CLIENT_ID ]; then
   exit
 fi
 
-# Formatting RES_URL
 # Formatting RES_URL
 RES_URL="$URL_RES_PREFIX/vehicles/$VEHICLE_ID/resources"
 
@@ -71,6 +72,7 @@ function usage ()
   echo "    -l, --lock            Retrieve the Lock Status of your Vehicle"
   echo "    -s, --status          Retrieve the General Status of your Vehicle"
   echo "    -e, --electric-status Retrieve the General Electric Status of your Vehicle"
+  echo "    -o, --odometer        Retrieve the Odometer reading of your Vehicle"
   echo "    -R, --resources       Retrieve the list of available resources of your Vehicle"
   exit
 }
@@ -78,7 +80,7 @@ function usage ()
 function parse_options ()
 {
        # Check Options
-       OPT=$(getopt -o trflseR --long token,refresh,fuel,lock,status,electric-status,resources -n "$NAME parse-error" -- "$@")
+       OPT=$(getopt -o trflseoR --long token,refresh,fuel,lock,status,electric-status,odometer,resources -n "$NAME parse-error" -- "$@")
        if [ $? != 0 ] || [ $# -eq 0 ]; then
                usage
        fi
@@ -112,6 +114,10 @@ function parse_options ()
                                printStatus "${RES_ELECTRIC[@]}"
                                shift
                                ;;
+                       -o | --odometer )
+                               printStatus "${RES_ODO[@]}"
+                               shift
+                               ;;
                        -R | --resources )
                                printResources
                                shift