Skip to content

Commit

Permalink
Remove suffix logic (broken due to translation support)
Browse files Browse the repository at this point in the history
Fixes #558
  • Loading branch information
wlcrs committed Dec 19, 2023
1 parent 87135da commit 7b65137
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 42 deletions.
6 changes: 1 addition & 5 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,4 @@ async def _create_configuration_update_coordinator(
class HuaweiSolarEntity(Entity):
"""Huawei Solar Entity."""

_attr_has_entity_name = True

def add_name_suffix(self, suffix) -> None:
"""Add a suffix after the current entity name."""
self._attr_name = f"{self.name}{suffix}"
_attr_has_entity_name = True
9 changes: 0 additions & 9 deletions number.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ async def async_setup_entry(
DATA_CONFIGURATION_UPDATE_COORDINATORS
] # type: list[HuaweiSolarConfigurationUpdateCoordinator]

# When more than one inverter is present, then we suffix all sensors with '#1', '#2', ...
# The order for these suffixes is the order in which the user entered the slave-ids.
must_append_inverter_suffix = len(update_coordinators) > 1

entities_to_add: list[NumberEntity] = []
for idx, (update_coordinator, configuration_update_coordinator) in enumerate(
zip(update_coordinators, configuration_update_coordinators)
Expand Down Expand Up @@ -183,11 +179,6 @@ async def async_setup_entry(
bridge.slave_id,
)

# Add suffix if multiple inverters are present
if must_append_inverter_suffix:
for entity in slave_entities:
entity.add_name_suffix(f" #{idx+1}")

entities_to_add.extend(slave_entities)

async_add_entities(entities_to_add)
Expand Down
9 changes: 0 additions & 9 deletions select.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ async def async_setup_entry(
HuaweiSolarConfigurationUpdateCoordinator
] = hass.data[DOMAIN][entry.entry_id][DATA_CONFIGURATION_UPDATE_COORDINATORS]

# When more than one inverter is present, then we suffix all sensors with '#1', '#2', ...
# The order for these suffixes is the order in which the user entered the slave-ids.
must_append_inverter_suffix = len(update_coordinators) > 1

entities_to_add: list[SelectEntity] = []
for idx, (update_coordinator, configuration_update_coordinator) in enumerate(
zip(update_coordinators, configuration_update_coordinators)
Expand Down Expand Up @@ -134,11 +130,6 @@ async def async_setup_entry(
bridge.slave_id,
)

# Add suffix if multiple inverters are present
if must_append_inverter_suffix:
for entity in slave_entities:
entity.add_name_suffix(f" #{idx+1}")

entities_to_add.extend(slave_entities)

async_add_entities(entities_to_add)
Expand Down
9 changes: 0 additions & 9 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,6 @@ async def async_setup_entry(
DATA_CONFIGURATION_UPDATE_COORDINATORS
] # type: list[HuaweiSolarConfigurationUpdateCoordinator]

# When more than one inverter is present, then we suffix all sensors with '#1', '#2', ...
# The order for these suffixes is the order in which the user entered the slave-ids.
must_append_inverter_suffix = len(update_coordinators) > 1

entities_to_add: list[SensorEntity] = []
for idx, (update_coordinator, configuration_update_coordinator) in enumerate(
zip_longest(update_coordinators, configuration_update_coordinators)
Expand Down Expand Up @@ -729,11 +725,6 @@ async def async_setup_entry(
)
)

# Add suffix if multiple inverters are present
if must_append_inverter_suffix:
for entity in slave_entities:
entity.add_name_suffix(f" #{idx+1}")

entities_to_add.extend(slave_entities)

optimizer_update_coordinators = hass.data[DOMAIN][entry.entry_id][
Expand Down
11 changes: 1 addition & 10 deletions switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ async def async_setup_entry(
configuration_update_coordinators = hass.data[DOMAIN][entry.entry_id][
DATA_CONFIGURATION_UPDATE_COORDINATORS
] # type: list[HuaweiSolarConfigurationUpdateCoordinator]

# When more than one inverter is present, then we suffix all sensors with '#1', '#2', ...
# The order for these suffixes is the order in which the user entered the slave-ids.
must_append_inverter_suffix = len(update_coordinators) > 1


entities_to_add: list[SwitchEntity] = []
for idx, (update_coordinator, configuration_update_coordinator) in enumerate(
zip(update_coordinators, configuration_update_coordinators)
Expand Down Expand Up @@ -115,11 +111,6 @@ async def async_setup_entry(
bridge.slave_id,
)

# Add suffix if multiple inverters are present
if must_append_inverter_suffix:
for entity in slave_entities:
entity.add_name_suffix(f" #{idx+1}")

entities_to_add.extend(slave_entities)

async_add_entities(entities_to_add)
Expand Down

0 comments on commit 7b65137

Please sign in to comment.