Skip to content

v0.4.0

Choose a tag to compare

@turbo5000c turbo5000c released this 18 Jun 04:13
35e7ec8

What's Changed

Some weather-grouped entities were registering with duplicated office prefixes (e.g. sensor.noaa_ilm_weather_noaa_ilm_weather_visibility) when Home Assistant combined the device name with the entity name. This fix ensures all sensors follow the correct standardized entity ID format without duplication by using Home Assistant's _attr_has_entity_name = True pattern.
Entity ID Format Standards

Office-grouped sensors: sensor.noaa_[office_code]_[domain]_[entity_type]
    Examples: sensor.noaa_ilm_weather_humidity, sensor.noaa_sgx_surf_rip_current_risk, sensor.noaa_sgx_space_aurora_next_time
Global (hurricane) sensors: sensor.noaa_hurricane_[entity_type]
    Examples: sensor.noaa_hurricane_alerts, sensor.noaa_hurricane_activity

Root Cause

Home Assistant combines device names with entity names to create entity IDs. When sensors returned full names like NOAA ILM Weather Visibility, Home Assistant would combine that with the device name NOAA ILM Weather, resulting in duplicated prefixes: noaa_ilm_weather_noaa_ilm_weather_visibility.
Fix Approach

Added _attr_has_entity_name = True to all device-scoped sensor base classes and changed the name property to return local names only. Home Assistant then correctly combines the device name with the local entity name.
Changes

All office-grouped sensors now use _attr_has_entity_name = True with local-only names:
    sensors/forecasts.py: Names return "Extended Forecast", "Hourly Forecast"
    sensors/weather_observations.py: Names return "Temperature", "Humidity", "Wind Speed", etc.
    sensors/surf.py: Names return "Rip Current Risk", "Surf Height", "Water Temperature"
    sensors/weather_extra.py: Names return "Cloud Cover", "Radar Timestamp", "Forecast Discussion"
    sensors/alerts.py: Name returns "Active NWS Alerts"
    sensors/space_weather.py: Names return "Geomagnetic Storm", "Planetary K-index", "Aurora Next Time", etc.

Hurricane sensors updated:
    HurricaneAlertsSensor: Name returns "Alerts" (device: NOAA Hurricane → sensor.noaa_hurricane_alerts)
    HurricaneActivitySensor: Name returns "Activity" (device: NOAA Hurricane → sensor.noaa_hurricane_activity)

Removed suggested_object_id properties from all sensors - no longer needed with proper _attr_has_entity_name usage

Example

class WeatherObservationSensor(CoordinatorEntity):
_attr_has_entity_name = True # Tells HA to combine device + entity name

@property
def name(self):
    # Returns LOCAL name only - HA combines with device name
    return self._sensor_name  # e.g., "Visibility"

Device: "NOAA ILM Weather" + Entity: "Visibility"

-> sensor.noaa_ilm_weather_visibility ✓

Migration Note

The _attr_has_entity_name = True pattern affects how Home Assistant registers entities. This ensures:

New installs: Entities register with clean IDs from day one
Existing installs with broken IDs: Existing entities retain their broken ID until manually removed; new entities added afterwards will be created with clean IDs

Verification

✅ Flake8 compliance verified
✅ Python syntax validated
✅ No secrets detected
✅ _attr_has_entity_name = True applied to all device-scoped sensors
✅ Local-only names implemented across all sensor types
⚠️ Tests require updates to reflect new local name assertions (in progress)

Full Changelog: v0.3.7...v0.4.0