ha-myenergi
ha-myenergi copied to clipboard
Support libbi export to grid
Is your feature request related to a problem? Please describe.
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.
Describe the solution you'd like
HA entity to turn on and off export to grid.
Describe alternatives you've considered
none
Additional context
Also raised https://github.com/CJNE/pymyenergi/issues/18 for the underlying library
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
It's not a very consistent API is it!
I've got it working locally; will be posting it here soon.
The API is sort of consistent. Looking at the app code there are a number of modes that are defined, but not used and cannot be set. (capture, charge, match) The new mode (drain) was simply added to the list and that's why it became 5.
Charge target is implemented as well, but it's super-broken in the libbi firmware. 😞
Charge target is implemented as well, but it's super-broken in the libbi firmware. 😞
Nice :-) I'll try it with the app tonight.
BTW do you have 5.414 installed on your libbi ? ( see https://myenergi.info/libbi-no-longer-fully-charging-with-cheap-rate-ove-t11328.html )
I had 5.408 on until this morning. Overnight, instead of my set 2.5h charge, the libbi only charged for an hour and then it sort of held the SoC. I installed 5.414, which now completely broke the charge from grid. Grrrr!
For those who are foolish and reckless.... I present you the latest bleeding edge version of the integration. New operation mode for your libbi: 'Export'. Let me know if you have any issues with it. myenergi-20231029.tgz
I am adding the service to set the charge target. New version probably tomorrow (depending on my schedule).
Great work. I'm running 5.414.
Can confirm export works!
My charge target remains the same with toggling the charge from grid. Does yours change?
Yes mine seems to default to zero... I reset it in the app to 100%, and toggle it again in home assistant, but it returns to zero
Same behaviour in the app too...... toggle it and it returns to zero.
aha.... this is another shared account issue. If I login into app with primary account details, then it remembers the chargetarget between toggles...
If it's the same issue in the app, then it's a myenergi issue.
I have tested it with my secondary account and it is indeed a myenergi backend issue. 🤦
For those who are foolish and reckless.... I present you the latest bleeding edge version of the integration. New operation mode for your libbi: 'Export'. Let me know if you have any issues with it. myenergi-20231029.tgz
FYI, didn't work for me, plugin failed to startup. I see in the logs -
2023-10-30 13:09:29.625 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Home for myenergi
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 399, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/myenergi/__init__.py", line 53, in async_setup_entry
conn = await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/myenergi/pymyenergi/connection.py", line 40, in __init__
self.oauth.authenticate(password=self.app_password)
File "/usr/local/lib/python3.11/site-packages/pycognito/__init__.py", line 478, in authenticate
tokens = aws.authenticate_user(client_metadata=client_metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pycognito/aws_srp.py", line 269, in authenticate_user
response = boto_client.initiate_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/botocore/client.py", line 535, in _api_call
return self._make_api_call(operation_name, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/botocore/client.py", line 936, in _make_api_call
request_dict = self._convert_to_request_dict(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/botocore/client.py", line 1007, in _convert_to_request_dict
request_dict = self._serializer.serialize_to_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/botocore/validate.py", line 381, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter AuthParameters.USERNAME, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
Rolled back to official version and it started up.
As this version adds the OAuth endpoints you need to remove your integration and re-add it as it requires both API key/password and App email/app password parameters.
As this version adds the OAuth endpoints you need to remove your integration and re-add it as it requires both API key/password and App email/app password parameters.
Ah, got it, thanks. After re-adding ( and entering username/password ) I was able to enable export :-)
My grid charge percentage stayed at 60% FYI.
Great to hear! The charge target is only an issue if you're using a secondary account to access your main account. People who signed up to a myenergi account using google/apple/facebook need a secondary account as currently we only support OAuth with email/password combo.
I am nearly ready with the charge target setting functionality, but as this is the first time I'm implementing a HA service, it is a lot of trial and error.
Thanks for making this version. Is there a plan for getting a 0.0.25 made with this in? (Sorry, I'm not sure how that side is managed) Thanks
@whittyone Yes, there is. I am updating the pymyenergi library currently. Once that's done and out, I can push my modifications to the HA component.
I see this didn't make 0.0.25
@plord12 The 0.1.0 version of pymyenergi (released yesterday) has all the necessary features in there, so once I rebase my local dev copy to 0.0.25, this will be in 0.0.26.
@plord12 The 0.1.0 version of pymyenergi (released yesterday) has all the necessary features in there, so once I rebase my local dev copy to 0.0.25, this will be in 0.0.26.
Brilliant! Many thanks.
I'm making really good use of this to dump excess power in the evenings and during Octopus saving sessions, so good to know that I shouldn't upgrade just yet. Thanks!
@plord12 The 0.1.0 version of pymyenergi (released yesterday) has all the necessary features in there, so once I rebase my local dev copy to 0.0.25, this will be in 0.0.26.
Did this get added to 0.0.26 or 0.0.27? I don't see it in the changelogs.
I'm still working on getting the PR ready. Unfortunately work has been eating into my spare time, so no ETA at the moment.
No worries. 0.0.25 is still working fine for me so I'm in no rush to update. 😄
I hate to pester, given so many give their time for projects like this, but any news ?
Once this gets in I hope to look at the libbi dual tariff issue (eg sync libbi schedule from octopus) ... but I don't really want to get going until this is in.
Cheers :-)
I can see the light at the end of the tunnel! I've been playing catch-up with the changes that happened in this repo vs what I've added. Hoping to submit the PR this weekend. 🤞
@trizmark would you be able to look at issue #516 when you do your update? Currently, Libbi operating mode is not working in 0.0.27 but the solution is described.
Thanks,
I found that issue when I brought my fork up to 0.0.27 and it's already fixed.