소스 검색

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 5 달 전
부모
커밋
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"""