Przeglądaj źródła

Implement HA 2022.8 naming changes

Issue #196
Jason Rumney 3 lat temu
rodzic
commit
fb8c47e39a

+ 4 - 8
custom_components/tuya_local/helpers/device_config.py

@@ -174,17 +174,13 @@ class TuyaEntityConfig:
         self._config = config
         self._is_primary = primary
 
-    def name(self, base_name):
+    def name(self):
         """The friendly name for this entity."""
-        own_name = self._config.get("name")
-        if own_name is None:
-            return base_name
-        else:
-            return base_name + " " + own_name
+        return self._config.get("name")
 
     def unique_id(self, device_uid):
         """Return a suitable unique_id for this entity."""
-        own_name = self._config.get("name")
+        own_name = self.name()
         if own_name:
             return f"{device_uid}-{slugify(own_name)}"
         else:
@@ -218,7 +214,7 @@ class TuyaEntityConfig:
     @property
     def config_id(self):
         """The identifier for this entity in the config."""
-        own_name = self._config.get("name")
+        own_name = self.name()
         if own_name:
             return f"{self.entity}_{slugify(own_name)}"
 

+ 5 - 1
custom_components/tuya_local/helpers/mixin.py

@@ -38,7 +38,11 @@ class TuyaLocalEntity:
     @property
     def name(self):
         """Return the name for the UI."""
-        return self._config.name(self._device.name)
+        return self._config.name()
+
+    @property
+    def has_entity_name(self):
+        return True
 
     @property
     def unique_id(self):

+ 1 - 1
hacs.json

@@ -1,5 +1,5 @@
 {
   "name": "Tuya Local",
   "render_readme": true,
-  "homeassistant": "2022.7.0"
+  "homeassistant": "2022.8.0"
 }

+ 2 - 2
tests/devices/base_device_tests.py

@@ -62,10 +62,10 @@ class TuyaDeviceTestCase(IsolatedAsyncioTestCase):
         self.entities[self.primary_entity] = self.create_entity(cfg.primary_entity)
 
         self.names = {}
-        self.names[cfg.primary_entity.config_id] = cfg.primary_entity.name(cfg.name)
+        self.names[cfg.primary_entity.config_id] = cfg.primary_entity.name()
         for e in cfg.secondary_entities():
             self.entities[e.config_id] = self.create_entity(e)
-            self.names[e.config_id] = e.name(cfg.name)
+            self.names[e.config_id] = e.name()
 
     def create_entity(self, config):
         """Create an entity to match the config"""