xraver / mercedes_me_api

Script to use Mercedes Me APIs.
MIT License
57 stars 14 forks source link

HACS installation tested and aprooved? #25

Closed andilge closed 3 years ago

andilge commented 3 years ago

Is it only me or generally HACS installation won't integrate mercedes_me_api successfully?

townsmcp commented 3 years ago

Same here. I thought it might be due to the url setting in Mercedes website when setting up the oauth but when I run the scripts from my laptop to authorise the token generation the web page goes blank

xraver commented 3 years ago

Hi, it's necessary to create the first token by using python script. then you get a blank page in the url you will find a code something like https://localhost/?code=Byw8SGgHgrbSv9an9NQCmHtvxhjS6uYRY4XFT4FM

you have to copy the code and paste in the script. after that you will be able to use integration. sorry for this...

Il giorno ven 8 gen 2021 alle ore 15:11 townsmcp notifications@github.com ha scritto:

Same here. I thought it might be due to the url setting in Mercedes website when setting up the oauth but when I run the scripts from my laptop to authorise the token generation the web page goes blank

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xraver/mercedes_me_api/issues/25#issuecomment-756774523, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJM7A76ODLIOWEXTDMO3KTSY4G7LANCNFSM4V2PLRCQ .

townsmcp commented 3 years ago

