From 55cd1ffb7c780c032153ca180c27eb5cf7f1c973 Mon Sep 17 00:00:00 2001 From: Shay Levy Date: Mon, 8 Nov 2021 01:29:29 +0200 Subject: [PATCH] Revert "Use DeviceInfo in shelly (#58520)" (#59315) This reverts commit df6351f86b50451c7ecd8e70cfb5bbc97829cc73. --- homeassistant/components/shelly/entity.py | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index f8383ccd297..5df87b0531c 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -282,9 +282,6 @@ class ShellyBlockEntity(entity.Entity): 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: @@ -296,6 +293,13 @@ class ShellyBlockEntity(entity.Entity): """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.""" @@ -344,9 +348,9 @@ class ShellyRpcEntity(entity.Entity): 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) @@ -488,15 +492,19 @@ class ShellyRestAttributeEntity(update_coordinator.CoordinatorEntity): 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."""