msavazzi
(Massimo Savazzi)
September 19, 2022, 2:20pm
1
I have several sonoff switch with 3 gang each.
The issue I have is that the friendly name of the entity derived from either the sonoff original component or the sonoff lan component is not with the gang definition:
Entity ID
Name
switch.sonoff_1000fxxxxx_1
0.08
switch.sonoff_1000fxxxxx_2
0.08
switch.sonoff_1000fxxxxx_3
0.08
I need
Entity ID
Name
switch.sonoff_1000fxxxxx_1
0.08_1
switch.sonoff_1000fxxxxx_2
0.08_2
switch.sonoff_1000fxxxxx_3
0.08_3
How can I rename them authomatically?
msavazzi
(Massimo Savazzi)
September 20, 2022, 4:36pm
2
Here is the solution… but I cannot contribute it via Git, I get an error
anyway here is the line to change self.attr_name = f"{device[‘name’]} {self.uid}"
in entity.py
if self.uid:
self._attr_unique_id = f"{device['deviceid']}_{self.uid}"
if not self.uid.isdigit():
self._attr_entity_category = ENTITY_CATEGORIES.get(self.uid)
self._attr_icon = ICONS.get(self.uid)
s = NAMES.get(self.uid) or self.uid.title().replace("_", " ")
self._attr_name = f"{device['name']} {s}"
else:
self._attr_name = f"{device['name']}_{self.uid}"
else:
self._attr_name = device["name"]
self._attr_unique_id = device["deviceid"]