Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions homeassistant/components/shelly/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ def __init__(self, wrapper: BlockDeviceWrapper, block: Block) -> None:
self.wrapper = wrapper
self.block = block
self._name = get_block_entity_name(wrapper.device, block)
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)

@property
def name(self) -> str:
Expand All @@ -296,6 +293,13 @@ def should_poll(self) -> bool:
"""If device should be polled."""
return False

@property
def device_info(self) -> DeviceInfo:
"""Device info."""
return {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
}

@property
def available(self) -> bool:
"""Available."""
Expand Down Expand Up @@ -344,9 +348,9 @@ def __init__(self, wrapper: RpcDeviceWrapper, key: str) -> None:
self.wrapper = wrapper
self.key = key
self._attr_should_poll = False
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)
self._attr_device_info = {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
}
self._attr_unique_id = f"{wrapper.mac}-{key}"
self._attr_name = get_rpc_entity_name(wrapper.device, key)

Expand Down Expand Up @@ -488,15 +492,19 @@ def __init__(
self.description = description
self._name = get_block_entity_name(wrapper.device, None, self.description.name)
self._last_value = None
self._attr_device_info = DeviceInfo(
connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)}
)

@property
def name(self) -> str:
"""Name of sensor."""
return self._name

@property
def device_info(self) -> DeviceInfo:
"""Device info."""
return {
"connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)}
}

@property
def entity_registry_enabled_default(self) -> bool:
"""Return if it should be enabled by default."""
Expand Down