@xraver when I run the python script, I get the message saying to open a browser window and insert the following link (I've removed my client_id):

https://id.mercedes-benz.com/as/authorization.oauth2?response_type=code&client_id=XXX-XXX-XXX-XXX-XXX&redirect_uri=https://localhost&scope=mb:vehicle:mbdata:fuelstatus%20mb:vehicle:mbdata:vehiclestatus%20mb:vehicle:mbdata:vehiclelock%20mb:vehicle:mbdata:evstatus%20mb:vehicle:mbdata:payasyoudrive%20offline_access

However when I copy paste this to a browse window the page doesn't load and I get the following address:

https://localhost/?error_description=The+requested+scope+is+invalid%2C+unknown%2C+malformed%2C+or+exceeds+that+which+the+client+is+permitted+to+request.&error=invalid_scope#

And the content of the token file shows:

{"error_description":"Authorization code is malformed.","error":"invalid_grant"}
Evilfraggle commented 3 years ago

Same here, but I get in the browser a "ERR_CONNECTION_REFUSED" Message

xraver commented 3 years ago

Hi, seems that the requested scope is invalid... try to exit from the mercedes me session, use the link again and provide credentials. the first time systems will require to accept the APIs. then when you will be redirected to the url just copy in the script only the code. i've tried again and it works for me....

Il giorno ven 8 gen 2021 alle ore 17:19 Evilfraggle < notifications@github.com> ha scritto:

Same here, but I get in the browser a "ERR_CONNECTION_REFUSED" Message

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xraver/mercedes_me_api/issues/25#issuecomment-756847985, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJM7A7G6W24GZYUYSVVK4TSY4WA5ANCNFSM4V2PLRCQ .

Evilfraggle commented 3 years ago

Hi, seems that the requested scope is invalid... try to exit from the mercedes me session, use the link again and provide credentials. the first time systems will require to accept the APIs. then when you will be redirected to the url just copy in the script only the code. i've tried again and it works for me.... Il giorno ven 8 gen 2021 alle ore 17:19 Evilfraggle < notifications@github.com> ha scritto: Same here, but I get in the browser a "ERR_CONNECTION_REFUSED" Message — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#25 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJM7A7G6W24GZYUYSVVK4TSY4WA5ANCNFSM4V2PLRCQ .

Thanks for the respond. My fault was not to register ALL APIs, but just some of them. Now it works 👍

townsmcp commented 3 years ago

@Evilfraggle same here for me too!!! I don't have the insurance so didn't register for that API. Register for it and the registration works for me

townsmcp commented 3 years ago

hmmmm not so sure about this. I have tried 0.9, 0.10 (with 'enable_resources_file: False and 'enable_resources_file: True', 'scan_interval: 120' and leaving scan_interval out of configuration.yaml) in HACS all to no avail. When I use the .sh or .py script I get the following:

James@James-MacBook-Pro mercedes_me_api-master % ./mercedes_me_api.sh -s
mercedes_me_api.sh - 0.6

Retrieving decklidstatus:

Retrieving doorstatusfrontleft:

Retrieving doorstatusfrontright:

Retrieving doorstatusrearleft:

Retrieving doorstatusrearright:

Retrieving interiorLightsFront:

Retrieving interiorLightsRear:

Retrieving lightswitchposition:

Retrieving readingLampFrontLeft:

Retrieving readingLampFrontRight:

Retrieving rooftopstatus:

Retrieving sunroofstatus:

Retrieving windowstatusfrontleft:

Retrieving windowstatusfrontright:

Retrieving windowstatusrearleft:

Retrieving windowstatusrearright:

No data is returned by the script :( same for the entities in HA - status is unknown even after reboots

xraver commented 3 years ago

When you have no data there are several options: 1) your car does not support the service requested 2) you have to refresh from your car the sensor (e.g. power on car, open doors, lights, windows, etc) and retry 3) some issue with Mercedes API: in my case I cannot see information from fuel :(

Il giorno sab 9 gen 2021 alle 00:36 townsmcp notifications@github.com ha scritto:

hmmmm not so sure about this. I have tried 0.9, 0.10 (with 'enable_resources_file: False and 'enable_resources_file: True', 'scan_interval: 120' and leaving scan_interval out of configuration.yaml) all to no avail. When I use the .sh or .py script I get the following:

James@James-MacBook-Pro mercedes_me_api-master % ./mercedes_me_api.sh -s mercedes_me_api.sh - 0.6

Retrieving decklidstatus:

Retrieving doorstatusfrontleft:

Retrieving doorstatusfrontright:

Retrieving doorstatusrearleft:

Retrieving doorstatusrearright:

Retrieving interiorLightsFront:

Retrieving interiorLightsRear:

Retrieving lightswitchposition:

Retrieving readingLampFrontLeft:

Retrieving readingLampFrontRight:

Retrieving rooftopstatus:

Retrieving sunroofstatus:

Retrieving windowstatusfrontleft:

Retrieving windowstatusfrontright:

Retrieving windowstatusrearleft:

Retrieving windowstatusrearright:

No data is returned :(

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/xraver/mercedes_me_api/issues/25#issuecomment-757048965, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJM7A6K3JVOVSHWZRPKSRDSY6JINANCNFSM4V2PLRCQ .

andilge commented 3 years ago

I've cloned the repo on my Ubuntu computer and have been able to create the .mercedesme_token file with success, content looks fine.

Where exactly should I place the token file now, in homeassistant/custom_components/mercedesmeapi ?

After this, will I need to add the integration in Home Assistant as well?

danielrheinbay commented 3 years ago

The token file needs to be placed in your homeassistant config folder. It's the same folder where you place your Home Assistant's configuration.yaml.

Speaking of which, yes, you need to enable the integration by adding its configuration to your configuration.yaml as described in the README.

andilge commented 3 years ago

figured out the config folder and yes, configuration.yaml is filled as well. No i have errors about the resource files.

Logger: custom_components.mercedesmeapi.resources
Source: custom_components/mercedesmeapi/resources.py:159
Integration: mercedesmeapi (documentation, issues)
First occurred: 23:36:04 (1 occurrences)
Last logged: 23:36:04
Error retrieving available resources - Generic Error (504)
andilge commented 3 years ago

changing enable_resources_file from true to false didn't make things get better.

here my configuration:

mercedesmeapi:
  client_id: !secret mercedesapi_client_id
  client_secret: !secret mercedesapi_client_secret
  vehicle_id: abcd1234
  enable_resources_file: false
  scan_interval: 120
andilge commented 3 years ago

continuing this in Integration failed to initialize #28

andilge commented 3 years ago

HACS installation working