فهرست منبع

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 3 ماه پیش
والد
کامیت
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
 
+    # 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
     def device_class(self):
         """Return the class of this device"""