magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

Add support for Vehicles and Vehicle Status (battery level, charging state, etc.) #57

Closed kennethroe closed 7 months ago

kennethroe commented 7 months ago

Adds Vehicle and Vehicle Status support to the API - allowing you to get the charge state of EVs configured in the Emporia account.

magico13 commented 7 months ago

Seems good to me with one possible problem, at least for me with my Model 3 when the car is asleep the call wakes it up and that can take longer than the default 10 second timeout. Might be worth mentioning in the readme at least and we might want to extend the timeout for that request, which it's not exactly set up for at the moment.

I do wonder if it's really appropriate to proxy through Emporia's servers for this though. Smartcar has a free option for individual developers so it might be better to just go directly at that API instead, which would also enable additional features that Smartcar supports but that Emporia doesn't surface.

kennethroe commented 7 months ago

Added a note to readme indicating that it may wake the vehicle and that 10 second timeout is in play.

Direct to Smartcar would be great, but would require a separate app to be installed on user's mobile device to onboard the user to the app, concurrently registering the user with Smartcar under the app owner's account (and billing all calls to that app owner/Smartcar customer's account).

Since monitoring vehicle status is a feature of the Emporia platform, and Emporia user will already be onboarded and have their vehicles configured, seemed like a reasonable path.

Repsect your vision on whether it fits or not as this is your project, but it's certainly useful to me and likely others.

magico13 commented 7 months ago

I will merge this since it is functionality in their app that people may want to call via code. I'm hesitant to add vehicle monitoring to Home Assistant through this though, at least at this time, so I don't think I'm going to prioritize that at the moment. If that is added I would likely do so via a sensor that is disabled by default and some thought would need to go into determining an appropriate polling rate.

kennethroe commented 7 months ago

Agree on HA integration - the call is heavy and thought on how often you want to call is necessary.

Currently integrated into my HA instance using a command line sensor that calls a python script that handles auth and specifies vehicle to call get_vehicle_status for. Sensor has been staying up to date. This path seems viable while forcing the appropriate level of thought, and testing on their specific vehicle, for those that chose to integrate it.