Skip to content

Commit eac2ffc

Browse files
authored
Merge pull request #11 from drc38/push-updates
Push updates
2 parents c399ab7 + 1c65e14 commit eac2ffc

File tree

5 files changed

+47
-16
lines changed

5 files changed

+47
-16
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [lbbrhzn, drc38]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![OCPP](https://github.com/home-assistant/brands/raw/master/custom_integrations/ocpp/icon.png)
22

3-
This is a home assistant integration for chargers that support the Open Charge Point Protocol.
3+
This is a Home Assistant integration for Electric Vehicle chargers that support the Open Charge Point Protocol.
44

55
* based on the [Python OCPP Package](https://github.com/mobilityhouse/ocpp).
66
* [HACS](https://hacs.xyz/) compatible repository
@@ -33,12 +33,17 @@ This is a home assistant integration for chargers that support the Open Charge P
3333

3434
## Supported devices
3535

36-
The following devices are supported :
37-
OCPP 1.6 compatible devices
36+
All OCPP 1.6j compatible devices should be supported, but not every device offers the same level of functionality. So far, we've tried:
3837

38+
- [Wallbox Pulsar](https://wallbox.com/en_uk/wallbox-pulsar)
39+
- [EVLink Wallbox Plus](https://www.se.com/ww/en/product/EVH3S22P0CK/evlink-wallbox-plus---t2-attached-cable---3-phase---32a-22kw/)
40+
- [Evnex E Series & X Series Charging Stations](https://www.evnex.com/)
41+
- [ABB Terra AC-W11-G5-R-0](https://new.abb.com/products/6AGC082156/tac-w11-g5-r-0)
3942

40-
## Development
41-
### Debugging
43+
## Devices with known issues
44+
- [EVBox Elvi](https://evbox.com/en/products/home-chargers/elvi?language=en) appears to require a secure connection, which we do not support (yet).
45+
46+
## Debugging
4247

4348
To enable debug logging for this integration and related libraries you
4449
can control this in your Home Assistant `configuration.yaml`
@@ -54,4 +59,9 @@ logger:
5459

5560
After a restart detailed log entries will appear in `/config/home-assistant.log`.
5661

62+
## Support
63+
**💡 Tip:** If you like this project consider buying me a cocktail 🍹:
5764

65+
<a href="https://www.buymeacoffee.com/lbbrhzn" target="_blank">
66+
<img src="https://cdn.buymeacoffee.com/buttons/default-black.png" alt="Buy Me A Coffee" width="150px">
67+
</a>

custom_components/ocpp/api.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from homeassistant.config_entries import ConfigEntry
99
from homeassistant.const import TIME_MINUTES
1010
from homeassistant.core import HomeAssistant
11-
from homeassistant.helpers import device_registry, entity_registry
11+
from homeassistant.helpers import device_registry, entity_component, entity_registry
12+
1213
import voluptuous as vol
1314
import websockets
1415

@@ -202,9 +203,14 @@ async def update(self, cp_id: str):
202203
dr = device_registry.async_get(self.hass)
203204
identifiers = {(DOMAIN, cp_id)}
204205
dev = dr.async_get_device(identifiers)
205-
for ent in entity_registry.async_entries_for_device(er, dev):
206-
if ent.platform == SENSOR:
207-
self.hass.async_create_task(ent.update())
206+
# _LOGGER.info("Device id: %s updating", dev.name)
207+
for ent in entity_registry.async_entries_for_device(er, dev.id):
208+
if SENSOR in ent.entity_id:
209+
# _LOGGER.info("Entity id: %s updating", ent.entity_id)
210+
self.hass.async_create_task(
211+
entity_component.async_update_entity(self.hass, ent.entity_id)
212+
)
213+
208214

209215
def device_info(self):
210216
"""Return device information."""
@@ -646,7 +652,7 @@ async def async_update_device_info(self, boot_info: dict):
646652

647653
_LOGGER.debug("Updating device info %s: %s", self.central.cpid, boot_info)
648654

649-
dr = await device_registry.async_get_registry(self.hass)
655+
dr = device_registry.async_get(self.hass)
650656

651657
serial = boot_info.get(om.charge_point_serial_number.name, None)
652658

@@ -723,7 +729,7 @@ def on_boot_notification(self, **kwargs):
723729
)
724730

725731
asyncio.create_task(self.async_update_device_info(kwargs))
726-
732+
self.hass.async_create_task(self.central.update(self.central.cpid))
727733
return call_result.BootNotificationPayload(
728734
current_time=datetime.now(tz=timezone.utc).isoformat(),
729735
interval=30,
@@ -752,6 +758,7 @@ def on_status_notification(self, connector_id, error_code, status, **kwargs):
752758
def on_firmware_status(self, status, **kwargs):
753759
"""Handle firmware status notification."""
754760
self._metrics[cstat.firmware_status.value] = status
761+
self.hass.async_create_task(self.central.update(self.central.cpid))
755762
return call_result.FirmwareStatusNotificationPayload()
756763

757764
@on(Action.Authorize)
@@ -768,6 +775,7 @@ def on_start_transaction(self, connector_id, id_tag, meter_start, **kwargs):
768775
self._metrics[cstat.stop_reason.value] = ""
769776
self._metrics[csess.transaction_id.value] = self._transactionId
770777
self._metrics[csess.meter_start.value] = int(meter_start) / 1000
778+
self.hass.async_create_task(self.central.update(self.central.cpid))
771779
return call_result.StartTransactionPayload(
772780
id_tag_info={om.status.value: AuthorizationStatus.accepted.value},
773781
transaction_id=self._transactionId,
@@ -789,6 +797,7 @@ def on_stop_transaction(self, meter_stop, timestamp, transaction_id, **kwargs):
789797
self._metrics[Measurand.power_active_import.value] = 0
790798
if Measurand.power_reactive_import.value in self._metrics:
791799
self._metrics[Measurand.power_reactive_import.value] = 0
800+
self.hass.async_create_task(self.central.update(self.central.cpid))
792801
return call_result.StopTransactionPayload(
793802
id_tag_info={om.status.value: AuthorizationStatus.accepted.value}
794803
)
@@ -804,7 +813,7 @@ def on_heartbeat(self, **kwargs):
804813
"""Handle a Heartbeat."""
805814
now = datetime.now(tz=timezone.utc).isoformat()
806815
self._metrics[cstat.heartbeat.value] = now
807-
self._units[cstat.heartbeat.value] = "time"
816+
self.hass.async_create_task(self.central.update(self.central.cpid))
808817
return call_result.HeartbeatPayload(current_time=now)
809818

810819
def get_metric(self, measurand: str):

custom_components/ocpp/sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,6 @@ def extra_state_attributes(self):
100100
"integration": DOMAIN,
101101
}
102102

103-
async def update(self):
103+
async def async_update(self):
104104
"""Get the latest data and update the states."""
105-
await self.async_write_ha_state()
105+
self._state = self.central_system.get_metric(self.cp_id, self.metric)

hacs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "ocpp",
2+
"name": "Open Charge Point Protocol (OCPP)",
33
"content_in_root": false,
44
"domains": [
55
"sensor"
66
],
77
"homeassistant": "2021.6.6",
88
"iot_class": "Local Push",
99
"render_readme": true
10-
}
10+
}

0 commit comments

Comments
 (0)