Use DeviceInfo on zwave (#58183)
Co-authored-by: epenet <epenet@users.noreply.github.com>pull/58181/head
parent
9990385926
commit
0b302ab141
|
@ -12,6 +12,7 @@ from homeassistant import config_entries
|
|||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_NAME,
|
||||
ATTR_VIA_DEVICE,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
|
@ -25,7 +26,7 @@ from homeassistant.helpers.dispatcher import (
|
|||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
)
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
from homeassistant.helpers.entity import DeviceInfo, generate_entity_id
|
||||
from homeassistant.helpers.entity_component import DEFAULT_SCAN_INTERVAL
|
||||
from homeassistant.helpers.entity_platform import EntityPlatform
|
||||
from homeassistant.helpers.entity_registry import (
|
||||
|
@ -1301,21 +1302,21 @@ class ZWaveDeviceEntity(ZWaveBaseEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information."""
|
||||
identifier, name = node_device_id_and_name(
|
||||
self.node, self.values.primary.instance
|
||||
)
|
||||
info = {
|
||||
"name": name,
|
||||
"identifiers": {identifier},
|
||||
"manufacturer": self.node.manufacturer_name,
|
||||
"model": self.node.product_name,
|
||||
}
|
||||
info = DeviceInfo(
|
||||
name=name,
|
||||
identifiers={identifier},
|
||||
manufacturer=self.node.manufacturer_name,
|
||||
model=self.node.product_name,
|
||||
)
|
||||
if self.values.primary.instance > 1:
|
||||
info["via_device"] = (DOMAIN, self.node_id)
|
||||
info[ATTR_VIA_DEVICE] = (DOMAIN, self.node_id)
|
||||
elif self.node_id > 1:
|
||||
info["via_device"] = (DOMAIN, 1)
|
||||
info[ATTR_VIA_DEVICE] = (DOMAIN, 1)
|
||||
return info
|
||||
|
||||
@property
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
# pylint: disable=import-outside-toplevel
|
||||
from itertools import count
|
||||
|
||||
from homeassistant.const import ATTR_BATTERY_LEVEL, ATTR_ENTITY_ID, ATTR_WAKEUP
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL,
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_VIA_DEVICE,
|
||||
ATTR_WAKEUP,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.device_registry import async_get_registry as get_dev_reg
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.entity_registry import async_get_registry
|
||||
|
||||
from .const import (
|
||||
|
@ -151,17 +156,17 @@ class ZWaveNodeEntity(ZWaveBaseEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information."""
|
||||
identifier, name = node_device_id_and_name(self.node)
|
||||
info = {
|
||||
"identifiers": {identifier},
|
||||
"manufacturer": self.node.manufacturer_name,
|
||||
"model": self.node.product_name,
|
||||
"name": name,
|
||||
}
|
||||
info = DeviceInfo(
|
||||
identifiers={identifier},
|
||||
manufacturer=self.node.manufacturer_name,
|
||||
model=self.node.product_name,
|
||||
name=name,
|
||||
)
|
||||
if self.node_id > 1:
|
||||
info["via_device"] = (DOMAIN, 1)
|
||||
info[ATTR_VIA_DEVICE] = (DOMAIN, 1)
|
||||
return info
|
||||
|
||||
def maybe_update_application_version(self, value):
|
||||
|
|
|
@ -355,6 +355,7 @@ ATTR_MODE: Final = "mode"
|
|||
ATTR_MANUFACTURER: Final = "manufacturer"
|
||||
ATTR_MODEL: Final = "model"
|
||||
ATTR_SW_VERSION: Final = "sw_version"
|
||||
ATTR_VIA_DEVICE: Final = "via_device"
|
||||
|
||||
ATTR_BATTERY_CHARGING: Final = "battery_charging"
|
||||
ATTR_BATTERY_LEVEL: Final = "battery_level"
|
||||
|
|
Loading…
Reference in New Issue