For more details about this component, please refer to the documentation at
https://github.com/xraver/mercedes_me_api/
"""
-# Software Parameters
+# Software Name & Version
NAME = "Mercedes Me API"
DOMAIN = "mercedesmeapi"
-VERSION = "0.7"
+VERSION = "0.8"
+# Software Parameters
TOKEN_FILE = ".mercedesme_token"
-CREDENTIAL_FILE = ".mercedesme_credentials"
+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%20offline_access"
+SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access"
URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2"
# File Parameters
For more details about this component, please refer to the documentation at
https://github.com/xraver/mercedes_me_api/
"""
-# Software Parameters
+# Software Name & Version
NAME = "Mercedes Me API"
DOMAIN = "mercedesmeapi"
-VERSION = "0.7"
+VERSION = "0.8"
+# Software Parameters
TOKEN_FILE = ".mercedesme_token"
-CREDENTIAL_FILE = ".mercedesme_credentials"
+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%20offline_access"
+SCOPE = "mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20offline_access"
URL_RES_PREFIX = "https://api.mercedes-benz.com/vehicledata/v2"
#UPDATE_SIGNAL = "mercedesmeapi_update"
#!/bin/bash
# Author: G. Ravera
-# Version 0.4
+# Version 0.5
# Creation Date: 28/09/2020
#
# Change log:
# 18/10/2020 - 0.2 - Added the possibility to retrieve the list of resources available
# 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
# Script Name & Version
NAME="mercedes_me_api.sh"
-VERSION="0.4"
+VERSION="0.5"
+
+# Script Parameters
+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"
+URL_RES_PREFIX="https://api.mercedes-benz.com/vehicledata/v2"
+# Resources
+RES_FUEL=(rangeliquid tanklevelpercent)
+RES_LOCK=(doorlockstatusvehicle doorlockstatusdecklid doorlockstatusgas positionHeading)
+RES_STAT=(decklidstatus doorstatusfrontleft doorstatusfrontright doorstatusrearleft doorstatusrearright \
+ interiorLightsFront interiorLightsRear lightswitchposition readingLampFrontLeft readingLampFrontRight \
+ rooftopstatus sunroofstatus \
+ windowstatusfrontleft windowstatusfrontright windowstatusrearleft windowstatusrearright
+)
+RES_ELECTRIC=(soc rangeelectric)
# set "extended regular expression" argument for sed based on OS
if [ "X$(uname -s)" = "XDarwin" ]
SED_FLAG="-r"
fi
-# Static Parameters
-REDIRECT_URL="https://localhost"
-SCOPE="mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20offline_access"
-STATE="12345678"
-TOKEN_FILE=".mercedesme_token"
-CREDENTIALS_FILE=".mercedesme_credentials"
-
# Credentials
CLIENT_ID=""
CLIENT_SECRET=""
exit
fi
-# URL
-RES_URL="https://api.mercedes-benz.com/vehicledata/v2/vehicles/$VEHICLE_ID/resources"
-
-# Resources
-RES_FUEL=(rangeliquid tanklevelpercent)
-RES_LOCK=(doorlockstatusvehicle doorlockstatusdecklid doorlockstatusgas positionHeading)
-RES_STAT=(decklidstatus doorstatusfrontleft doorstatusfrontright doorstatusrearleft doorstatusrearright \
- interiorLightsFront interiorLightsRear lightswitchposition readingLampFrontLeft readingLampFrontRight \
- rooftopstatus sunroofstatus \
- windowstatusfrontleft windowstatusfrontright windowstatusrearleft windowstatusrearright
-)
+# Formatting RES_URL
+# Formatting RES_URL
+RES_URL="$URL_RES_PREFIX/vehicles/$VEHICLE_ID/resources"
function usage ()
{
echo " or: $NAME -l"
echo
echo "Arguments:"
- echo " -t, --token Procedure to obtatin the Access Token (stored into $TOKEN_FILE)"
- echo " -r, --refresh Procedure to refresh the Access Token (stored into $TOKEN_FILE)"
- echo " -f, --fuel Retrieve the Fuel Status of your Vehicle"
- echo " -l, --lock Retrieve the Lock Status of your Vehicle"
- echo " -s, --status Retrieve the General Status of your Vehicle"
- echo " -R, --resources Retrieve the list of available resources of your Vehicle"
+ echo " -t, --token Procedure to obtatin the Access Token (stored into $TOKEN_FILE)"
+ echo " -r, --refresh Procedure to refresh the Access Token (stored into $TOKEN_FILE)"
+ echo " -f, --fuel Retrieve the Fuel Status of your Vehicle"
+ 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 " -R, --resources Retrieve the list of available resources of your Vehicle"
exit
}
function parse_options ()
{
# Check Options
- OPT=$(getopt -o trflsR --long token,refresh,fuel,lock,status,resources -n "$NAME parse-error" -- "$@")
+ OPT=$(getopt -o trflseR --long token,refresh,fuel,lock,status,electric-status,resources -n "$NAME parse-error" -- "$@")
if [ $? != 0 ] || [ $# -eq 0 ]; then
usage
fi
printStatus "${RES_STAT[@]}"
shift
;;
+ -e | --electric-status )
+ printStatus "${RES_ELECTRIC[@]}"
+ shift
+ ;;
-R | --resources )
printResources
shift