birdie1 / victron

Victron bluetooth and serial communication at a python script. With MQTT and HomeAssistant support.
GNU General Public License v3.0
124 stars 16 forks source link

missing values "virtual load output" "state [bulk, float, absorption]" #26

Open pkoevesdi opened 1 year ago

pkoevesdi commented 1 year ago

Hey,

very fine project, meeting quite exactly my use case: getting my SmartSolar values via bluetooth and mqtt into the home assistant of my camper. Sadly, I'm missing these values: "virtual load output" and "state [bulk, float, absorption]". I'm not sure, why:

Since the official GATT-protocol ist officially not available for other devices than SmartShunt (or did I miss something?), I think, I'm connecting via reverse engineered VictronConnect-protocol? I use this in config.yml:

devices:
    - name: SmartSolar
      type: smartsolar
      protocol: bluetooth
      mac: ...

The advertisement protocol is no solution, since it doesn't contain the (for me important) virtual load output state - neither the App show this value in the preview values section, nor the spec includes it. Further more, the advertisment doesn't include the panel voltage and current, which I get here.

Thank You very much for hints how to get these values and how to contribute.

birdie1 commented 1 year ago

Hello, yes, these values are not reversed engineered. The reverse engineering is quite difficult and I am not really good at it.

If you want to try it: https://github.com/vvvrrooomm/victron did most of the research I am using for my code. In this repo there is wireshark prorocol dissector. We tried using the app and wireshark to find out which bluetooth hex value could be which. In my code you can set the loglevel to debug, than it should output all the data which it is not able to interprete. If you combine both, you may find more values. I am still looking for a way to get the history values from the smartsolar as well. The value are already reverse engineered, but it looks like I need to send something towards the smartsolar, that it will send the history back. This would be very interesting as well. I would be very happy if you find some more values :)

All values currently gathered are send to mqtt.

If you specify 'bluetooth' as protocol, it will use the reverse engineered procotol. bluetooth-ble is the gatt protocol, but you are right, it is only available on smartshunt.

Even if it does not help in your case, I will have a look at the advertisement protocol. Sounds nice to implement this as well.

pkoevesdi commented 1 year ago

Ok, thank You for the feedback. I'll try to figure out some stuff, but it can take a whole while, I'm very limited in time. Maybe next weekend. For using the advertisement data, I had quick success with this project: https://github.com/keshavdv/victron-ble Instead of querying the sqlite database, You can simply get the encryption key from the app under settings, product-info, at the bottom, see here: https://community.victronenergy.com/questions/187303/victron-bluetooth-advertising-protocol.html I'd suggest to keep this issue open, until we find these parameters.

birdie1 commented 1 year ago

Yes sure, we can leave it open.

Thanks for the links. I will add it probably beginning ob october to my code.

pkoevesdi commented 1 year ago

Ok, I took a look at it and found out almost everything that VictronConnect displays for my SmartSolar, including the load output. I'm not yet sure about the state and what to send to get the history. I posted my findings into victron.lua in https://github.com/vvvrrooomm/victron/pull/2

birdie1 commented 1 year ago

Nice, thanks for your work. I will add it to my code

pkoevesdi commented 1 year ago

So, now I found acutally almost all information, public since years: https://www.victronenergy.de/upload/documents/VE.Can-registers-public.pdf https://www.victronenergy.com/upload/documents/BlueSolar-HEX-protocol.pdf The only thing missing was all the time the bluetooth stuff around, but the payload - the VREGs are open. So, I'll stop putting all that into the wireshark lua. I found also the state I was missing, it is VREG 0x0201. Maybe You can look through for the command for getting the history? I'll see what I can do to implement the (for me) important stuff here...

robinsalyon commented 1 year ago

Thank you both, I'm interested in these parameters too (in json).

pkoevesdi commented 1 year ago

@birdie1, can You provide me with some starter's help how to implement new found values into Your source code? I'm a bit lost and don't know where to put them. I've documented a lot of stuff in the .lua in mentioned pull request, but I don't need it in wireshark, I need it in mqtt. ;-)

Thank You!