mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use DeviceInfo in shelly (#58520)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c1dc2bbf28
commit
df6351f86b
@ -282,6 +282,9 @@ class ShellyBlockEntity(entity.Entity):
|
|||||||
self.wrapper = wrapper
|
self.wrapper = wrapper
|
||||||
self.block = block
|
self.block = block
|
||||||
self._name = get_block_entity_name(wrapper.device, block)
|
self._name = get_block_entity_name(wrapper.device, block)
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
@ -293,13 +296,6 @@ class ShellyBlockEntity(entity.Entity):
|
|||||||
"""If device should be polled."""
|
"""If device should be polled."""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Device info."""
|
|
||||||
return {
|
|
||||||
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Available."""
|
"""Available."""
|
||||||
@ -348,9 +344,9 @@ class ShellyRpcEntity(entity.Entity):
|
|||||||
self.wrapper = wrapper
|
self.wrapper = wrapper
|
||||||
self.key = key
|
self.key = key
|
||||||
self._attr_should_poll = False
|
self._attr_should_poll = False
|
||||||
self._attr_device_info = {
|
self._attr_device_info = DeviceInfo(
|
||||||
"connections": {(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
|
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
|
||||||
}
|
)
|
||||||
self._attr_unique_id = f"{wrapper.mac}-{key}"
|
self._attr_unique_id = f"{wrapper.mac}-{key}"
|
||||||
self._attr_name = get_rpc_entity_name(wrapper.device, key)
|
self._attr_name = get_rpc_entity_name(wrapper.device, key)
|
||||||
|
|
||||||
@ -494,19 +490,15 @@ class ShellyRestAttributeEntity(update_coordinator.CoordinatorEntity):
|
|||||||
self.description = description
|
self.description = description
|
||||||
self._name = get_block_entity_name(wrapper.device, None, self.description.name)
|
self._name = get_block_entity_name(wrapper.device, None, self.description.name)
|
||||||
self._last_value = None
|
self._last_value = None
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Name of sensor."""
|
"""Name of sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self) -> DeviceInfo:
|
|
||||||
"""Device info."""
|
|
||||||
return {
|
|
||||||
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
|
|
||||||
}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def entity_registry_enabled_default(self) -> bool:
|
def entity_registry_enabled_default(self) -> bool:
|
||||||
"""Return if it should be enabled by default."""
|
"""Return if it should be enabled by default."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user