Closed plord12 closed 1 month ago
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.
Ok folks, here's the pre-release. Few things to tweak, but I've been running this for a few days and had no issues with it. Could someone with a Zappi verify that I didn't break functionality that has been added since 0.0.24? @videojedi Do I remember correctly that you have a Zappi?
Just to highlight the main changes:
I still need to add the app email/password to the reconfigure screen (so you won't have to remove the addon and readd it), but other than that I think we're there!
Brilliant !
I've installed it, so far so good. I'll know more after 24 hours though.
( BTW myenergi-20240501.tgz seems to be a tar file not a compressed tar file )
One thing I forgot to mention: setting the charge target does not seem to be reflected in the ME mobile app. I'm on Android, using 3.3.2 (rev. 41) version of the app and it does not reflect the changes I do via the API. The new charge target is taken into account (based on my testing), but the app will cache whatever value you set there. 🤷
Great work! Thanks for your efforts. I can confirm my Zappis are still functioning.
Now the weather is getting nicer, I plan to switch the charge from grid on or off based on solar prediction for the following day.
Will keep an eye on it and report back any/if issues.
I've installed it, so far so good. I'll know more after 24 hours though.
Overnight automations wored as expected :-)
Yep all my automations worked too. Looked at 8am and was slightly worried Libbi was Stopped. But then realised Octopus had given me cheap rate for 12.5 hours! Automation switched Libbi back to normal when cheap rate ended as intended. Cheers.
I assume everything is still working. I am just finishing off improving the UX when moving from the current version to the new one that will support OAuth - don't really want to tell users to remove the integration and re-add it to enter the app email/password.
The pymyenergi PR is in. 🎉 Once that's merged I can submit the PR for this as it is fully ready! When the new version is out, you can simply hit 'reconfigure' on the integration, add app email/password and boom; you got all the new features. Pretty proud of the user experience handling... 😁
Awesome news! Not sure I need to do the new login if I'm using the test version from earlier in the thread? But I look forward to seeing it as available soon either way. Good job! 😀
Awesome news! Not sure I need to do the new login if I'm using the test version from earlier in the thread? But I look forward to seeing it as available soon either way. Good job! 😀
You won't need it. The 'Reconfigure' will only be required if you're upgrading from the official 0.0.27 version.
Hi, I just wondered what the sensor was for the charge and set target charge? I can set stopped, normal and export but can't find the new charge / set charge target.
Hi, I just wondered what the sensor was for the charge and set target charge? I can set stopped, normal and export but can't find the new charge / set charge target.
Use the myenergi_libbi_charge_target service to set the charge target of the libbi.
Strange, I don't seem to have that. Can you share a screenshot in assistant of that service?
Hacs says I'm on 0.0.27 but no update available
In order to see that you need to use the currently unreleased version that's included further up here. I'm waiting for my PR to be accepted for pymyenergi and once that's done I can submit my PR for ha-myenergi, which would include this functionality in the official release.
@trizmark it looks like the pymyenergi change has been made in 0.2.0 would it be possible to get this great new functionality included in ha-myenergi?
I don't know why because the old test version still works fine, but I'm checking for the update every day.
I was waiting for the official HACs version but I think I will install the test version that supports charging. Silly question (but I'm fairly new to HA) how do you install the test version?
I don't think the Libbi supports on-demand charging? Or at least not yet. It does some weird thing with Agile tariffs where at 4pm it gets the next day's cheapest periods and charges itself at those times, but there's no way to forcibly charge it.
Also waiting patiently for this release :)
In related news, wonder whether this beta testing will have any ramifications for this integration: https://myenergi.info/libbi-beta-testing-signup-t13284.html
In related news, wonder whether this beta testing will have any ramifications for this integration: https://myenergi.info/libbi-beta-testing-signup-t13284.html
Good point ... I signed up, but I guess the server API will remain the same so that phone app remains working,. Could have more features I suppose.
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