Renamed variables in Tuya (#57759)

This commit is contained in:
Franck Nijhof 2021-10-15 11:33:30 +02:00 committed by GitHub
parent b7c52d0485
commit b97d5a703c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 85 additions and 88 deletions

View file

@ -71,8 +71,8 @@ class TuyaEntity(Entity):
def __init__(self, device: TuyaDevice, device_manager: TuyaDeviceManager) -> None:
"""Init TuyaHaEntity."""
self._attr_unique_id = f"tuya.{device.id}"
self.tuya_device = device
self.tuya_device_manager = device_manager
self.device = device
self.device_manager = device_manager
@property
def name(self) -> str | None:
@ -81,37 +81,35 @@ class TuyaEntity(Entity):
hasattr(self, "entity_description")
and self.entity_description.name is not None
):
return f"{self.tuya_device.name} {self.entity_description.name}"
return self.tuya_device.name
return f"{self.device.name} {self.entity_description.name}"
return self.device.name
@property
def device_info(self) -> DeviceInfo:
"""Return a device description for device registry."""
return DeviceInfo(
identifiers={(DOMAIN, self.tuya_device.id)},
identifiers={(DOMAIN, self.device.id)},
manufacturer="Tuya",
name=self.tuya_device.name,
model=self.tuya_device.product_name,
name=self.device.name,
model=self.device.product_name,
)
@property
def available(self) -> bool:
"""Return if the device is available."""
return self.tuya_device.online
return self.device.online
async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{TUYA_HA_SIGNAL_UPDATE_ENTITY}_{self.tuya_device.id}",
f"{TUYA_HA_SIGNAL_UPDATE_ENTITY}_{self.device.id}",
self.async_write_ha_state,
)
)
def _send_command(self, commands: list[dict[str, Any]]) -> None:
"""Send command to the device."""
_LOGGER.debug(
"Sending commands for device %s: %s", self.tuya_device.id, commands
)
self.tuya_device_manager.send_commands(self.tuya_device.id, commands)
_LOGGER.debug("Sending commands for device %s: %s", self.device.id, commands)
self.device_manager.send_commands(self.device.id, commands)