Browse Source

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 tháng trước cách đây
mục cha
commit
ddcdb1f0ff
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  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"""