Closed woutercoppens closed 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.
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.
If you don’t mind I close this for now to keep the overview. If it becomes relevant again, please re-open it.
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:
platform: mqtt name: PREFIX_display_name state_topic: "weconnect/0/vehicles/MYVIN/nickname" icon: mdi:car
platform: mqtt name: PREFIX_display_model state_topic: "weconnect/0/vehicles/MYVIN/model" icon: mdi:car-connected ` It is not possible to work with a variable in the name of the sensor or in the state_topic. So you'll have to replace MYVIN with your real VIN. The PREFIX should only be used it you have more than 1 car in WeConnect, because each sensor should have a unique name. In case of a second car, you have to copy/paste all sensors and replace MYVIN and PREFIX with the other values. This works for now but I'm looking for something more dynamically and automatically.
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?