phev-remote / phevcore

MIT License
29 stars 11 forks source link

Java Port #9

Open ylexus opened 3 years ago

ylexus commented 3 years ago

I am willing to invest time in porting this brilliant library to java. Will benefit automations that are coded in java. I run my java based automation hub on raspberry pi and I have a personal interest in adding support for PHEV to my hub so that I can simplify preheating routine (cancel charge schedule, start aircon, stop aircon, re-enable charge schedule) as the native app is utterly rubbish. Projects like https://www.openhab.org can they use the java port to add connectors. I am an experienced java dev, but nearly zero in C. The library is simple enough though, so I don't think there will be major problems. I am sure I'll have some questions when I am stuck though, so if you are all interested at all, I'd appreciate some form of contact (email would be enough). If not - fair enough, I hope I can manage. I'll start in my own repo, and then maybe you could create a repo under phev-remote.

slikwerker commented 3 years ago

Nice idea, just bought an Outlander PHEV myself. I'm willing to help you. I'm an experienced Java developer. How can I help?

ylexus commented 3 years ago

@slikwerker great. I wanted to start with trying to connect ty my car using the existing phevctl command line utility that is based on this library. I failed to register it as a second device, so I reset my car's WiFi only to realise that I completely lost the original password (which has been updated by the dealership, so no record of it anywhere in the world except in my car). Dealerships are closed to non/essential activities in the UK, so I can't recover the password.

I wanted to start by ensuring the lib works with my car so you could do that too. Next step would be to try to understand existing code. I browsed it a little, but got stuck on understanding the API of the author's messaging library (msg-core) used by phev-core. Also failed to link this project to msg-core for convenient click-through in CLion. Lack of C ecosystem knowledge does not help. I guess you can try doing the same.

slikwerker commented 3 years ago

Hi, I don't have a WiFi code either, so I've planned a meeting with a local dealer (at the end of the week) to check the batteries and to obtain the WiFi code.

In the meantime I'll try figuring out how the current code works.

papawattu commented 3 years ago

Hi,

You can ignore most of the msg library, its just a way to abstract different messaging implementation. The messages to the code are just byte strings, and look at the phev-core tests for the best way to understand what is going on.

Happy to help with the port - I also know a bit of Java, but wrote it in C because of the code is meant to run on low memory devices such as the ESP32.

marvkis commented 3 years ago

Hi,

I just stumbled over this lib and this ticket. My goal is also to have my MY19 integrated into openhab, so I also jump in here. I already had some 'low-level' experiments back in early 2019, so I've learned it's quite complicated to get the communication with the car up and running. (I assume MY20 behave quite similar to MY19). From my expirience things will get complicated when we try to configure everything correctly in order to have OH talking directly with the car. I think it would be good to have some device connecting to the car's wifi and also to the 'Home'-Network. I'm currently thinking of something like a RPI with two wifi sticks working as bridge between the home / oh network and the car. We could use the C library and build up a communication layer on top of it to communicate with OH. Mybe just a small java app running on the RPI using JNI to integrate the lib.

I already had a RPI connecting to my car... but where is it now..? It's a good time to have it reactivated ;)

ylexus commented 3 years ago

Unfortunately, my motivation is on pause as I can't recover the car's WiFi password for now. Wrapper around this library is a quick hack, yes, but I wanted a proper port. My platform is also rpi. I am running my own Java based automation hub based on my http://GitHub.com/ylexus/jiotty library.

I'll be back when I recover the password. If someone else takes the initiative - I'll be happy to contribute later.

scooper1 commented 3 years ago

i hope you manage to get your key ok