mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Tweaks to Tuya base entity (#57526)
This commit is contained in:
parent
d90d804260
commit
c943677675
@ -6,7 +6,7 @@ from typing import Any
|
|||||||
from tuya_iot import TuyaDevice, TuyaDeviceManager
|
from tuya_iot import TuyaDevice, TuyaDeviceManager
|
||||||
|
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||||
|
|
||||||
from .const import DOMAIN, TUYA_HA_SIGNAL_UPDATE_ENTITY
|
from .const import DOMAIN, TUYA_HA_SIGNAL_UPDATE_ENTITY
|
||||||
|
|
||||||
@ -28,21 +28,21 @@ class TuyaHaEntity(Entity):
|
|||||||
return self.tuya_device.name
|
return self.tuya_device.name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self) -> DeviceInfo:
|
||||||
"""Return a device description for device registry."""
|
"""Return a device description for device registry."""
|
||||||
return {
|
return DeviceInfo(
|
||||||
"identifiers": {(DOMAIN, f"{self.tuya_device.id}")},
|
identifiers={(DOMAIN, self.tuya_device.id)},
|
||||||
"manufacturer": "Tuya",
|
manufacturer="Tuya",
|
||||||
"name": self.tuya_device.name,
|
name=self.tuya_device.name,
|
||||||
"model": self.tuya_device.product_name,
|
model=self.tuya_device.product_name,
|
||||||
}
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return if the device is available."""
|
"""Return if the device is available."""
|
||||||
return self.tuya_device.online
|
return self.tuya_device.online
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Call when entity is added to hass."""
|
"""Call when entity is added to hass."""
|
||||||
self.async_on_remove(
|
self.async_on_remove(
|
||||||
async_dispatcher_connect(
|
async_dispatcher_connect(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user