Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support libbi export to grid #18

Open
plord12 opened this issue Oct 26, 2023 · 19 comments
Open

Support libbi export to grid #18

plord12 opened this issue Oct 26, 2023 · 19 comments

Comments

@plord12
Copy link

plord12 commented Oct 26, 2023

Since libbi 5.408 ( https://support.myenergi.com/hc/en-gb/articles/19276846239377-libbi-Firmware-Version-5-408 ) libbi supports export to grid. This is useful if you wanted to use your libbi to charge by cheap electricity (or solar) and export when export prices are high.

App now supports this :

Screenshot 2023-10-26 at 13 20 15
@videojedi
Copy link
Contributor

Looks like the endpoints are...

to turn on
https://s18.myenergi.net/cgi-libbi-mode-L24047041-5

and to turn off
https://s18.myenergi.net/cgi-libbi-mode-L24047041-1

@plord12
Copy link
Author

plord12 commented Oct 26, 2023

Looks like the endpoints are...

to turn on https://s18.myenergi.net/cgi-libbi-mode-L24047041-5

and to turn off https://s18.myenergi.net/cgi-libbi-mode-L24047041-1

Yes, agreed. ( I was just typing this and you beat me to it ! )

@videojedi
Copy link
Contributor

Early progress

image

@plord12
Copy link
Author

plord12 commented Oct 27, 2023

BTW, I don't think the official app displays the discharging status well. Overnight the app looked "good" ( ie asking me if I wanted to start export ) yet it was still in export mode. Battery drained overnight.

So we'll definatly want to see the status in home assistant -

$ myenergi -j libbi show
...
  "batteryDischargingBoost": false,
...

@plord12
Copy link
Author

plord12 commented Oct 27, 2023

Also need to fill in some more status. Guessing -

101 - slow charge ?
104 - idle & full
102 - some sort of discharging
12 - charging when in discharge mode

@plord12
Copy link
Author

plord12 commented Oct 28, 2023

Also need to fill in some more status. Guessing -

101 - slow charge ? 104 - idle & full 102 - some sort of discharging 12 - charging when in discharge mode

Maybe this helps ( from apk ) -

function F(e) {
    switch (e) {
        case 5:
            return p.LibbiStatus.charging;
        case 6:
            return p.LibbiStatus.discharging;
        case 7:
            return p.LibbiStatus.durationScheduledCharge;
        case 8:
            return p.LibbiStatus.durationScheduledDrain;
        case 11:
            return p.LibbiStatus.stopped;
        case 51:
        case 53:
        case 55:
            return p.LibbiStatus.boosting;
        case 251:
            return p.LibbiStatus.upgradingDSP;
        case 102:
        case 104:
            return p.LibbiStatus.full;
        case 252:
            return p.LibbiStatus.upgradingARM;
        default:
            return p.LibbiStatus.idle
    }
}

@plord12
Copy link
Author

plord12 commented Oct 28, 2023

Oh, we also need to add the new charging limit.

PUT https://myaccount.myenergi.com/api/AccountAccess/<serial>/TargetEnergy?targetEnergy=5100 

@trizmark
Copy link
Contributor

I've got all the functionality in https://github.com/trizmark/pymyenergi, which is a fork of https://github.com/mattburns/pymyenergi, which has an open PR (https://github.com/CJNE/pymyenergi/pulls/16) on this repo. Once matthburns merges my PR, the open PR will update here as well and hopefully CJNE will have time to review/merge.
I've got a PR ready to go on ha-myenergi as soon as pymyenergi is updated.

BTW, got the full status list from the app source:

    0: "Off",
    1: "On",
    2: "Battery Full",
    4: "Idle",
    5: "Charging",
    6: "Discharging",
    7: "Duration Charging",
    8: "Duration Drain",
    12: "Target Charge",
    51: "Boosting",
    53: "Boosting",
    55: "Boosting",
    11: "Stopped",
    101: "Idle?",
    102: "Full",
    104: "Full",
    151: "FW Upgrade (ARM)",
    156: "FW Upgrade (DSP)",
    234: "Calibration Charge",
    251: "FW Upgrade (DSP)",
    252: "FW Upgrade (ARM)",

@trizmark
Copy link
Contributor

trizmark commented Jun 3, 2024

0.2.0 released today, which includes this functionality!

@MaximumFish
Copy link

BTW, got the full status list from the app source:

What are the odds of refining these to be more useful/descriptive? I'm using the HA integration myself and figured out that Idle? means the battery is empty so I was able to set an alert for that. Ideally I'd also like to be able to have visibility for when the battery is: full and idle, "full" (above 95%) and still charging, and "full" and discharging. There's three separate Full states listed (2, 102 and 104) so presumably that's all of those?

Happy to help in any way I can but I've not used this library beyond the HA integration...

@plord12
Copy link
Author

plord12 commented Aug 21, 2024

What are the odds of refining these to be more useful/descriptive?

See #50 for an update (from the manual!)

@MaximumFish
Copy link

What are the odds of refining these to be more useful/descriptive?

See #50 for an update (from the manual!)

Oh yeah, they're in the manual! Though it doesn't include any of the normal operation stuff or "Full" code 104.

@MalcolmSpencer
Copy link

Looking for help......

I can change the charge target in HA and it reflects correctly in the HA dashboard but it doesn't change the target in the iOS App and when I open the iOSApp, the charge target in HA is set back to the iOSApp value. I have a primary account using email and password but the location is shared with my wife who has read-only access.

Is this behaviour you all see or different?

@trizmark
Copy link
Contributor

@MalcolmSpencer It is a ME app/frontend issue. I'm on Android, but even if I logout/clear app data/cache the target set via the API is not picked up. However, if I call the API directly, it returns the correct value.
I did a quick test to prove that it works as expected.
I set my SoC target to 60% in the app. I used HA to set the SoC target to 100% (18.4kW in my case). Current libbi SoC is 67%.
Open the app and it still shows 60% and warns me that it won't charge as the current SoC is above the target.
I set the 18:00-18:30 to be a cheap timeslot to trigger charging from grid and the libbi starts charging full throttle.

I'll ping ME about it, but since public use of the API is unsupported I doubt they'll do annnything about it.

So, trust what you see in HA! That's the real deal! 😉

@MalcolmSpencer
Copy link

MalcolmSpencer commented Aug 31, 2024

The problem i have is slightly different. If I have the ME app target SoC set to 100% (9.2kWh). I then set the target soc to 4.6Kw in HA. If I open the libbi screen on the iOS App the HA target SoC gets set back to 9.2kWh.
The same happens whether grid charge is on or off in the ME App

@G6EJD
Copy link

G6EJD commented Aug 31, 2024

This was a comment rather then an issue with the integration/ code.

@trizmark
Copy link
Contributor

The problem i have is slightly different. If I have the ME app target SoC set to 100% (9.2kWh). I then set the target soc to 4.6Kw in HA. If I open the libbi screen on the iOS App the HA target SoC gets set back to 9.2kWh. The same happens whether grid charge is on or off in the ME App

THe only iOS device I got is an iPad and the behaviour is exactly the same as my Android phone. Any update done via HA to the charge target is not reflected in the app. All settings remained the same when I opened the libbi page in iOS. Even if I toggled the grid charging on/off in the iOS app, it kept showing 60% SoC target even though HA showed 100% (which was the one I set from there).

Obviously there could be a difference in the iOS code as the ME app is a native iPad app.

@MalcolmSpencer
Copy link

Thanks, not sure whats going on but I'll try and do some testing and let you know.
For now, the safest way is to leave the target charge at 100% and have HA monitor the SoC and turn 'charge form grid' on and off as required to hit the target soc charge.

@browncp-lly
Copy link

I think I have this same issue where the Libbi charge target doesn't charge in the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants