Skip to content

Commit

Permalink
update naming (lbbrhzn#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
drc38 authored Nov 5, 2022
1 parent 2706a82 commit b31ccf5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions custom_components/ocpp/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
class OcppNumber(RestoreNumber, NumberEntity):
"""Individual slider for setting charge rate."""

_attr_has_entity_name = True
entity_description: OcppNumberDescription

def __init__(
Expand All @@ -84,10 +85,7 @@ def __init__(
self._attr_unique_id = ".".join(
[NUMBER_DOMAIN, self.cp_id, self.entity_description.key]
)
self._attr_name = ".".join([self.cp_id, self.entity_description.name])
self.entity_id = (
NUMBER_DOMAIN + "." + "_".join([self.cp_id, self.entity_description.key])
)
self._attr_name = self.entity_description.name
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.cp_id)},
via_device=(DOMAIN, self.central_system.id),
Expand Down
6 changes: 2 additions & 4 deletions custom_components/ocpp/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
class ChargePointMetric(RestoreSensor, SensorEntity):
"""Individual sensor for charge point metrics."""

_attr_has_entity_name = True
entity_description: OcppSensorDescription

def __init__(
Expand All @@ -89,14 +90,11 @@ def __init__(
self._attr_unique_id = ".".join(
[DOMAIN, self.cp_id, self.entity_description.key, SENSOR_DOMAIN]
)
self._attr_name = ".".join([self.cp_id, self.entity_description.name])
self._attr_name = self.entity_description.name
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.cp_id)},
via_device=(DOMAIN, self.central_system.id),
)
self.entity_id = (
SENSOR_DOMAIN + "." + "_".join([self.cp_id, self.entity_description.key])
)
self._attr_icon = ICON
self._attr_native_unit_of_measurement = None

Expand Down
6 changes: 2 additions & 4 deletions custom_components/ocpp/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async def async_setup_entry(hass, entry, async_add_devices):
class ChargePointSwitch(SwitchEntity):
"""Individual switch for charge point."""

_attr_has_entity_name = True
entity_description: OcppSwitchDescription

def __init__(
Expand All @@ -92,14 +93,11 @@ def __init__(
self._attr_unique_id = ".".join(
[SWITCH_DOMAIN, DOMAIN, self.cp_id, self.entity_description.key]
)
self._attr_name = ".".join([self.cp_id, self.entity_description.name])
self._attr_name = self.entity_description.name
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.cp_id)},
via_device=(DOMAIN, self.central_system.id),
)
self.entity_id = (
SWITCH_DOMAIN + "." + "_".join([self.cp_id, self.entity_description.key])
)

@property
def available(self) -> bool:
Expand Down

0 comments on commit b31ccf5

Please sign in to comment.