diff --git a/homeassistant/components/whois/sensor.py b/homeassistant/components/whois/sensor.py index 48efaf7630d..68e77162a4f 100644 --- a/homeassistant/components/whois/sensor.py +++ b/homeassistant/components/whois/sensor.py @@ -79,7 +79,7 @@ SENSORS: tuple[WhoisSensorEntityDescription, ...] = ( ), WhoisSensorEntityDescription( key="days_until_expiration", - name="Days Until Expiration", + name="Days until expiration", icon="mdi:calendar-clock", native_unit_of_measurement=TIME_DAYS, value_fn=_days_until_expiration, @@ -93,7 +93,7 @@ SENSORS: tuple[WhoisSensorEntityDescription, ...] = ( ), WhoisSensorEntityDescription( key="last_updated", - name="Last Updated", + name="Last updated", device_class=SensorDeviceClass.TIMESTAMP, entity_category=EntityCategory.DIAGNOSTIC, value_fn=lambda domain: _ensure_timezone(domain.last_updated), @@ -156,6 +156,7 @@ class WhoisSensorEntity(CoordinatorEntity, SensorEntity): """Implementation of a WHOIS sensor.""" entity_description: WhoisSensorEntityDescription + _attr_has_entity_name = True def __init__( self, @@ -166,10 +167,10 @@ class WhoisSensorEntity(CoordinatorEntity, SensorEntity): """Initialize the sensor.""" super().__init__(coordinator=coordinator) self.entity_description = description - self._attr_name = f"{domain} {description.name}" self._attr_unique_id = f"{domain}_{description.key}" self._attr_device_info = DeviceInfo( identifiers={(DOMAIN, domain)}, + name=domain, entry_type=DeviceEntryType.SERVICE, ) self._domain = domain diff --git a/tests/components/whois/test_sensor.py b/tests/components/whois/test_sensor.py index 89b84dc5849..828a9242621 100644 --- a/tests/components/whois/test_sensor.py +++ b/tests/components/whois/test_sensor.py @@ -60,7 +60,7 @@ async def test_whois_sensors( assert state.state == "364" assert ( state.attributes.get(ATTR_FRIENDLY_NAME) - == "home-assistant.io Days Until Expiration" + == "home-assistant.io Days until expiration" ) assert state.attributes.get(ATTR_ICON) == "mdi:calendar-clock" assert ATTR_DEVICE_CLASS not in state.attributes @@ -83,7 +83,7 @@ async def test_whois_sensors( assert entry.unique_id == "home-assistant.io_last_updated" assert entry.entity_category == EntityCategory.DIAGNOSTIC assert state.state == "2021-12-31T23:00:00+00:00" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home-assistant.io Last Updated" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home-assistant.io Last updated" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP assert ATTR_ICON not in state.attributes @@ -137,9 +137,9 @@ async def test_whois_sensors( assert device_entry.configuration_url is None assert device_entry.entry_type == dr.DeviceEntryType.SERVICE assert device_entry.identifiers == {(DOMAIN, "home-assistant.io")} + assert device_entry.name == "home-assistant.io" assert device_entry.manufacturer is None assert device_entry.model is None - assert device_entry.name is None assert device_entry.sw_version is None @@ -159,7 +159,7 @@ async def test_whois_sensors_missing_some_attrs( assert entry.unique_id == "home-assistant.io_last_updated" assert entry.entity_category == EntityCategory.DIAGNOSTIC assert state.state == "2021-12-31T23:00:00+00:00" - assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home-assistant.io Last Updated" + assert state.attributes.get(ATTR_FRIENDLY_NAME) == "home-assistant.io Last updated" assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.TIMESTAMP assert ATTR_ICON not in state.attributes