custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.86k stars 239 forks source link

[New Sensor]: Victron Bluetooth Solar Charger / LifePO4 Shunt / BMS / Inverter /... #1217

Open bentolor opened 11 months ago

bentolor commented 11 months ago

Sensor Description

Victron Energy Bluetooth enabled product line

Additional information

About Victron / sensor family

Victron Energy is a manufacturer of high quality solar charger, solar inverters/converters and battery management products. In my case I have a "SmartSolar MPPT 100/30" solar charge controller. Typically these devices can be controlled/monitored by the Android/iOS app from the vendor and a six-digit PIN.

Vendor opening it's bluetooth protocol

As described in this blog post they recently decided to open their Bluetooth advertisement based protocol. They call this "instant readout". Users need to specifically enable this.

In the case of my SmartSolar charger, the advertisment data renders in the app as follows: grafik

Supported devices

The Victron devices supporting "Instant readout" are listed here.

Bluetooth Advertisment specification

The blog-post provides an 8-page long specification covering the following 14 device classes in total (see below). So I assume really simple. Most tricky part I assume is the AES-based encryption with the PIN and an additional nonce :-(

For my solar charger (besides the encryption) the spec describes: grafik

Other devices covered are:

https://community.victronenergy.com/storage/attachments/48745-extra-manufacturer-data-2022-12-14.pdf

BLE advertisements

---===### The PIN used for the extract below is 123456 ! ###===---

2023-07-29 16:28:20.370 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.ble_monitor
2023-07-29 16:29:18.160 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01\xe77\xc2.\x97\x9d\xbf\xd2\xd2Q7\xe5*\xa2\x12']local name: UUID16: None,UUID128: None
2023-07-29 16:29:57.784 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01\x0f8\xc2\x11a \x96\x1f\xd2\x95\xd3\xc0\xed(\xf0']local name: UUID16: None,UUID128: None
2023-07-29 16:34:27.712 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01\x1d9\xc2\x93p;4\xd3\xa9\xca\xeb6_@\xca']local name: UUID16: None,UUID128: None
2023-07-29 16:34:45.950 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01/9\xc2\xe9\xeb\xc2\xce\x7fKT"^\x94\xaf\x14']local name: UUID16: None,UUID128: None
2023-07-29 16:35:00.147 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01=9\xc2 &|s\t\x8f\xba\xc5\n\xea\xfdv']local name: UUID16: None,UUID128: None
2023-07-29 16:35:17.015 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01N9\xc202\xf4\x16)\xd3{\x9f^MN\xd6']local name: UUID16: None,UUID128: None
2023-07-29 16:35:25.813 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b"\x17\xff\xe1\x02\x10\x02V\xa0\x01W9\xc2\xca*\xdd{LtD\x05'm\xb8\xca"]local name: UUID16: None,UUID128: None
2023-07-29 16:35:43.621 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01h9\xc2\x11>\xd1D\xd0\x11\xe28\x9e\xac\xa1\xa7']local name: UUID16: None,UUID128: None
2023-07-29 16:37:07.247 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01\xbc9\xc2\xe5\x829\x91\xc0m\xbb`\xb4\xf2\x02\x97']local name: UUID16: None,UUID128: None
2023-07-29 16:37:39.485 INFO (Thread-5) [custom_components.ble_monitor.ble_parser] BLE advertisement received from MAC/UUID e774bb073082: service data: []manufacturer specific data: [b'\x17\xff\xe1\x02\x10\x02V\xa0\x01\xdc9\xc2\xa7\\|\x9e\x0bFF}$`l\x83']local name: UUID16: None,UUID128: None
bentolor commented 11 months ago

Python noob, but happy to give it a try on my own with a few pointers. Purely from paper it really sounds easy.

I stumbled over the values for VE_REG_DEVICE_STATE but found i.e. this code extract describing values & states as well as the codes for VE_REG_CHR_ERROR_CODE

bentolor commented 11 months ago

Update: I just realized the links lead to an existing ESPHome implementation.

Wow – dang that was easy. So my personal challenge has been already solved as part of my journey to collect the data for this issue. Please feel free to close / proceed with this request according to your likings.

samster395 commented 6 months ago

Update: I just realized the links lead to an existing ESPHome implementation.

Wow – dang that was easy. So my personal challenge has been already solved as part of my journey to collect the data for this issue. Please feel free to close / proceed with this request according to your likings.

I assume the ESPHome implementation you mentioned is this one?

So it is my understanding that all that needs to be done is a parser written for this component and the ESPHome component could help in this?

Some help in this would be much appreciated as it's kinda beyond my knowledge.

I have the ESPHome implementation working but seems silly to use another device when home assistant can do it itself.

Maybe this could also help? It's supposed to be a hacs component that does what we want but it currently doesn't work, so maybe the ESPHome one should be referenced instead.

bentolor commented 6 months ago

@samster395 I was not aware about keshavdv/victron-hacs. This should mostly already do the job also for you, no?

I think the only benefit left having this natively in home assistant is, that I'd expect bluetooth-proxy support then. According to my understanding otherwise you'd either need a dedicated ESPHome device or the Home Assistant bluetooth receiver in direct proximity of the Victron appliance instead of having just a few bluetooth-proxy devices spread across the area.

samster395 commented 6 months ago

@samster395 I was not aware about keshavdv/victron-hacs. This should mostly already do the job also for you, no?

I think the only benefit left having this natively in home assistant is, that I'd expect bluetooth-proxy support then. According to my understanding otherwise you'd either need a dedicated ESPHome device or the Home Assistant bluetooth receiver in direct proximity of the Victron appliance instead of having just a few bluetooth-proxy devices spread across the area.

It doesn't work unfortunately, I already tried it, maybe it did at some point but I could not get it to work.

This is my reason for wanting it supported by this component because right now I need to have a dedicated ESPHome device running right next to my raspberry pi running HA just to pull the data in.