فهرست منبع

fix(novadigital_midpanel8_controller): use translations

- fix lint issues in media_player
   - define _attr as global before use
   - directly set fixed attribute instead of through setattr
Jason Rumney 10 ساعت پیش
والد
کامیت
fc8cf853ff

+ 1 - 1
custom_components/tuya_local/devices/novadigital_midpanel8_controller.yaml

@@ -543,7 +543,7 @@ entities:
         optional: true
         name: switch
   - entity: event
-    name: Notification
+    translation_key: notification
     dps:
       - id: 212
         type: utf16b64

+ 6 - 5
custom_components/tuya_local/media_player.py

@@ -32,6 +32,11 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
     )
 
 
+def _attr(dp):
+    """Return the attribute name for a given datapoint."""
+    return f"_attr_{dp.name}"
+
+
 class TuyaLocalMediaPlayer(TuyaLocalEntity, MediaPlayerEntity):
     """Representation of a Tuya Local media player device."""
 
@@ -279,8 +284,4 @@ class TuyaLocalMediaPlayer(TuyaLocalEntity, MediaPlayerEntity):
             if d in self._metadata:
                 setattr(self, _attr(self._metadata[d]), v)
                 if self._metadata[d].name == "media_position":
-                    setattr(self, "_attr_media_position_updated_at", utcnow())
-
-    def _attr(dp):
-        """Return the attribute name for a given datapoint."""
-        return f"_attr_{dp.name}"
+                    self._attr_media_position_updated_at = utcnow()