tillsteinbach / WeConnect-python

Python API for the Volkswagen WeConnect Services
MIT License
112 stars 31 forks source link

HomeAssistant support #34

Closed woutercoppens closed 2 years ago

woutercoppens commented 2 years ago

Hi Till,

First of all: thanks a lot for your work on this great repository. It looks very promising.

I started working on an integration with HomeAssistant based on WeConnect-mqtt. It works great but I'm facing some issues: the message contains the VIN. So the sensors look like: ` sensor:

The second approach I'm thinking about is to write a custom integration based on WeConnect-python: I did some quick testing but I could not find a method that dumps all domains and their values in one big list. (Unless I looked over it.) A big dictionary that looks something like this: [ "weconnect/0/vehicles/MYVIN/nickname": "Daddy's car", "weconnect/0/vehicles/MYVIN/model": "ID4", .... ] Is this available?

tillsteinbach commented 2 years ago

Hey! Regarding the first question: Your request would be that the path should not contain the VIN but something like: /0/ ... /1/ and so on? Regarding the second question: It is a tree but something like this could work:

import argparse
from weconnect import weconnect

def main():
    """ Simple example showing how to retrieve all vehciles from the account """
    parser = argparse.ArgumentParser(
        prog='allVehciles',
        description='Example retrieving all vehciles in the account')
    parser.add_argument('-u', '--username', help='Username of Volkswagen id', required=True)
    parser.add_argument('-p', '--password', help='Password of Volkswagen id', required=True)

    args = parser.parse_args()

    print('#  Initialize WeConnect')
    weConnect = weconnect.WeConnect(username=args.username, password=args.password, updateAfterLogin=False, loginOnInit=False)
    print('#  Login')
    weConnect.login()
    print('#  update')
    weConnect.update()
    print('#  print results')
    allAttributes = {}
    for child in weConnect.getLeafChildren():
        allAttributes[child.getGlobalAddress()] = str(child)
    print(allAttributes)

if __name__ == '__main__':
    main()

Just one more information that might change your plans. There is the user @mitch-dc who works on a home-assistance interface using WeConnect-python: https://github.com/mitch-dc/volkswagen_we_connect_id so maybe it is worth spending effort contributing to this project instead of starting a new one. If you still wan't to do your own project, it is of course also good, but I though it is maybe an information you are missing.

woutercoppens commented 2 years ago

Hi Till,

For the moment, you may park my request about the mqtt integration ;-)

I'll reach out to mitch to see if I can assist. It would be stupid to to create 2 plugins.

tillsteinbach commented 2 years ago

If you don’t mind I close this for now to keep the overview. If it becomes relevant again, please re-open it.