From 8e56e13db2dfe84dbb5bfe45efdbf3e6a5321f55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:57:19 +0100 Subject: [PATCH 1/7] build(deps): bump sphinx-rtd-theme from 3.0.1 to 3.0.2 (#1408) Bumps [sphinx-rtd-theme](https://github.com/readthedocs/sphinx_rtd_theme) from 3.0.1 to 3.0.2. - [Changelog](https://github.com/readthedocs/sphinx_rtd_theme/blob/master/docs/changelog.rst) - [Commits](https://github.com/readthedocs/sphinx_rtd_theme/compare/3.0.1...3.0.2) --- updated-dependencies: - dependency-name: sphinx-rtd-theme dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 93ff933f..709ccb7b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,4 +2,4 @@ myst-parser==3.0.1 docutils==0.18.1 Jinja2==3.1.4 sphinx==7.1.2 -sphinx_rtd_theme==3.0.1 +sphinx_rtd_theme==3.0.2 From 2e7a015cb672255d7bb74c662aeb5b5bb628967e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:58:04 +0100 Subject: [PATCH 2/7] build(deps): bump pytest-homeassistant-custom-component (#1407) Bumps [pytest-homeassistant-custom-component](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component) from 0.13.183 to 0.13.184. - [Release notes](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/releases) - [Changelog](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/blob/master/CHANGELOG.md) - [Commits](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/compare/0.13.183...0.13.184) --- updated-dependencies: - dependency-name: pytest-homeassistant-custom-component dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3530361e..91dfa4e5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,6 @@ ocpp==1.0.0 websockets==13.1 jsonschema==4.23.0 pre-commit==4.0.1 -pytest-homeassistant-custom-component==0.13.183 +pytest-homeassistant-custom-component==0.13.184 setuptools>=70.0.0 # not directly required, pinned by Snyk to avoid a vulnerability zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability From 1c62f4005e7d9b3ab431ceb9a2505e29c1242360 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:44:08 +0100 Subject: [PATCH 3/7] build(deps): bump websockets from 13.1 to 14.1 (#1395) * build(deps): bump websockets from 13.1 to 14.1 Bumps [websockets](https://github.com/python-websockets/websockets) from 13.1 to 14.1. - [Release notes](https://github.com/python-websockets/websockets/releases) - [Commits](https://github.com/python-websockets/websockets/compare/13.1...14.1) --- updated-dependencies: - dependency-name: websockets dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * update for >14 * fix linting * suppress close * drop restriction --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: lbbrhzn <8673442+lbbrhzn@users.noreply.github.com> Co-authored-by: drc38 <20024196+drc38@users.noreply.github.com> --- custom_components/ocpp/manifest.json | 2 +- requirements.txt | 2 +- tests/test_charge_point_v16.py | 68 ++++++++++++---------------- 3 files changed, 30 insertions(+), 42 deletions(-) diff --git a/custom_components/ocpp/manifest.json b/custom_components/ocpp/manifest.json index 3037e129..9f826d71 100644 --- a/custom_components/ocpp/manifest.json +++ b/custom_components/ocpp/manifest.json @@ -14,7 +14,7 @@ "issue_tracker": "https://github.com/lbbrhzn/ocpp/issues", "requirements": [ "ocpp>=1.0.0", - "websockets>=12.0,<14" + "websockets>=12.0" ], "version": "0.6.1" } diff --git a/requirements.txt b/requirements.txt index 91dfa4e5..cbb8ea3b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ colorlog==6.9.0 uv>=0.4 ruff==0.8.0 ocpp==1.0.0 -websockets==13.1 +websockets==14.1 jsonschema==4.23.0 pre-commit==4.0.1 pytest-homeassistant-custom-component==0.13.184 diff --git a/tests/test_charge_point_v16.py b/tests/test_charge_point_v16.py index 4da5d22d..ffc60a23 100644 --- a/tests/test_charge_point_v16.py +++ b/tests/test_charge_point_v16.py @@ -130,12 +130,18 @@ async def test_services(hass, cs, socket_enabled): await hass.async_block_till_done() # no subprotocol + # NB each new config entry will trigger async_update_entry + # if the charger measurands differ from the config entry + # which causes the websocket server to close/restart with a + # ConnectionClosedOK exception, hence it needs to be passed/suppressed async with websockets.connect( "ws://127.0.0.1:9002/CP_1_nosub", ) as ws2: # use a different id for debugging cp2 = ChargePoint("CP_1_no_subprotocol", ws2) - with contextlib.suppress(asyncio.TimeoutError): + with contextlib.suppress( + asyncio.TimeoutError, websockets.exceptions.ConnectionClosedOK + ): await asyncio.wait_for( asyncio.gather( cp2.start(), @@ -177,17 +183,8 @@ async def test_services(hass, cs, socket_enabled): await asyncio.wait_for( asyncio.gather( cp.start(), - cp.send_boot_notification(), - cp.send_authorize(), - cp.send_heartbeat(), - cp.send_status_notification(), - cp.send_firmware_status(), - cp.send_data_transfer(), - cp.send_start_transaction(), - cp.send_stop_transaction(), - cp.send_meter_periodic_data(), ), - timeout=5, + timeout=3, ) await ws.close() @@ -204,17 +201,8 @@ async def test_services(hass, cs, socket_enabled): await asyncio.wait_for( asyncio.gather( cp.start(), - cp.send_boot_notification(), - cp.send_authorize(), - cp.send_heartbeat(), - cp.send_status_notification(), - cp.send_firmware_status(), - cp.send_data_transfer(), - cp.send_start_transaction(), - cp.send_stop_transaction(), - cp.send_meter_periodic_data(), ), - timeout=5, + timeout=3, ) await ws.close() @@ -235,7 +223,7 @@ async def test_services(hass, cs, socket_enabled): cp.start(), cp.send_meter_periodic_data(), ), - timeout=5, + timeout=3, ) # check if None assert cs.get_metric("test_cpid", "Energy.Meter.Start") is None @@ -247,7 +235,7 @@ async def test_services(hass, cs, socket_enabled): cp.send_start_transaction(12344), cp.send_meter_periodic_data(), ), - timeout=5, + timeout=3, ) # save for reference the values for meter_start and transaction_id saved_meter_start = int(cs.get_metric("test_cpid", "Energy.Meter.Start")) @@ -261,7 +249,7 @@ async def test_services(hass, cs, socket_enabled): asyncio.gather( cp.send_meter_periodic_data(), ), - timeout=5, + timeout=3, ) await ws.close() @@ -423,9 +411,11 @@ async def test_services(hass, cs, socket_enabled): "ws://127.0.0.1:9000/CP_1_error", subprotocols=["ocpp1.6"], ) as ws: - cp = ChargePoint("CP_1_error", ws) - cp.accept = False - try: + with contextlib.suppress( + asyncio.TimeoutError, websockets.exceptions.ConnectionClosedOK + ): + cp = ChargePoint("CP_1_error", ws) + cp.accept = False await asyncio.wait_for( asyncio.gather( cp.start(), @@ -437,23 +427,21 @@ async def test_services(hass, cs, socket_enabled): ), timeout=3, ) - except TimeoutError: - pass - except websockets.exceptions.ConnectionClosedOK: - pass await ws.close() await asyncio.sleep(1) + + # setting state no longer available with websockets >14 # test ping timeout, change cpid to start new connection - cs.settings.cpid = "CP_3_test" - async with websockets.connect( - "ws://127.0.0.1:9000/CP_3", - subprotocols=["ocpp1.6"], - ) as ws: - cp = ChargePoint("CP_3_test", ws) - ws.state = 3 # CLOSED = 3 - await asyncio.sleep(3) - await ws.close() + # cs.settings.cpid = "CP_3_test" + # async with websockets.connect( + # "ws://127.0.0.1:9000/CP_3", + # subprotocols=["ocpp1.6"], + # ) as ws: + # cp = ChargePoint("CP_3_test", ws) + # ws.state = 3 # CLOSED = 3 + # await asyncio.sleep(3) + # await ws.close() # test services when charger is unavailable await asyncio.sleep(1) From a55913cec503110b6b2a5270bcd5f57e145ac19a Mon Sep 17 00:00:00 2001 From: drc38 <20024196+drc38@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:22:15 +1300 Subject: [PATCH 4/7] add pytest fixture loop scope (#1412) --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 3239665c..d3d043b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,7 @@ addopts = -qq --cov=custom_components.ocpp --allow-unix-socket --allow-hosts=127.0.0.1 console_output_style = count asyncio_mode = auto +asyncio_default_fixture_loop_scope = function [coverage:report] show_missing = true From 51bc1422520d22efd816d5f23bb92709967d1ebf Mon Sep 17 00:00:00 2001 From: Nerdix <70015952+N3rdix@users.noreply.github.com> Date: Sun, 1 Dec 2024 07:54:30 +0100 Subject: [PATCH 5/7] Correct reactive power device class (#1417) * reactive power * fix * exclude energy reactive --- custom_components/ocpp/sensor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/ocpp/sensor.py b/custom_components/ocpp/sensor.py index 536f2b0a..d577ee09 100644 --- a/custom_components/ocpp/sensor.py +++ b/custom_components/ocpp/sensor.py @@ -156,6 +156,8 @@ def device_class(self): device_class = SensorDeviceClass.CURRENT elif self.metric.lower().startswith("voltage"): device_class = SensorDeviceClass.VOLTAGE + elif self.metric.lower().startswith("energy.r"): + device_class = None elif self.metric.lower().startswith("energy."): device_class = SensorDeviceClass.ENERGY elif self.metric in [ @@ -163,8 +165,10 @@ def device_class(self): Measurand.rpm, ] or self.metric.lower().startswith("frequency"): device_class = SensorDeviceClass.FREQUENCY - elif self.metric.lower().startswith(("power.a", "power.o", "power.r")): + elif self.metric.lower().startswith(("power.a", "power.o")): device_class = SensorDeviceClass.POWER + elif self.metric.lower().startswith("power.r"): + device_class = SensorDeviceClass.REACTIVE_POWER elif self.metric.lower().startswith("temperature."): device_class = SensorDeviceClass.TEMPERATURE elif self.metric.lower().startswith("timestamp.") or self.metric in [ From b5924d0ac6c398ca2273d42d0e7457257349fd31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:01:26 +0100 Subject: [PATCH 6/7] build(deps): bump ruff from 0.8.0 to 0.8.1 (#1416) Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.0 to 0.8.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.0...0.8.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: drc38 <20024196+drc38@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cbb8ea3b..6a8e4abc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ colorlog==6.9.0 uv>=0.4 -ruff==0.8.0 +ruff==0.8.1 ocpp==1.0.0 websockets==14.1 jsonschema==4.23.0 From f4ed62ef53909a6c4b11f90a9a9c8ec8c126bdaf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Dec 2024 20:01:54 +0100 Subject: [PATCH 7/7] build(deps): bump pytest-homeassistant-custom-component (#1415) Bumps [pytest-homeassistant-custom-component](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component) from 0.13.184 to 0.13.186. - [Release notes](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/releases) - [Changelog](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/blob/master/CHANGELOG.md) - [Commits](https://github.com/MatthewFlamm/pytest-homeassistant-custom-component/compare/0.13.184...0.13.186) --- updated-dependencies: - dependency-name: pytest-homeassistant-custom-component dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6a8e4abc..ee608fdf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,6 @@ ocpp==1.0.0 websockets==14.1 jsonschema==4.23.0 pre-commit==4.0.1 -pytest-homeassistant-custom-component==0.13.184 +pytest-homeassistant-custom-component==0.13.186 setuptools>=70.0.0 # not directly required, pinned by Snyk to avoid a vulnerability zipp>=3.19.1 # not directly required, pinned by Snyk to avoid a vulnerability