-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add base entity to Peblar Rocksolid EV Chargers integration (#133794)
- Loading branch information
Showing
14 changed files
with
111 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Base entity for the Peblar integration.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from homeassistant.const import CONF_HOST | ||
from homeassistant.helpers import device_registry as dr | ||
from homeassistant.helpers.device_registry import DeviceInfo | ||
from homeassistant.helpers.entity import EntityDescription | ||
from homeassistant.helpers.update_coordinator import ( | ||
CoordinatorEntity, | ||
DataUpdateCoordinator, | ||
) | ||
|
||
from .const import DOMAIN | ||
from .coordinator import PeblarConfigEntry | ||
|
||
|
||
class PeblarEntity[_DataUpdateCoordinatorT: DataUpdateCoordinator[Any]]( | ||
CoordinatorEntity[_DataUpdateCoordinatorT] | ||
): | ||
"""Defines a Peblar entity.""" | ||
|
||
_attr_has_entity_name = True | ||
|
||
def __init__( | ||
self, | ||
*, | ||
entry: PeblarConfigEntry, | ||
coordinator: _DataUpdateCoordinatorT, | ||
description: EntityDescription, | ||
) -> None: | ||
"""Initialize the Peblar entity.""" | ||
super().__init__(coordinator=coordinator) | ||
self.entity_description = description | ||
self._attr_unique_id = f"{entry.unique_id}_{description.key}" | ||
|
||
system_information = entry.runtime_data.system_information | ||
self._attr_device_info = DeviceInfo( | ||
configuration_url=f"http://{entry.data[CONF_HOST]}", | ||
connections={ | ||
(dr.CONNECTION_NETWORK_MAC, system_information.ethernet_mac_address), | ||
(dr.CONNECTION_NETWORK_MAC, system_information.wlan_mac_address), | ||
}, | ||
identifiers={ | ||
(DOMAIN, entry.runtime_data.system_information.product_serial_number) | ||
}, | ||
manufacturer=system_information.product_vendor_name, | ||
model=system_information.product_model_name, | ||
model_id=system_information.product_number, | ||
name="Peblar EV Charger", | ||
serial_number=system_information.product_serial_number, | ||
sw_version=entry.runtime_data.version_coordinator.data.current.firmware, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.