From b31ccf52bd06d6fe770f7eecfb0b4b2f071f0caf Mon Sep 17 00:00:00 2001 From: drc38 <20024196+drc38@users.noreply.github.com> Date: Sat, 5 Nov 2022 23:41:12 +1300 Subject: [PATCH] update naming (#666) --- custom_components/ocpp/number.py | 6 ++---- custom_components/ocpp/sensor.py | 6 ++---- custom_components/ocpp/switch.py | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/custom_components/ocpp/number.py b/custom_components/ocpp/number.py index dad44df0..5a978173 100644 --- a/custom_components/ocpp/number.py +++ b/custom_components/ocpp/number.py @@ -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__( @@ -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), diff --git a/custom_components/ocpp/sensor.py b/custom_components/ocpp/sensor.py index cfb41c22..94b20c3e 100644 --- a/custom_components/ocpp/sensor.py +++ b/custom_components/ocpp/sensor.py @@ -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__( @@ -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 diff --git a/custom_components/ocpp/switch.py b/custom_components/ocpp/switch.py index 1e188205..c6a48e14 100644 --- a/custom_components/ocpp/switch.py +++ b/custom_components/ocpp/switch.py @@ -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__( @@ -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: