anton-ptashnik / ecoflow-api-py

Python library for communicating with Ecoflow power stations over BLE
MIT License
12 stars 0 forks source link

[Delta 2] Noisy Remaining time estimates #3

Open taras-sereda opened 4 months ago

taras-sereda commented 4 months ago

Hi and thanks for this tiny lib!

I'm interested at the moment in the REMAINING_TIME attribute only and observed very noisy estimates for that value. Could it be a bug?

Another question, can you elaborate more on how parsing of the packets work? Is there any specification I can consult?

Here is a code I'm running:

import asyncio
import bleak
from ecoflow import Delta2

async def main():
    mac = "00:00:00:00:00:00"
    ble_client = bleak.BleakClient(mac, timeout=15)
    async with Delta2(ble_client) as dev:

        await dev.start_state_stream(print_state)
        await asyncio.sleep(40)
        await dev.stop_state_stream()

async def print_state(data):
    print("state update...")
    for k, v in data.items():
        print(f"{k} = {v}")
    print("-"*20)

asyncio.run(main())

The output is as bellow:

skipped a data page 69
state update...
StateField.CHARGE_TH_MIN = 0
StateField.CHARGE_TH_MAX = 100
StateField.REMAINING_TIME = Time(hrs=98, mins=59)
--------------------
skipped a data page 123
state update...
--------------------
state update...
StateField.CHARGE_SPEED = 1200
--------------------
skipped a data page 70
state update...
--------------------
skipped a data page 123
state update...
--------------------
skipped a data page 69
state update...
StateField.CHARGE_TH_MIN = 52
StateField.CHARGE_TH_MAX = 80
StateField.REMAINING_TIME = Time(hrs=149, mins=27)
--------------------
skipped a data page 123
state update...
--------------------
skipped a data page 70
skipped a data page 123
state update...
--------------------
state update...
StateField.CHARGE_SPEED = 1200
--------------------
skipped a data page 69
state update...
StateField.CHARGE_TH_MIN = 89
StateField.CHARGE_TH_MAX = 61
StateField.REMAINING_TIME = Time(hrs=334, mins=34)
anton-ptashnik commented 4 months ago

Hi @taras-sereda , Unfortunately there is no BLE API documented for the device, or at least, I'm not aware of any in open access. Initially I sniffed a couple of requests between Delta 2 and a mobile app which were most stable but now it can be out of date.

Packet structure seems to change from time to time so looking at your logs it seems that some of data items shifted to another place in packet, on instance even these below. MAX definitely should be > MIN but it is not.

StateField.CHARGE_TH_MIN = 89
StateField.CHARGE_TH_MAX = 61

Moreover in recent firmware updates the way of communication establishment was changed so currently I cannot execute any command for my Delta 2 and I do not know an easy way of figuring out how to establish connection.

taras-sereda commented 4 months ago

Hi @anton-ptashnik, thank you for the reply,

Looks like there is no easy way to talk to the power station :( It's what it's, thank you for sharing the details.