[charger] Add support for OCPP chargers#47
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for OCPP (Open Charge Point Protocol) chargers to the EVSE load balancer by implementing a new OcppCharger class. The implementation enables the load balancer to work with OCPP-compliant charging stations through the existing OCPP Home Assistant integration.
Key changes include:
- Added complete OCPP charger implementation with status monitoring and current limit control
- Integrated OCPP charger into the factory pattern for automatic device detection
- Added comprehensive test coverage for all OCPP charger functionality
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
custom_components/evse_load_balancer/chargers/ocpp_charger.py |
Main implementation of OCPP charger with status monitoring, current limit management, and OCPP-specific entity mappings |
tests/chargers/test_ocpp_charger.py |
Comprehensive test suite covering all OCPP charger methods and edge cases |
custom_components/evse_load_balancer/const.py |
Added OCPP domain constant for service calls |
custom_components/evse_load_balancer/config_flow.py |
Integrated OCPP as supported charger type in configuration flow |
custom_components/evse_load_balancer/chargers/__init__.py |
Added OCPP charger to factory registration |
README.md |
Updated documentation to include OCPP charger support |
Comments suppressed due to low confidence (2)
tests/chargers/test_ocpp_charger.py:164
- The test references OcppEntityMap.PowerOffered and implements power-based max current calculation, but this functionality is not implemented in the actual OcppCharger class. Either implement this feature or remove the test.
if key == OcppEntityMap.PowerOffered:
|
Seems to recognize the charger through the ocpp integration. However I cannot test more than that, since my 2 meters isnt supported and in adv. config i cannot choose correct entity for power consumption. |
|
hi @dirkgroenen Did a local merge of #44 (ocpp) and #45 (tibber), so i was able to complete the install of EVSE, however there seems to be something wrong. The state of the evse load balancing state becomes unavailable and throws quite a few errors in the log. This error originated from a custom integration. Logger: custom_components.evse_load_balancer.coordinator Available current for phase 'l1' is None.Cannot proceed with balancing cycle. and this one .. This error originated from a custom integration. Logger: homeassistant Error doing job: Exception in callback _TrackTimeInterval._interval_listener() (None) |
|
Thanks @kljakobsen! Just pushed a change to the branch which should fix the The other one ( Would you mind checking if it works? If not let me know and I'll dive into the Tibber integration branch to try and find the issue there. |
|
If you have some time to spare, may I ask you @kljakobsen to have another look at this one? 🙏 |
|
Hi @kljakobsen - in case the previous message got lost; would you mind having another test with this such we can continue merging? |
|
I'd love to help testing with our OCPP charger and the DSMR-integration. With the changes from 5d0a8e9 added (that's the only change?), instead of
This is from the log:
|
|
So, I did some rewriting (with some AI help) and seems to be functioning now. Made a pull request in the ocpp branch: #67 |
* Use the right status and status_connector * Improvements for ocpp charger * Fix for is_charging error in v1.0.5 * Rewrite set current to use number.set_value instead of ocpp service * Revert ha_device.py * Added transaction_id OcppEntityMap * Removed unneeded code for devid * Used the code from @dirkgroenen to use ChargePointMaxProfile instead of TxProfile * Change charging profile and add spec --------- Co-authored-by: Dirk Groenen <dirk@bitlabs.nl>
|
Alright @juliusvaart, as mentioned in #67 I merged your changes, fixed the tests and made sure we're in a "green" state again. Reading the other thread it seems like the last thing we were checking was why the "Load Balancer Status" wasn't switching to Asking for the device's entities you returned the following:
But, those are the Load Balancer Device entities. I was actually referring to the OCPP charger one so we can see which entities are exposed by the OCPP Charger. Reason for asking: the load balancer should be looking for entities ending with So what we can do next:
In the meantime check the logs for any issues. Hopefully we're only a small step away from having this fixed and working 🙌 |
|
With the branch in your repo it also remains on "Awaiting charger". The entities from OCPP Charger are: Nothing in the logs, maybe we could add some extra logs in the ocpp_charger.py? "sensor.charger_status_connector" is "Charging" _"Preparing", "Charging" and "SuspendedEV" are good statusses, but all statusses when a car is connected are:
Edit: see that all the right statusses are in car_connected(). |
|
Oke, found out that EVSE Load Balancer is not finding the entities. With this _get_status() (from ChatGPT) it works: Same issue with get_current_limit(). This ChatGPT thing works (also with Only issue is with the TransactionID, it defaults to 0 when restarting HA and there is an issue with TxDefaultProfile vs TxProfile. |
|
Sorry for the late reply @juliusvaart - it's been very bust recently so had to park the side for a bit.
Did you found out because of the log messages telling there entity wasn't found? Cause the code should throw exceptions if entities doen't exist. I've pushed a change to the Can you update your code, enable the component's debug logging and restart home assistant? It should print a log line starting with Thanks! |
|
Hello @dirkgroenen, sorry for the late reply. I'm too busy to put a lot of effort in getting this right. My Python skills are lacking (and AI sucks if your skills are lacking ;-). When i've got time i'll dive into this. |



Closes #44 by adding support for OCPP chargers.
As the requester of the charger @kljakobsen, please can you have a look at this branch and test it out locally?
Apart from hoping that the correct entities will be used, I'm also particularly interested to know whether there's a way for me to retrieve the charger's configured maximum limit? Can you browse around and see if there's anything that does not expose the current configured current, but instead the maximum current of the installation?
Right now I've just used a value of 32A as a max - but obviously it would be way more ideal to retrieve the right value.
Let me know if it works 🙏
You can update (if done via HACS) using: