Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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']
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -33,12 +33,17 @@ 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 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/)
- [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)

## Development
### Debugging
## 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
can control this in your Home Assistant `configuration.yaml`
Expand All @@ -54,4 +59,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 🍹:

<a href="https://www.buymeacoffee.com/lbbrhzn" target="_blank">
<img src="https://cdn.buymeacoffee.com/buttons/default-black.png" alt="Buy Me A Coffee" width="150px">
</a>
23 changes: 16 additions & 7 deletions custom_components/ocpp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TIME_MINUTES
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry, entity_registry
from homeassistant.helpers import device_registry, entity_component, entity_registry

import voluptuous as vol
import websockets

Expand Down Expand Up @@ -202,9 +203,14 @@ async def update(self, cp_id: str):
dr = device_registry.async_get(self.hass)
identifiers = {(DOMAIN, cp_id)}
dev = dr.async_get_device(identifiers)
for ent in entity_registry.async_entries_for_device(er, dev):
if ent.platform == SENSOR:
self.hass.async_create_task(ent.update())
# _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)
self.hass.async_create_task(
entity_component.async_update_entity(self.hass, ent.entity_id)
)


def device_info(self):
"""Return device information."""
Expand Down Expand Up @@ -646,7 +652,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)

Expand Down Expand Up @@ -723,7 +729,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,
Expand Down Expand Up @@ -752,6 +758,7 @@ def on_status_notification(self, connector_id, error_code, status, **kwargs):
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)
Expand All @@ -768,6 +775,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,
Expand All @@ -789,6 +797,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}
)
Expand All @@ -804,7 +813,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):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ocpp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +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."""
await self.async_write_ha_state()
self._state = self.central_system.get_metric(self.cp_id, self.metric)
4 changes: 2 additions & 2 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "ocpp",
"name": "Open Charge Point Protocol (OCPP)",
"content_in_root": false,
"domains": [
"sensor"
],
"homeassistant": "2021.6.6",
"iot_class": "Local Push",
"render_readme": true
}
}