From e3e4ffae569002ccf552b0c06049d1c7bc107475 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 13:23:41 +0200 Subject: [PATCH 01/17] Update hacs.json --- hacs.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hacs.json b/hacs.json index 8905092d..48b61e8a 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { - "name": "ocpp", + "name": "Open Charge Point Protocol", "content_in_root": false, "domains": [ "sensor" @@ -7,4 +7,4 @@ "homeassistant": "2021.6.6", "iot_class": "Local Push", "render_readme": true -} \ No newline at end of file +} From b6c376e8cbac921057f0da8a8b1c21260b38e0ec Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 13:24:44 +0200 Subject: [PATCH 02/17] Update hacs.json --- hacs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hacs.json b/hacs.json index 48b61e8a..1f427f64 100644 --- a/hacs.json +++ b/hacs.json @@ -1,5 +1,5 @@ { - "name": "Open Charge Point Protocol", + "name": "Open Charge Point Protocol (OCPP)", "content_in_root": false, "domains": [ "sensor" From c9aa7b3daa46230eab311e9be499c3b87b07cad2 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 18:28:15 +0200 Subject: [PATCH 03/17] Update README.md Add list of charges that we have tried. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 80f0bdef..110ec872 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,10 @@ This is a home assistant integration for chargers that support the Open Charge P ## Supported devices -The following devices are supported : -OCPP 1.6 compatible devices +All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of finctionality. So far, we've tried tried: +- [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) +- [Evlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) ## Development ### Debugging From 964ddb41aaa0d3c607973bf3eaa639283f12c206 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 18:29:08 +0200 Subject: [PATCH 04/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 110ec872..674ac86d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This is a home assistant integration for chargers that support the Open Charge P ## Supported devices -All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of finctionality. So far, we've tried tried: +All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of finctionality. So far, we've tried: - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [Evlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) From 8ddd155f414756abd3e22ec1aef4a24ea3b52b73 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 18:30:54 +0200 Subject: [PATCH 05/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 674ac86d..31b1c3d7 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This is a home assistant integration for chargers that support the Open Charge P ## Supported devices -All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of finctionality. So far, we've tried: +All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of functionality. So far, we've tried: - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [Evlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) From e3cbca1f218485293e4a34dae042002ab60688b1 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 18:32:03 +0200 Subject: [PATCH 06/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31b1c3d7..5ca569be 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This is a home assistant integration for chargers that support the Open Charge P All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of functionality. So far, we've tried: - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) -- [Evlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) +- [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) ## Development ### Debugging From 829bcb503a57d2a50d98e21bb913a472a0fb6cce Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 20:23:50 +0200 Subject: [PATCH 07/17] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ca569be..28a518f5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ All OCPP 1.6j compatible devices should be supported, but not every device offer - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) -## Development ### Debugging To enable debug logging for this integration and related libraries you @@ -55,4 +54,9 @@ logger: After a restart detailed log entries will appear in `/config/home-assistant.log`. +## Support +**💡 Tip:** If you like this project consider buying me a cocktail 🍹: + + Buy Me A Coffee + From 6fe09974b2bb7c10c9b643201363416c396690c4 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 21:45:42 +0200 Subject: [PATCH 08/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28a518f5..a9ed1e8d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![OCPP](https://github.com/home-assistant/brands/raw/master/custom_integrations/ocpp/icon.png) -This is a home assistant integration for chargers that support the Open Charge Point Protocol. +This is a Home Assistant integration for Electric Vehicle chargers that support the Open Charge Point Protocol. * based on the [Python OCPP Package](https://github.com/mobilityhouse/ocpp). * [HACS](https://hacs.xyz/) compatible repository From 50a5570cd449fa659b54ba5bd968d8507bdc8851 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 22:03:03 +0200 Subject: [PATCH 09/17] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a9ed1e8d..1886367c 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ All OCPP 1.6j compatible devices should be supported, but not every device offer - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) +### Devices with known issues +- [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet). + ### Debugging To enable debug logging for this integration and related libraries you From 5b86875af99faf76bcfff2ce0070a13d23becf49 Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 22:04:20 +0200 Subject: [PATCH 10/17] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1886367c..5295624a 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,10 @@ All OCPP 1.6j compatible devices should be supported, but not every device offer - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) -### Devices with known issues +## Devices with known issues - [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet). -### Debugging +## Debugging To enable debug logging for this integration and related libraries you can control this in your Home Assistant `configuration.yaml` From 4cad3527b3eaf5e6063e173aa7de5412df10049c Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sat, 17 Jul 2021 23:48:45 +0200 Subject: [PATCH 11/17] Create FUNDING.yml --- .github/FUNDING.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..74f02d8d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [lbbrhzn, drc38] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 0f611d39a956b98f69b3e8aaf0154b043049c0f6 Mon Sep 17 00:00:00 2001 From: drc38 <20024196+drc38@users.noreply.github.com> Date: Sun, 18 Jul 2021 11:27:45 +1200 Subject: [PATCH 12/17] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5295624a..66daa246 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ All OCPP 1.6j compatible devices should be supported, but not every device offer - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) +- [Evnex X7](https://www.evnex.com/) ## Devices with known issues - [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet). From eebdee6487898299597dfcff9cd7a7d9e175fd33 Mon Sep 17 00:00:00 2001 From: drc38 <20024196+drc38@users.noreply.github.com> Date: Sun, 18 Jul 2021 11:29:05 +1200 Subject: [PATCH 13/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 66daa246..1a9db439 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ All OCPP 1.6j compatible devices should be supported, but not every device offer - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) - [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) -- [Evnex X7](https://www.evnex.com/) +- [Evnex E Series & X Series Charging Stations](https://www.evnex.com/) ## Devices with known issues - [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet). From 75a041723b27de585d3119601cf9a61580da112a Mon Sep 17 00:00:00 2001 From: lbbrhzn Date: Sun, 18 Jul 2021 08:47:08 +0200 Subject: [PATCH 14/17] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a9db439..efa84652 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,9 @@ This is a Home Assistant integration for Electric Vehicle chargers that support All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of functionality. So far, we've tried: - [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar) -- [EVlink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) +- [EVLink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/) - [Evnex E Series & X Series Charging Stations](https://www.evnex.com/) +- [ABB Terra AC-W11-G5-R-0](https://new.abb.com/products/6AGC082156/tac-w11-g5-r-0) ## Devices with known issues - [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet). From 67fc04cc3235f7d27f0d8dbb1e38d1aac27443aa Mon Sep 17 00:00:00 2001 From: drc38 Date: Sun, 18 Jul 2021 21:38:01 +1200 Subject: [PATCH 15/17] occp: push metric updates --- custom_components/ocpp/api.py | 26 ++++++++++++++++++++++---- custom_components/ocpp/sensor.py | 2 +- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index b240a375..7bdb8d4f 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -8,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.const import TIME_MINUTES from homeassistant.core import HomeAssistant -from homeassistant.helpers import device_registry +from homeassistant.helpers import device_registry, entity_component, entity_registry import voluptuous as vol import websockets @@ -59,6 +59,7 @@ DOMAIN, HA_ENERGY_UNIT, HA_POWER_UNIT, + SENSOR, ) from .enums import ( ConfigurationKey as ckey, @@ -195,6 +196,18 @@ async def set_charger_state( resp = False return resp + async def update(self, cp_id: str): + """Update sensors values in HA.""" + er = entity_registry.async_get(self.hass) + dr = device_registry.async_get(self.hass) + identifiers = {(DOMAIN, cp_id)} + dev = dr.async_get_device(identifiers) + # _LOGGER.info("Device id: %s updating", dev.name) + for ent in entity_registry.async_entries_for_device(er, dev.id): + if SENSOR in ent.entity_id: + # _LOGGER.info("Entity id: %s updating", ent.entity_id) + entity_component.async_update_entity(self.hass, ent.entity_id) + def device_info(self): """Return device information.""" return { @@ -635,7 +648,7 @@ async def async_update_device_info(self, boot_info: dict): _LOGGER.debug("Updating device info %s: %s", self.central.cpid, boot_info) - dr = await device_registry.async_get_registry(self.hass) + dr = device_registry.async_get(self.hass) serial = boot_info.get(om.charge_point_serial_number.name, None) @@ -692,6 +705,7 @@ def on_meter_values(self, connector_id: int, meter_value: Dict, **kwargs): - float(self._metrics[csess.meter_start.value]), 1, ) + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.MeterValuesPayload() @on(Action.BootNotification) @@ -711,7 +725,7 @@ def on_boot_notification(self, **kwargs): ) asyncio.create_task(self.async_update_device_info(kwargs)) - + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.BootNotificationPayload( current_time=datetime.now(tz=timezone.utc).isoformat(), interval=30, @@ -733,12 +747,14 @@ def on_status_notification(self, connector_id, error_code, status, **kwargs): if Measurand.power_reactive_import.value in self._metrics: self._metrics[Measurand.power_reactive_import.value] = 0 self._metrics[cstat.error_code.value] = error_code + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.StatusNotificationPayload() @on(Action.FirmwareStatusNotification) def on_firmware_status(self, status, **kwargs): """Handle firmware status notification.""" self._metrics[cstat.firmware_status.value] = status + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.FirmwareStatusNotificationPayload() @on(Action.Authorize) @@ -755,6 +771,7 @@ def on_start_transaction(self, connector_id, id_tag, meter_start, **kwargs): self._metrics[cstat.stop_reason.value] = "" self._metrics[csess.transaction_id.value] = self._transactionId self._metrics[csess.meter_start.value] = int(meter_start) / 1000 + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.StartTransactionPayload( id_tag_info={om.status.value: AuthorizationStatus.accepted.value}, transaction_id=self._transactionId, @@ -776,6 +793,7 @@ def on_stop_transaction(self, meter_stop, timestamp, transaction_id, **kwargs): self._metrics[Measurand.power_active_import.value] = 0 if Measurand.power_reactive_import.value in self._metrics: self._metrics[Measurand.power_reactive_import.value] = 0 + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.StopTransactionPayload( id_tag_info={om.status.value: AuthorizationStatus.accepted.value} ) @@ -791,7 +809,7 @@ def on_heartbeat(self, **kwargs): """Handle a Heartbeat.""" now = datetime.now(tz=timezone.utc).isoformat() self._metrics[cstat.heartbeat.value] = now - self._units[cstat.heartbeat.value] = "time" + self.hass.async_create_task(self.central.update(self.central.cpid)) return call_result.HeartbeatPayload(current_time=now) def get_metric(self, measurand: str): diff --git a/custom_components/ocpp/sensor.py b/custom_components/ocpp/sensor.py index cddff867..3c0e0528 100644 --- a/custom_components/ocpp/sensor.py +++ b/custom_components/ocpp/sensor.py @@ -102,4 +102,4 @@ def extra_state_attributes(self): def update(self): """Get the latest data and update the states.""" - pass + self._state = self.central_system.get_metric(self.cp_id, self.metric) From 6def8028632207ec033e39bfb5d802d6bebff349 Mon Sep 17 00:00:00 2001 From: drc38 Date: Sun, 18 Jul 2021 21:50:04 +1200 Subject: [PATCH 16/17] ocpp: create task to update entity --- custom_components/ocpp/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/ocpp/api.py b/custom_components/ocpp/api.py index 7bdb8d4f..646a44eb 100644 --- a/custom_components/ocpp/api.py +++ b/custom_components/ocpp/api.py @@ -206,7 +206,9 @@ async def update(self, cp_id: str): for ent in entity_registry.async_entries_for_device(er, dev.id): if SENSOR in ent.entity_id: # _LOGGER.info("Entity id: %s updating", ent.entity_id) - entity_component.async_update_entity(self.hass, ent.entity_id) + self.hass.async_create_task( + entity_component.async_update_entity(self.hass, ent.entity_id) + ) def device_info(self): """Return device information.""" From 1c65e14c973257de065bb805d29059c9e58e227f Mon Sep 17 00:00:00 2001 From: drc38 Date: Sun, 18 Jul 2021 21:57:07 +1200 Subject: [PATCH 17/17] ocpp: change to async update --- custom_components/ocpp/sensor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/custom_components/ocpp/sensor.py b/custom_components/ocpp/sensor.py index 98b2fec9..49fad05d 100644 --- a/custom_components/ocpp/sensor.py +++ b/custom_components/ocpp/sensor.py @@ -100,7 +100,6 @@ def extra_state_attributes(self): "integration": DOMAIN, } - async def update(self): + async def async_update(self): """Get the latest data and update the states.""" self._state = self.central_system.get_metric(self.cp_id, self.metric) -