瀏覽代碼

workaround (valve): force use of HA provided translations

HA defines translated names for "water" and "gas" valves, but it does not
make use of them.
Tell HA to use them for our valves.

PR #4126
Jason Rumney 1 月之前
父節點
當前提交
ddcdb1f0ff
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      custom_components/tuya_local/valve.py

+ 8 - 0
custom_components/tuya_local/valve.py

@@ -51,6 +51,14 @@ class TuyaLocalValve(TuyaLocalEntity, ValveEntity):
             ):
             ):
                 self._attr_supported_features |= ValveEntityFeature.SET_POSITION
                 self._attr_supported_features |= ValveEntityFeature.SET_POSITION
 
 
+    # HA defines translated names for valve classes, but does not use them
+    def _default_to_device_class_name(self) -> bool:
+        """Return True if an unnamed entity should be named by its device class.
+
+        For valves we make this True if the entity has a device class.
+        """
+        return self.device_class is not None
+
     @property
     @property
     def device_class(self):
     def device_class(self):
         """Return the class of this device"""
         """Return the class of this device"""