vwt12eh8 / hassio-ecoflow

EcoFlow Portable Power Station Integration for Home Assistant
MIT License
250 stars 39 forks source link

BMS data #11

Closed joejeff123 closed 2 years ago

joejeff123 commented 2 years ago

This is not an issue but rather a question:

How exactly does the code fetch the BMS and other data (MMPT and INV)? I cannot find this out by checking the source code. request is only called to get get_serial_main and get_dc_in_current.

mattwells commented 2 years ago

I'm still working out how this works myself but it appears that the listening happens in custom_components/ecoflow/ecoflow/rxtcp.py. This class creates a TCP connection to the battery which will then send packets of data about is happening. This binary stream is then converted to something that Home Assistant can use in custom_components/ecoflow/ecoflow/receive.py if you take a look around line 165 you can see where it is converting the binary.

I'm sure someone else can give you better information that I can but it might help you get started.

I get the impression that you are trying to make your own listener and if that is the case something to consider is that Ecoflow have an MQTT server that they host and it is possible to subscribe to that where it send JSON. I was involved in some discussion about it in this ticket in another repo https://github.com/v1ckxy/ecoflow-withoutflow/issues/1#issuecomment-1129501342 However using the solution that vwt12eh8 is made is a much nicer solution as it doesn't require an internet connection or Ecoflow's own services.

joejeff123 commented 2 years ago

This is all clear. I can get the PD, EMS, MPPT data via port 8055, but I don't find the code where it queries BMS data. If you check HassioEcoFlowClient you can see that it setups filters for BMS. But HassioEcoFlowClient never sends any commands to port 8055, so I wonder how does it enable that Ecoflow starts sending status data including the BMS.

joejeff123 commented 2 years ago

I also checked it doesn't use a different port for querying status data, HassioEcoFlowClient uses port 8055.

joejeff123 commented 2 years ago

I think I figured it:

def get_bms(): return build2(3, 32, 50)

Would get back the BMS data, but my Ecoflow Delta Pro doesn't reply anything if I send this. PD, EMS etc work.

vwt12eh8 commented 2 years ago

As far as I can tell, the BMS data is pushed at regular intervals. However, you need to be aware that it is sent at the same time as other messages.

When a push is performed, multiple messages may be sent in succession. If there is "0xAA,0x02" as a header, it can be regarded as the beginning of data, but since multiple data may be included in one reception, processing to search the header is required. Since BMS is almost always sent together with other messages, it is necessary to take measures against continuous sending.

Note that get_bms() works for the RIVER series, but not for the DELTA series.

Sorry I can not explain well.

joejeff123 commented 2 years ago

Thanks, actually after a I connected Ecoflow Delta Pro with the latest Mobile App it started to send data via port 8055 automatically. Before it never did.

So the answer to my question is that Ecoflow sends data by default on port 8055.