Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record Analytics Insights quality scale #133571

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

joostlek
Copy link
Member

Proposed change

Record Analytics Insights quality scale

Bronze

  • config-flow - Integration needs to be able to be set up via the UI
    • Uses data_description to give context to fields
    • Uses ConfigEntry.data and ConfigEntry.options correctly
  • test-before-configure - Test a connection in the config flow
    client = HomeassistantAnalyticsClient(
    session=async_get_clientsession(self.hass)
    )
    try:
    addons = await client.get_addons()
    integrations = await client.get_integrations()
    custom_integrations = await client.get_custom_integrations()
  • unique-config-entry - Don't allow the same device or service to be able to be set up twice
  • config-flow-test-coverage - Full test coverage for the config flow
homeassistant/components/analytics_insights/config_flow.py      52      0   100%
  • runtime-data - Use ConfigEntry.runtime_data to store runtime data
    @dataclass(frozen=True)
    class AnalyticsInsightsData:
    """Analytics data class."""
    coordinator: HomeassistantAnalyticsDataUpdateCoordinator
    names: dict[str, str]
    async def async_setup_entry(
    hass: HomeAssistant, entry: AnalyticsInsightsConfigEntry
    ) -> bool:
  • test-before-setup - Check during integration initialization if we are able to set it up correctly
    try:
    integrations = await client.get_integrations()
    except HomeassistantAnalyticsConnectionError as ex:
    raise ConfigEntryNotReady("Could not fetch integration list") from ex
  • appropriate-polling - If it's a polling integration, set an appropriate polling interval
    update_interval=timedelta(hours=12),
  • entity-unique-id - Entities have a unique ID
    self._attr_unique_id = entity_description.key
  • has-entity-name - Entities use has_entity_name = True
    _attr_has_entity_name = True
  • entity-event-setup - Entities event setup
  • dependency-transparency - Dependency transparency
    https://github.com/joostlek/python-homeassistant-analytics
  • action-setup - Service actions are registered in async_setup
  • common-modules - Place common patterns in common modules
    Coordinator -> coordinator.py
  • docs-high-level-description - The documentation includes a high-level description of the integration brand, product, or service
  • docs-installation-instructions - The documentation provides step-by-step installation instructions for the integration, including, if needed, prerequisites
  • docs-removal-instructions - The documentation provides removal instructions
  • docs-actions - The documentation describes the provided service actions that can be used
  • brands - Has branding assets available for the integration
    We have nice icon

Silver

  • config-entry-unloading - Support config entry unloading
    async def async_unload_entry(
    hass: HomeAssistant, entry: AnalyticsInsightsConfigEntry
    ) -> bool:
    """Unload a config entry."""
    return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
  • log-when-unavailable - If internet/device/service is unavailable, log once when unavailable and once when back connected
    Coordinator
  • entity-unavailable - Mark entity unavailable if appropriate
    Coordinator
  • action-exceptions - Service actions raise exceptions when encountering failures
  • reauthentication-flow - Reauthentication flow
  • parallel-updates - Set Parallel updates
  • test-coverage - Above 95% test coverage for all integration modules
  • integration-owner - Has an integration owner
    It'sa me
  • docs-installation-parameters - The documentation describes all integration installation parameters
  • docs-configuration-parameters - The documentation describes all integration configuration options

Gold

  • entity-translations - Entities have translated names
    "entity": {
    "sensor": {
    "custom_integrations": {
    "name": "{custom_integration_domain} (custom)"
    },
    "total_active_installations": {
    "name": "Total active installations"
    },
    "total_reports_integrations": {
    "name": "Total reported integrations"
    }
    }
    }
  • entity-device-class - Entities use device classes where possible
  • devices - The integration creates devices
    self._attr_device_info = DeviceInfo(
    identifiers={(DOMAIN, DOMAIN)},
    entry_type=DeviceEntryType.SERVICE,
    )
  • entity-category - Entities are assigned an appropriate EntityCategory
    _attr_entity_category = EntityCategory.DIAGNOSTIC
  • entity-disabled-by-default - Integration disables less popular (or noisy) entities
    GENERAL_SENSORS = [
    AnalyticsSensorEntityDescription(
    key="total_active_installations",
    translation_key="total_active_installations",
    entity_registry_enabled_default=False,
    state_class=SensorStateClass.TOTAL,
    native_unit_of_measurement="active installations",
    value_fn=lambda data: data.active_installations,
    ),
    AnalyticsSensorEntityDescription(
    key="total_reports_integrations",
    translation_key="total_reports_integrations",
    entity_registry_enabled_default=False,
    state_class=SensorStateClass.TOTAL,
    native_unit_of_measurement="active installations",
    value_fn=lambda data: data.reports_integrations,
    ),
    ]
  • discovery - Can be discovered
  • stale-devices - Clean up stale devices
  • diagnostics - Implements diagnostics
  • exception-translations - Exception messages are translatable
  • icon-translations - Icon translations
    {
    "entity": {
    "sensor": {
    "core_integrations": {
    "default": "mdi:puzzle"
    },
    "custom_integrations": {
    "default": "mdi:puzzle-edit"
    },
    "total_active_installations": {
    "default": "mdi:puzzle"
    },
    "total_reports_integrations": {
    "default": "mdi:puzzle"
    }
    }
    }
    }
  • reconfiguration-flow - Integrations should have a reconfigure flow
  • dynamic-devices - Devices added after integration setup
  • discovery-update-info - Integration uses discovery info to update network information
  • repair-issues - Repair issues and repair flows are used when user intervention is needed
  • docs-use-cases - The documentation describes use cases to illustrate how this integration can be used
  • docs-supported-devices - The documentation describes known supported / unsupported devices
  • docs-supported-functions - The documentation describes the supported functionality, including entities, and platforms
  • docs-data-update - The documentation describes how data is updated
  • docs-known-limitations - The documentation describes known limitations of the integration (not to be confused with bugs)
  • docs-troubleshooting - The documentation provides troubleshooting information
  • docs-examples - The documentation provides automation examples the user can use.

Platinum

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@joostlek joostlek requested a review from a team as a code owner December 19, 2024 12:26
config-entry-unloading: done
docs-configuration-parameters: todo
docs-installation-parameters: todo
entity-unavailable: done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would add a comment here, that it's handled through coordinator, as there is nothing that sets it explicitly

@joostlek
Copy link
Member Author

I also added an exception for the reconfigure flow because we solely store data in the options, and I don't think 2 flows to do the same thing make sense here

Copy link
Member

@zweckj zweckj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potato/potato, but those are done for me

@zweckj zweckj merged commit 870dc4d into home-assistant:dev Dec 20, 2024
34 checks passed
@joostlek joostlek deleted the ai-quality-scale branch December 20, 2024 12:16
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants