Skip to content

Commit 14c32ed

Browse files
drc38Jan Thunqvistdependabot[bot]lbbrhznmutesplash
authored
Multiple connectors (#91)
* Update .gitignore for HA dev. Use symlinks for integration. * Handle multiple connectors, initial framework. * Fix sensor updates and placement on proper devices. * Add test for v2x multi connector. Handle meter values properly. max_current working per connector. * add ocpp versions supported (lbbrhzn#1678) * build(deps): bump actions/checkout from 4 to 5 (lbbrhzn#1685) * build(deps): bump pre-commit from 4.2.0 to 4.3.0 (lbbrhzn#1686) * build(deps): bump ruff from 0.12.2 to 0.12.9 (lbbrhzn#1687) * Fix per connector set charge rate. Clean up swenglish comments. * Remove separate connector device breaking change. Fix test race condition. CodeRabbit fixes. * Fix max_current per connector bug. Remove ChargerSession sensors (used for debugging). Fix Charge Control naming when only one connector. More CodeRabbit suggestions. * Fix Connector naming. More CodeRabbit suggestions. * Add more tests. More CodeRabbit suggestions. * Test fixes. CodeRabbit suggestions. * Fix tests. * Split stop transaction test in separate tests. * Change entity id to include charger. Add session sensors to connectors. Clear charger-level entities after connector creation. Add num_connector changes to reload logic. Remove not used functions from chargepoint.py. Revert to original config flow due to automatic discovery of number of connectors. Add more tests. * Change port on test to fix crash. * Correct custom component name for debuggging (lbbrhzn#1697) * Add missing sensors. Convert features value in sensor. Add num_connectors to config entry. Migration to config 2.1. --------- Co-authored-by: Jan Thunqvist <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: lbbrhzn <[email protected]> Co-authored-by: mutesplash <[email protected]>
1 parent ee6a66b commit 14c32ed

34 files changed

+5775
-961
lines changed

.github/workflows/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Check out the repository
15-
uses: actions/checkout@v4
15+
uses: actions/checkout@v5
1616

1717
- name: Run Labeler
1818
uses: crazy-max/[email protected]

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
contents: write
1717
steps:
1818
- name: 📥 Checkout the repository
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020

2121
- name: 🛠️ Set up Python
2222
uses: actions/[email protected]

.github/workflows/publish_docs_to_wiki.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
publish_docs_to_wiki:
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v5
2222

2323
- name: Pull wiki
2424
run: |

.github/workflows/sphinx-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
docs:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v4
9+
- uses: actions/checkout@v5
1010
- uses: ammaraskar/sphinx-action@master
1111
with:
1212
docs-folder: "docs/"

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
name: Pre-commit
1818
steps:
1919
- name: Check out the repository
20-
uses: actions/checkout@v4
20+
uses: actions/checkout@v5
2121

2222
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
2323
uses: actions/[email protected]
@@ -46,7 +46,7 @@ jobs:
4646
name: HACS
4747
steps:
4848
- name: Check out the repository
49-
uses: "actions/checkout@v4"
49+
uses: "actions/checkout@v5"
5050

5151
- name: HACS validation
5252
uses: "hacs/action@main"
@@ -59,7 +59,7 @@ jobs:
5959
name: Hassfest
6060
steps:
6161
- name: Check out the repository
62-
uses: "actions/checkout@v4"
62+
uses: "actions/checkout@v5"
6363

6464
- name: Hassfest validation
6565
uses: "home-assistant/actions/hassfest@master"
@@ -69,7 +69,7 @@ jobs:
6969
environment: continuous-integration
7070
steps:
7171
- name: Check out code from GitHub
72-
uses: "actions/checkout@v4"
72+
uses: "actions/checkout@v5"
7373
- name: Setup Python ${{ env.DEFAULT_PYTHON }}
7474
uses: "actions/[email protected]"
7575
with:

.github/workflows/update-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v5
1414

1515
- name: Update version in manifest.json and commit
1616
env:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,7 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# HA Development
132+
/config/
133+
.DS_Store

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
![OCPP](https://github.com/home-assistant/brands/raw/master/custom_integrations/ocpp/icon.png)
77

8-
This is a Home Assistant integration for Electric Vehicle chargers that support the Open Charge Point Protocol.
8+
This is a Home Assistant integration for Electric Vehicle chargers that support the following Open Charge Point Protocols 1.6j, 2.0.1 and 2.1 (experimental).
99

1010
* based on the [Python OCPP Package](https://github.com/mobilityhouse/ocpp).
1111
* HACS compliant repository

config/configuration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ ocpp:
6565
logger:
6666
default: info
6767
logs:
68-
custom_components.cpps: debug
68+
custom_components.ocpp: debug
6969

7070
# If you need to debug uncomment the line below (doc: https://www.home-assistant.io/integrations/debugpy/)
7171
# debugpy:

custom_components/ocpp/__init__.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
CONF_METER_INTERVAL,
2626
CONF_MONITORED_VARIABLES,
2727
CONF_MONITORED_VARIABLES_AUTOCONFIG,
28+
CONF_NUM_CONNECTORS,
2829
CONF_SKIP_SCHEMA_VALIDATION,
2930
CONF_FORCE_SMART_CHARGING,
3031
CONF_HOST,
@@ -44,6 +45,7 @@
4445
DEFAULT_METER_INTERVAL,
4546
DEFAULT_MONITORED_VARIABLES,
4647
DEFAULT_MONITORED_VARIABLES_AUTOCONFIG,
48+
DEFAULT_NUM_CONNECTORS,
4749
DEFAULT_SKIP_SCHEMA_VALIDATION,
4850
DEFAULT_FORCE_SMART_CHARGING,
4951
DEFAULT_HOST,
@@ -192,6 +194,36 @@ async def async_migrate_entry(hass, config_entry: ConfigEntry):
192194
config_entry, data=new_data, minor_version=0, version=2
193195
)
194196

197+
if config_entry.version == 2 and config_entry.minor_version == 0:
198+
data = {**config_entry.data}
199+
cpids = data.get(CONF_CPIDS, [])
200+
201+
changed = False
202+
for idx, cp_map in enumerate(cpids):
203+
if not isinstance(cp_map, dict) or not cp_map:
204+
continue
205+
cp_id, cp_data = next(iter(cp_map.items()))
206+
if CONF_NUM_CONNECTORS not in cp_data:
207+
cp_data = {**cp_data, CONF_NUM_CONNECTORS: DEFAULT_NUM_CONNECTORS}
208+
cpids[idx] = {cp_id: cp_data}
209+
changed = True
210+
211+
if changed:
212+
data[CONF_CPIDS] = cpids
213+
hass.config_entries.async_update_entry(
214+
config_entry,
215+
data=data,
216+
version=2,
217+
minor_version=1,
218+
)
219+
else:
220+
hass.config_entries.async_update_entry(
221+
config_entry,
222+
data=data,
223+
version=2,
224+
minor_version=1,
225+
)
226+
195227
_LOGGER.info(
196228
"Migration to configuration version %s.%s successful",
197229
config_entry.version,

0 commit comments

Comments
 (0)