darrylb123 / ESP32_SMA-Inverter-MQTT

Arduino project to read SMA Inverter data via ESP32 bluetooth
MIT License
6 stars 4 forks source link

Some suggested changes #2

Closed mrtoy-me closed 1 year ago

mrtoy-me commented 1 year ago

Hi Darryl

I downloaded your fork several weeks ago when you had just rearranged headers and linux naming. I have been doing something similiar to you - modifying to add mqtt to send data to homeassistant - but not as complex as you ! I should have got in touch earlier I think or forked (I am pretty new to this). I have been running ESP32 connected to SMA2500 continuously all day and only disconnecting at night then reconnecting in the morning. I was having some issues with logging on sometimes and reading data errors ever now and then which caused problems with reconnect. I just tracked them down today and checked back at your repository and found you had been very busy. I suspect what I found today has been the problem all along. Looks like I missed the Nov 28, 2022 update by Lupo135 - rvcpcktID unt8_t instead of uint16_t like pcktID and pcktID never being re-initialised to 1 after disconnect. That will teach me to fork instead of download. I have done this PR because I found a second function with uint8_t rcvpcktID definition and I am using a logoffSMAInverter function that I found in the SBFSpot code. They logoff at the end of initialise before login, not sure why but I tried it with success -it is working flawlessly for me (though it could have been another change I made). I am now setting pcktID to 1 when I reconnect. Testing that tomorrow !

Anyway hope this has not been too long a message for a PR ... if you want to do any exchange of learnings my email is mrtoy@pm.me and I am in Qld like you.. small world Regards Brett

darrylb123 commented 1 year ago

I've not had many failures with logging on. I'll give it a go though.

darrylb123 commented 1 year ago

I get this error the first time I start up BT-Signal 71.0 % *** logonSMAInverter Unexpected response 00:80:25:27:38:E7 pcktID=0x0004 rcvpcktID=0x1CCC now=0x000A

I assume, because it hadn't logged on before.

mrtoy-me commented 1 year ago

That error only started, I assume, with my suggested changes ..... that's weird because mine has been working flawlessly for several days now with ... logg off SMA then by BT flush, BT disconnect at night and in the morning, BT connect, initialise sma, getBT_SignalStrength, logoffSMA, LogonSMA.

mrtoy-me commented 1 year ago

Once I am connected in the morning, I read data every 2 minutes throughout the day and stay connected to SMA until there is no difference in Etotal and, only then do I disconnect. A quick scan of your main loop, and I think you are initialising/logging in and disconnecting each scan/request for data, is that right ?

mrtoy-me commented 1 year ago

I should really try it without logoffSMA .. just not sure I have time before going away

darrylb123 commented 1 year ago

I still have sbfspot operating. Not sure if staying connected will affect it. Does sbfspot have the same behaviour as you describe? I keep scanning through the night, just once every 15min scan once per minute through the day.

On Sat, Jul 8, 2023, 8:28 PM mrtoy-me @.***> wrote:

I should really try it without logoffSMA .. just not sure I have time before going away

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/ESP32_SMA-Inverter-MQTT/pull/2#issuecomment-1627076210, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVMLEVOBGVIA2FCASV3XPEY4FANCNFSM6AAAAAAZ4MURIQ . You are receiving this because you modified the open/close state.Message ID: @.***>

mrtoy-me commented 1 year ago

as far a I can tell sbfspot does what I am using - I used the logoff code from sbfspot and adapted it - then I looked how they were using it and tried it that way - been working a treat since. I would not be running sbfspot at the same time, sma could get confused if one app was logged in and another tried to login. I tried sbfspot integration for ha but I could not get the config right and it would not connect. The config was a real pain for me.

darrylb123 commented 1 year ago

I've been using the esp32 with my code and sbfspot simulateously for several days with out any issue with either. My sbfspot runs from cron evey 10min so must login each time?

On Sun, 9 Jul 2023, 11:22 am mrtoy-me, @.***> wrote:

as far a I can test sbfspot does what I am using - I used the logoff code from sbfspot and adapted it - then I looked how they were using it and tried it that way - been working a treat since. I would not be running sbfspot at the same time, sma could get confused if one app was logged in and another tried to login. I tried sbfspot integration for ha but I could not get the config right and it would not connect. The config was a real pain for me.

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/ESP32_SMA-Inverter-MQTT/pull/2#issuecomment-1627564582, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVOK4QEVSTUFFQKGHOLXPIBWRANCNFSM6AAAAAAZ4MURIQ . You are receiving this because you modified the open/close state.Message ID: @.***>

mrtoy-me commented 1 year ago

sounds like you should ditch my suggested changes :)

darrylb123 commented 1 year ago

I went away overnight from not long after I applied you changes. The esp32 failed for hours at a time yesterday, and all day today. The bluetooth connection was failing which has nothing to do with your changes??? Sometimes the signal strength was returned <1% other times there was nothing. I've used another module to see if it is the first module.

darrylb123 commented 12 months ago

Again today, only connected for about an hour, then stopped. Commented out both logoff and it stayed out the rest of the day. I've kept it there but wrapped in a #define. My inverter is a SB5000TL-20, don't know if there is any difference. Might try adding the logoff back one at a time to see which one or both causes it.

habuild commented 12 months ago

@darrylb123 Hi Darryl, sorry I didn't comment on the other pull request you just closed. I misplaced my BT esp32(the kids picked it up or something) so didn't have much else to add and I am unable to test atm. Good to hear you got this working nicely though.

@mrtoy-me Sorry to hear you had trouble with the HAOS-Sbfspot addon. If you wish to revist it in the future hit me up on my repo or the HA forums and I can try and help you with your config.

darrylb123 commented 11 months ago

Thanks, closed your pull request as it was way back. I bought a couple of wemos esp32 mini d1 off AliExpress. Very impressive and very cheap.

On Fri, 14 Jul 2023, 9:13 pm habuild, @.***> wrote:

@darrylb123 https://github.com/darrylb123 Hi Darryl, sorry I didn't comment on the other pull request you just closed. I misplaced my BT esp32(the kids picked it up or something) so didn't have much else to add and I am unable to test atm. Good to hear you got this working nicely though.

@mrtoy-me https://github.com/mrtoy-me Sorry to hear you had trouble with the HAOS-Sbfspot addon. If you wish to revist it in the future hit me up on my repo or the HA forums and I can try and help you with your config.

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/ESP32_SMA-Inverter-MQTT/pull/2#issuecomment-1635708637, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVKMDJ43GRD2O7FUTXTXQESVLANCNFSM6AAAAAAZ4MURIQ . You are receiving this because you were mentioned.Message ID: @.***>