mariolukas / Bluetti_ESP32_Bridge

Bluetti Power Station ESP32 Bluetooth to MQTT Bridge
GNU General Public License v3.0
89 stars 31 forks source link

one poll command, including ac/dc status #43

Closed dpleiss closed 1 year ago

dpleiss commented 1 year ago

currently, the first poll command already reads all data submitted to MQTT server increasing the requested length by 2 adds the status of ac/dc switches to the data submitted to MQTT server

dpleiss commented 1 year ago
Bildschirm­foto 2023-02-04 um 13 46 18
giovanne123 commented 1 year ago

Great, thanks. Working for me too :-)

AlexBurghardt commented 1 year ago

Well, this solution keeps the issue in PayloadParser. The ac/dc status is already in the originally requested page 0x00.

dpleiss commented 1 year ago

The original length request of 0x28 does not request the ac/dc status. It is only requested (and part of the response) with a length value of 0x2A. I guess (but did not try) that holds true even with your, AlexBurghardt, changes to PayloadParser. Also, the other two requests don't make sense to me, at least for EB3A; with or without the changes to PayloadParser. I don't see a conflict here.

AlexBurghardt commented 1 year ago

I may mix something up here, I will have to check back. If I remember correctly (off which I am not 100% sure), adding a small offset to two of the original field filter checks in PayloadParser led to first success with ac/dc status (still with two page 0x00 requests ) but once I changed the page page length of the second request I saw that the filter field check made more problems, so I reworked it to be equal to the calculations below because this part was working properly.

dpleiss commented 1 year ago

I no longer have my notes at hand with me trying to understand the parsing. So, I'm not sure if there is a bug in the PayloadParser and if the ac/dc information is already there when requesting a length of 0x28. What I'm sure about is that with the original PayloadParser code, changing the request from 0x28 to 0x2a made the ac/dc information appear in the PayloadParser and ultimately at the MQTT end.

dpleiss commented 1 year ago

well, if you do get the ac/dc switch status information from the 0x28 request, then yours is right and mine is wrong.

AlexBurghardt commented 1 year ago

I just tested it with the original:

static device_field_data_t bluetti_polling_command[] = { {FIELD_UNDEFINED, 0x00, 0x0A, 0x28 ,0 , 0, TYPE_UNDEFINED}, {FIELD_UNDEFINED, 0x00, 0x46, 0x15 ,0 , 0, TYPE_UNDEFINED}, {FIELD_UNDEFINED, 0x0B, 0xB9, 0x3D ,0 , 0, TYPE_UNDEFINED} };

and I get the ac/dc status, which I did not get before my PayloadParser change. I suppose that it is in the second page, requested with offset 0x46. I remember original field filter having problems with that page.

dpleiss commented 1 year ago

Alex, you got it right, I got it wrong!