Migrate DNSIP to new entity naming style (#75197)

This commit is contained in:
G Johansson 2022-07-15 11:07:39 +02:00 committed by GitHub
parent 06e905054e
commit 48f4b51a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,7 @@ class WanIpSensor(SensorEntity):
"""Implementation of a DNS IP sensor.""" """Implementation of a DNS IP sensor."""
_attr_icon = "mdi:web" _attr_icon = "mdi:web"
_attr_has_entity_name = True
def __init__( def __init__(
self, self,
@ -61,7 +62,7 @@ class WanIpSensor(SensorEntity):
ipv6: bool, ipv6: bool,
) -> None: ) -> None:
"""Initialize the DNS IP sensor.""" """Initialize the DNS IP sensor."""
self._attr_name = f"{name} IPv6" if ipv6 else name self._attr_name = "IPv6" if ipv6 else None
self._attr_unique_id = f"{hostname}_{ipv6}" self._attr_unique_id = f"{hostname}_{ipv6}"
self.hostname = hostname self.hostname = hostname
self.resolver = aiodns.DNSResolver() self.resolver = aiodns.DNSResolver()
@ -76,7 +77,7 @@ class WanIpSensor(SensorEntity):
identifiers={(DOMAIN, f"{hostname}_{ipv6}")}, identifiers={(DOMAIN, f"{hostname}_{ipv6}")},
manufacturer="DNS", manufacturer="DNS",
model=aiodns.__version__, model=aiodns.__version__,
name=hostname, name=name,
) )
async def async_update(self) -> None: async def async_update(self) -> None: