Просмотр исходного кода

light: friendly_name is a property.

Jason Rumney 4 лет назад
Родитель
Сommit
f18144db6c
1 измененных файлов с 5 добавлено и 10 удалено
  1. 5 10
      custom_components/tuya_local/generic/light.py

+ 5 - 10
custom_components/tuya_local/generic/light.py

@@ -38,6 +38,7 @@ class TuyaLocalLight(LightEntity):
         """Return the name of the light."""
         return self._device.name
 
+    @property
     def friendly_name(self):
         """Return the friendly name for this entity."""
         return self._config.name
@@ -63,27 +64,21 @@ class TuyaLocalLight(LightEntity):
     @property
     def is_on(self):
         """Return the current state."""
-        return self._switch_dps.map_from_dps(
-            self._device.get_property(self._switch_dps.id)
-        )
+        return self._switch_dps.get_value(self._device)
 
     @property
     def device_state_attributes(self):
         """Get additional attributes that the integration itself does not support."""
         attr = {}
         for a in self._attr_dps:
-            attr[a.name] = a.map_from_dps(self._device.get_property(a.id))
+            attr[a.name] = a.get_value(self._device)
         return attr
 
     async def async_turn_on(self):
-        await self._device.async_set_property(
-            self._switch_dps.id, self._switch_dps.map_to_dps(True)
-        )
+        await self._switch_dps.async_set_value(self._device, True)
 
     async def async_turn_off(self):
-        await self._device.async_set_property(
-            self._switch_dps.id, self._switch_dps.map_to_dps(False)
-        )
+        await self._switch_dps.async_set_value(self._device, False)
 
     async def async_toggle(self):
         dps_display_on = self.is_on