diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index cc100c48fd8..03c896cce1c 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -46,10 +46,10 @@ jobs: with: type: ${{ env.BUILD_TYPE }} - - name: Verify version - uses: home-assistant/actions/helpers/verify-version@master - with: - ignore-dev: true + # - name: Verify version + # uses: home-assistant/actions/helpers/verify-version@master + # with: + # ignore-dev: true - name: Fail if translations files are checked in run: | @@ -205,334 +205,3 @@ jobs: --cosign \ --target /data \ --generic ${{ needs.init.outputs.version }} - - build_machine: - name: Build ${{ matrix.machine }} machine core image - if: github.repository_owner == 'home-assistant' - needs: ["init", "build_base"] - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - strategy: - matrix: - machine: - - generic-x86-64 - - intel-nuc - - khadas-vim3 - - odroid-c2 - - odroid-c4 - - odroid-m1 - - odroid-n2 - - odroid-xu - - qemuarm - - qemuarm-64 - - qemux86 - - qemux86-64 - - raspberrypi - - raspberrypi2 - - raspberrypi3 - - raspberrypi3-64 - - raspberrypi4 - - raspberrypi4-64 - - raspberrypi5-64 - - tinker - - yellow - - green - steps: - - name: Checkout the repository - uses: actions/checkout@v4.2.2 - - - name: Set build additional args - run: | - # Create general tags - if [[ "${{ needs.init.outputs.version }}" =~ d ]]; then - echo "BUILD_ARGS=--additional-tag dev" >> $GITHUB_ENV - elif [[ "${{ needs.init.outputs.version }}" =~ b ]]; then - echo "BUILD_ARGS=--additional-tag beta" >> $GITHUB_ENV - else - echo "BUILD_ARGS=--additional-tag stable" >> $GITHUB_ENV - fi - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build base image - uses: home-assistant/builder@2024.08.2 - with: - args: | - $BUILD_ARGS \ - --target /data/machine \ - --cosign \ - --machine "${{ needs.init.outputs.version }}=${{ matrix.machine }}" - - publish_ha: - name: Publish version files - environment: ${{ needs.init.outputs.channel }} - if: github.repository_owner == 'home-assistant' - needs: ["init", "build_machine"] - runs-on: ubuntu-latest - steps: - - name: Checkout the repository - uses: actions/checkout@v4.2.2 - - - name: Initialize git - uses: home-assistant/actions/helpers/git-init@master - with: - name: ${{ secrets.GIT_NAME }} - email: ${{ secrets.GIT_EMAIL }} - token: ${{ secrets.GIT_TOKEN }} - - - name: Update version file - uses: home-assistant/actions/helpers/version-push@master - with: - key: "homeassistant[]" - key-description: "Home Assistant Core" - version: ${{ needs.init.outputs.version }} - channel: ${{ needs.init.outputs.channel }} - - - name: Update version file (stable -> beta) - if: needs.init.outputs.channel == 'stable' - uses: home-assistant/actions/helpers/version-push@master - with: - key: "homeassistant[]" - key-description: "Home Assistant Core" - version: ${{ needs.init.outputs.version }} - channel: beta - - publish_container: - name: Publish meta container for ${{ matrix.registry }} - environment: ${{ needs.init.outputs.channel }} - if: github.repository_owner == 'home-assistant' - needs: ["init", "build_base"] - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - strategy: - fail-fast: false - matrix: - registry: ["ghcr.io/home-assistant", "docker.io/homeassistant"] - steps: - - name: Checkout the repository - uses: actions/checkout@v4.2.2 - - - name: Install Cosign - uses: sigstore/cosign-installer@v3.7.0 - with: - cosign-release: "v2.2.3" - - - name: Login to DockerHub - if: matrix.registry == 'docker.io/homeassistant' - uses: docker/login-action@v3.3.0 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry - if: matrix.registry == 'ghcr.io/home-assistant' - uses: docker/login-action@v3.3.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Meta Image - shell: bash - run: | - export DOCKER_CLI_EXPERIMENTAL=enabled - - function create_manifest() { - local tag_l=${1} - local tag_r=${2} - local registry=${{ matrix.registry }} - - docker manifest create "${registry}/home-assistant:${tag_l}" \ - "${registry}/amd64-homeassistant:${tag_r}" \ - "${registry}/i386-homeassistant:${tag_r}" \ - "${registry}/armhf-homeassistant:${tag_r}" \ - "${registry}/armv7-homeassistant:${tag_r}" \ - "${registry}/aarch64-homeassistant:${tag_r}" - - docker manifest annotate "${registry}/home-assistant:${tag_l}" \ - "${registry}/amd64-homeassistant:${tag_r}" \ - --os linux --arch amd64 - - docker manifest annotate "${registry}/home-assistant:${tag_l}" \ - "${registry}/i386-homeassistant:${tag_r}" \ - --os linux --arch 386 - - docker manifest annotate "${registry}/home-assistant:${tag_l}" \ - "${registry}/armhf-homeassistant:${tag_r}" \ - --os linux --arch arm --variant=v6 - - docker manifest annotate "${registry}/home-assistant:${tag_l}" \ - "${registry}/armv7-homeassistant:${tag_r}" \ - --os linux --arch arm --variant=v7 - - docker manifest annotate "${registry}/home-assistant:${tag_l}" \ - "${registry}/aarch64-homeassistant:${tag_r}" \ - --os linux --arch arm64 --variant=v8 - - docker manifest push --purge "${registry}/home-assistant:${tag_l}" - cosign sign --yes "${registry}/home-assistant:${tag_l}" - } - - function validate_image() { - local image=${1} - if ! cosign verify --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp https://github.com/home-assistant/core/.* "${image}"; then - echo "Invalid signature!" - exit 1 - fi - } - - function push_dockerhub() { - local image=${1} - local tag=${2} - - docker tag "ghcr.io/home-assistant/${image}:${tag}" "docker.io/homeassistant/${image}:${tag}" - docker push "docker.io/homeassistant/${image}:${tag}" - cosign sign --yes "docker.io/homeassistant/${image}:${tag}" - } - - # Pull images from github container registry and verify signature - docker pull "ghcr.io/home-assistant/amd64-homeassistant:${{ needs.init.outputs.version }}" - docker pull "ghcr.io/home-assistant/i386-homeassistant:${{ needs.init.outputs.version }}" - docker pull "ghcr.io/home-assistant/armhf-homeassistant:${{ needs.init.outputs.version }}" - docker pull "ghcr.io/home-assistant/armv7-homeassistant:${{ needs.init.outputs.version }}" - docker pull "ghcr.io/home-assistant/aarch64-homeassistant:${{ needs.init.outputs.version }}" - - validate_image "ghcr.io/home-assistant/amd64-homeassistant:${{ needs.init.outputs.version }}" - validate_image "ghcr.io/home-assistant/i386-homeassistant:${{ needs.init.outputs.version }}" - validate_image "ghcr.io/home-assistant/armhf-homeassistant:${{ needs.init.outputs.version }}" - validate_image "ghcr.io/home-assistant/armv7-homeassistant:${{ needs.init.outputs.version }}" - validate_image "ghcr.io/home-assistant/aarch64-homeassistant:${{ needs.init.outputs.version }}" - - if [[ "${{ matrix.registry }}" == "docker.io/homeassistant" ]]; then - # Upload images to dockerhub - push_dockerhub "amd64-homeassistant" "${{ needs.init.outputs.version }}" - push_dockerhub "i386-homeassistant" "${{ needs.init.outputs.version }}" - push_dockerhub "armhf-homeassistant" "${{ needs.init.outputs.version }}" - push_dockerhub "armv7-homeassistant" "${{ needs.init.outputs.version }}" - push_dockerhub "aarch64-homeassistant" "${{ needs.init.outputs.version }}" - fi - - # Create version tag - create_manifest "${{ needs.init.outputs.version }}" "${{ needs.init.outputs.version }}" - - # Create general tags - if [[ "${{ needs.init.outputs.version }}" =~ d ]]; then - create_manifest "dev" "${{ needs.init.outputs.version }}" - elif [[ "${{ needs.init.outputs.version }}" =~ b ]]; then - create_manifest "beta" "${{ needs.init.outputs.version }}" - create_manifest "rc" "${{ needs.init.outputs.version }}" - else - create_manifest "stable" "${{ needs.init.outputs.version }}" - create_manifest "latest" "${{ needs.init.outputs.version }}" - create_manifest "beta" "${{ needs.init.outputs.version }}" - create_manifest "rc" "${{ needs.init.outputs.version }}" - - # Create series version tag (e.g. 2021.6) - v="${{ needs.init.outputs.version }}" - create_manifest "${v%.*}" "${{ needs.init.outputs.version }}" - fi - - build_python: - name: Build PyPi package - environment: ${{ needs.init.outputs.channel }} - needs: ["init", "build_base"] - runs-on: ubuntu-latest - if: github.repository_owner == 'home-assistant' && needs.init.outputs.publish == 'true' - steps: - - name: Checkout the repository - uses: actions/checkout@v4.2.2 - - - name: Set up Python ${{ env.DEFAULT_PYTHON }} - uses: actions/setup-python@v5.3.0 - with: - python-version: ${{ env.DEFAULT_PYTHON }} - - - name: Download translations - uses: actions/download-artifact@v4.1.8 - with: - name: translations - - - name: Extract translations - run: | - tar xvf translations.tar.gz - rm translations.tar.gz - - - name: Build package - shell: bash - run: | - # Remove dist, build, and homeassistant.egg-info - # when build locally for testing! - pip install twine build - python -m build - - - name: Upload package - shell: bash - run: | - export TWINE_USERNAME="__token__" - export TWINE_PASSWORD="${{ secrets.TWINE_TOKEN }}" - - twine upload dist/* --skip-existing - - hassfest-image: - name: Build and test hassfest image - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write - needs: ["init"] - if: github.repository_owner == 'home-assistant' - env: - HASSFEST_IMAGE_NAME: ghcr.io/home-assistant/hassfest - HASSFEST_IMAGE_TAG: ghcr.io/home-assistant/hassfest:${{ needs.init.outputs.version }} - steps: - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Docker image - uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 - with: - context: . # So action will not pull the repository again - file: ./script/hassfest/docker/Dockerfile - load: true - tags: ${{ env.HASSFEST_IMAGE_TAG }} - - - name: Run hassfest against core - run: docker run --rm -v ${{ github.workspace }}/homeassistant:/github/workspace/homeassistant ${{ env.HASSFEST_IMAGE_TAG }} --core-integrations-path=/github/workspace/homeassistant/components - - - name: Push Docker image - if: needs.init.outputs.channel != 'dev' && needs.init.outputs.publish == 'true' - id: push - uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 - with: - context: . # So action will not pull the repository again - file: ./script/hassfest/docker/Dockerfile - push: true - tags: ${{ env.HASSFEST_IMAGE_TAG }},${{ env.HASSFEST_IMAGE_NAME }}:latest - - - name: Generate artifact attestation - if: needs.init.outputs.channel != 'dev' && needs.init.outputs.publish == 'true' - uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4 - with: - subject-name: ${{ env.HASSFEST_IMAGE_NAME }} - subject-digest: ${{ steps.push.outputs.digest }} - push-to-registry: true diff --git a/CODEOWNERS b/CODEOWNERS index e204463695e..76422734c92 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -40,8 +40,6 @@ build.json @home-assistant/supervisor # Integrations /homeassistant/components/abode/ @shred86 /tests/components/abode/ @shred86 -/homeassistant/components/acaia/ @zweckj -/tests/components/acaia/ @zweckj /homeassistant/components/accuweather/ @bieniu /tests/components/accuweather/ @bieniu /homeassistant/components/acmeda/ @atmurray @@ -1489,8 +1487,8 @@ build.json @home-assistant/supervisor /tests/components/tedee/ @patrickhilker @zweckj /homeassistant/components/tellduslive/ @fredrike /tests/components/tellduslive/ @fredrike -/homeassistant/components/template/ @PhracturedBlue @home-assistant/core -/tests/components/template/ @PhracturedBlue @home-assistant/core +/homeassistant/components/template/ @PhracturedBlue @tetienne @home-assistant/core +/tests/components/template/ @PhracturedBlue @tetienne @home-assistant/core /homeassistant/components/tesla_fleet/ @Bre77 /tests/components/tesla_fleet/ @Bre77 /homeassistant/components/tesla_wall_connector/ @einarhauks diff --git a/Dockerfile b/Dockerfile index 15574192093..10061485742 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,14 +25,14 @@ RUN \ --no-build \ -r homeassistant/requirements.txt -COPY requirements_all.txt home_assistant_frontend-* home_assistant_intents-* homeassistant/ +COPY requirements_top.txt home_assistant_frontend-* home_assistant_intents-* homeassistant/ RUN \ if ls homeassistant/home_assistant_*.whl 1> /dev/null 2>&1; then \ uv pip install homeassistant/home_assistant_*.whl; \ fi \ && uv pip install \ --no-build \ - -r homeassistant/requirements_all.txt + -r homeassistant/requirements_top.txt ## Setup Home Assistant Core COPY . homeassistant/ diff --git a/homeassistant/bootstrap.py b/homeassistant/bootstrap.py index 1034223051c..dcfb6685627 100644 --- a/homeassistant/bootstrap.py +++ b/homeassistant/bootstrap.py @@ -515,7 +515,7 @@ async def async_from_config_dict( issue_registry.async_create_issue( hass, core.DOMAIN, - f"python_version_{required_python_version}", + "python_version", is_fixable=False, severity=issue_registry.IssueSeverity.WARNING, breaks_in_ha_version=REQUIRED_NEXT_PYTHON_HA_RELEASE, diff --git a/homeassistant/components/acaia/__init__.py b/homeassistant/components/acaia/__init__.py deleted file mode 100644 index dfdb4cb935d..00000000000 --- a/homeassistant/components/acaia/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Initialize the Acaia component.""" - -from homeassistant.const import Platform -from homeassistant.core import HomeAssistant - -from .coordinator import AcaiaConfigEntry, AcaiaCoordinator - -PLATFORMS = [ - Platform.BUTTON, -] - - -async def async_setup_entry(hass: HomeAssistant, entry: AcaiaConfigEntry) -> bool: - """Set up acaia as config entry.""" - - coordinator = AcaiaCoordinator(hass, entry) - await coordinator.async_config_entry_first_refresh() - - entry.runtime_data = coordinator - - await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) - - return True - - -async def async_unload_entry(hass: HomeAssistant, entry: AcaiaConfigEntry) -> bool: - """Unload a config entry.""" - - return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) diff --git a/homeassistant/components/acaia/button.py b/homeassistant/components/acaia/button.py deleted file mode 100644 index 50671eecbba..00000000000 --- a/homeassistant/components/acaia/button.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Button entities for Acaia scales.""" - -from collections.abc import Callable, Coroutine -from dataclasses import dataclass -from typing import Any - -from aioacaia.acaiascale import AcaiaScale - -from homeassistant.components.button import ButtonEntity, ButtonEntityDescription -from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity_platform import AddEntitiesCallback - -from .coordinator import AcaiaConfigEntry -from .entity import AcaiaEntity - - -@dataclass(kw_only=True, frozen=True) -class AcaiaButtonEntityDescription(ButtonEntityDescription): - """Description for acaia button entities.""" - - press_fn: Callable[[AcaiaScale], Coroutine[Any, Any, None]] - - -BUTTONS: tuple[AcaiaButtonEntityDescription, ...] = ( - AcaiaButtonEntityDescription( - key="tare", - translation_key="tare", - press_fn=lambda scale: scale.tare(), - ), - AcaiaButtonEntityDescription( - key="reset_timer", - translation_key="reset_timer", - press_fn=lambda scale: scale.reset_timer(), - ), - AcaiaButtonEntityDescription( - key="start_stop", - translation_key="start_stop", - press_fn=lambda scale: scale.start_stop_timer(), - ), -) - - -async def async_setup_entry( - hass: HomeAssistant, - entry: AcaiaConfigEntry, - async_add_entities: AddEntitiesCallback, -) -> None: - """Set up button entities and services.""" - - coordinator = entry.runtime_data - async_add_entities(AcaiaButton(coordinator, description) for description in BUTTONS) - - -class AcaiaButton(AcaiaEntity, ButtonEntity): - """Representation of an Acaia button.""" - - entity_description: AcaiaButtonEntityDescription - - async def async_press(self) -> None: - """Handle the button press.""" - await self.entity_description.press_fn(self._scale) diff --git a/homeassistant/components/acaia/config_flow.py b/homeassistant/components/acaia/config_flow.py deleted file mode 100644 index 36727059c8a..00000000000 --- a/homeassistant/components/acaia/config_flow.py +++ /dev/null @@ -1,149 +0,0 @@ -"""Config flow for Acaia integration.""" - -import logging -from typing import Any - -from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError, AcaiaUnknownDevice -from aioacaia.helpers import is_new_scale -import voluptuous as vol - -from homeassistant.components.bluetooth import ( - BluetoothServiceInfoBleak, - async_discovered_service_info, -) -from homeassistant.config_entries import ConfigFlow, ConfigFlowResult -from homeassistant.const import CONF_ADDRESS, CONF_NAME -from homeassistant.helpers.device_registry import format_mac -from homeassistant.helpers.selector import ( - SelectOptionDict, - SelectSelector, - SelectSelectorConfig, - SelectSelectorMode, -) - -from .const import CONF_IS_NEW_STYLE_SCALE, DOMAIN - -_LOGGER = logging.getLogger(__name__) - - -class AcaiaConfigFlow(ConfigFlow, domain=DOMAIN): - """Handle a config flow for acaia.""" - - def __init__(self) -> None: - """Initialize the config flow.""" - self._discovered: dict[str, Any] = {} - self._discovered_devices: dict[str, str] = {} - - async def async_step_user( - self, user_input: dict[str, Any] | None = None - ) -> ConfigFlowResult: - """Handle a flow initialized by the user.""" - - errors: dict[str, str] = {} - - if user_input is not None: - mac = format_mac(user_input[CONF_ADDRESS]) - try: - is_new_style_scale = await is_new_scale(mac) - except AcaiaDeviceNotFound: - errors["base"] = "device_not_found" - except AcaiaError: - _LOGGER.exception("Error occurred while connecting to the scale") - errors["base"] = "unknown" - except AcaiaUnknownDevice: - return self.async_abort(reason="unsupported_device") - else: - await self.async_set_unique_id(mac) - self._abort_if_unique_id_configured() - - if not errors: - return self.async_create_entry( - title=self._discovered_devices[user_input[CONF_ADDRESS]], - data={ - CONF_ADDRESS: mac, - CONF_IS_NEW_STYLE_SCALE: is_new_style_scale, - }, - ) - - for device in async_discovered_service_info(self.hass): - self._discovered_devices[device.address] = device.name - - if not self._discovered_devices: - return self.async_abort(reason="no_devices_found") - - options = [ - SelectOptionDict( - value=device_mac, - label=f"{device_name} ({device_mac})", - ) - for device_mac, device_name in self._discovered_devices.items() - ] - - return self.async_show_form( - step_id="user", - data_schema=vol.Schema( - { - vol.Required(CONF_ADDRESS): SelectSelector( - SelectSelectorConfig( - options=options, - mode=SelectSelectorMode.DROPDOWN, - ) - ) - } - ), - errors=errors, - ) - - async def async_step_bluetooth( - self, discovery_info: BluetoothServiceInfoBleak - ) -> ConfigFlowResult: - """Handle a discovered Bluetooth device.""" - - self._discovered[CONF_ADDRESS] = mac = format_mac(discovery_info.address) - self._discovered[CONF_NAME] = discovery_info.name - - await self.async_set_unique_id(mac) - self._abort_if_unique_id_configured() - - try: - self._discovered[CONF_IS_NEW_STYLE_SCALE] = await is_new_scale( - discovery_info.address - ) - except AcaiaDeviceNotFound: - _LOGGER.debug("Device not found during discovery") - return self.async_abort(reason="device_not_found") - except AcaiaError: - _LOGGER.debug( - "Error occurred while connecting to the scale during discovery", - exc_info=True, - ) - return self.async_abort(reason="unknown") - except AcaiaUnknownDevice: - _LOGGER.debug("Unsupported device during discovery") - return self.async_abort(reason="unsupported_device") - - return await self.async_step_bluetooth_confirm() - - async def async_step_bluetooth_confirm( - self, user_input: dict[str, Any] | None = None - ) -> ConfigFlowResult: - """Handle confirmation of Bluetooth discovery.""" - - if user_input is not None: - return self.async_create_entry( - title=self._discovered[CONF_NAME], - data={ - CONF_ADDRESS: self._discovered[CONF_ADDRESS], - CONF_IS_NEW_STYLE_SCALE: self._discovered[CONF_IS_NEW_STYLE_SCALE], - }, - ) - - self.context["title_placeholders"] = placeholders = { - CONF_NAME: self._discovered[CONF_NAME] - } - - self._set_confirm_only() - return self.async_show_form( - step_id="bluetooth_confirm", - description_placeholders=placeholders, - ) diff --git a/homeassistant/components/acaia/const.py b/homeassistant/components/acaia/const.py deleted file mode 100644 index c603578763d..00000000000 --- a/homeassistant/components/acaia/const.py +++ /dev/null @@ -1,4 +0,0 @@ -"""Constants for component.""" - -DOMAIN = "acaia" -CONF_IS_NEW_STYLE_SCALE = "is_new_style_scale" diff --git a/homeassistant/components/acaia/coordinator.py b/homeassistant/components/acaia/coordinator.py deleted file mode 100644 index bd915b42408..00000000000 --- a/homeassistant/components/acaia/coordinator.py +++ /dev/null @@ -1,86 +0,0 @@ -"""Coordinator for Acaia integration.""" - -from __future__ import annotations - -from datetime import timedelta -import logging - -from aioacaia.acaiascale import AcaiaScale -from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError - -from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ADDRESS -from homeassistant.core import HomeAssistant -from homeassistant.helpers.update_coordinator import DataUpdateCoordinator - -from .const import CONF_IS_NEW_STYLE_SCALE - -SCAN_INTERVAL = timedelta(seconds=15) - -_LOGGER = logging.getLogger(__name__) - -type AcaiaConfigEntry = ConfigEntry[AcaiaCoordinator] - - -class AcaiaCoordinator(DataUpdateCoordinator[None]): - """Class to handle fetching data from the scale.""" - - config_entry: AcaiaConfigEntry - - def __init__(self, hass: HomeAssistant, entry: AcaiaConfigEntry) -> None: - """Initialize coordinator.""" - super().__init__( - hass, - _LOGGER, - name="acaia coordinator", - update_interval=SCAN_INTERVAL, - config_entry=entry, - ) - - self._scale = AcaiaScale( - address_or_ble_device=entry.data[CONF_ADDRESS], - name=entry.title, - is_new_style_scale=entry.data[CONF_IS_NEW_STYLE_SCALE], - notify_callback=self.async_update_listeners, - ) - - @property - def scale(self) -> AcaiaScale: - """Return the scale object.""" - return self._scale - - async def _async_update_data(self) -> None: - """Fetch data.""" - - # scale is already connected, return - if self._scale.connected: - return - - # scale is not connected, try to connect - try: - await self._scale.connect(setup_tasks=False) - except (AcaiaDeviceNotFound, AcaiaError, TimeoutError) as ex: - _LOGGER.debug( - "Could not connect to scale: %s, Error: %s", - self.config_entry.data[CONF_ADDRESS], - ex, - ) - self._scale.device_disconnected_handler(notify=False) - return - - # connected, set up background tasks - if not self._scale.heartbeat_task or self._scale.heartbeat_task.done(): - self._scale.heartbeat_task = self.config_entry.async_create_background_task( - hass=self.hass, - target=self._scale.send_heartbeats(), - name="acaia_heartbeat_task", - ) - - if not self._scale.process_queue_task or self._scale.process_queue_task.done(): - self._scale.process_queue_task = ( - self.config_entry.async_create_background_task( - hass=self.hass, - target=self._scale.process_queue(), - name="acaia_process_queue_task", - ) - ) diff --git a/homeassistant/components/acaia/entity.py b/homeassistant/components/acaia/entity.py deleted file mode 100644 index 8a2108d2687..00000000000 --- a/homeassistant/components/acaia/entity.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Base class for Acaia entities.""" - -from dataclasses import dataclass - -from homeassistant.helpers.device_registry import DeviceInfo -from homeassistant.helpers.entity import EntityDescription -from homeassistant.helpers.update_coordinator import CoordinatorEntity - -from .const import DOMAIN -from .coordinator import AcaiaCoordinator - - -@dataclass -class AcaiaEntity(CoordinatorEntity[AcaiaCoordinator]): - """Common elements for all entities.""" - - _attr_has_entity_name = True - - def __init__( - self, - coordinator: AcaiaCoordinator, - entity_description: EntityDescription, - ) -> None: - """Initialize the entity.""" - super().__init__(coordinator) - self.entity_description = entity_description - self._scale = coordinator.scale - self._attr_unique_id = f"{self._scale.mac}_{entity_description.key}" - - self._attr_device_info = DeviceInfo( - identifiers={(DOMAIN, self._scale.mac)}, - manufacturer="Acaia", - model=self._scale.model, - suggested_area="Kitchen", - ) - - @property - def available(self) -> bool: - """Returns whether entity is available.""" - return super().available and self._scale.connected diff --git a/homeassistant/components/acaia/icons.json b/homeassistant/components/acaia/icons.json deleted file mode 100644 index aeab07ee912..00000000000 --- a/homeassistant/components/acaia/icons.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "entity": { - "button": { - "tare": { - "default": "mdi:scale-balance" - }, - "reset_timer": { - "default": "mdi:timer-refresh" - }, - "start_stop": { - "default": "mdi:timer-play" - } - } - } -} diff --git a/homeassistant/components/acaia/manifest.json b/homeassistant/components/acaia/manifest.json deleted file mode 100644 index c907a70a38e..00000000000 --- a/homeassistant/components/acaia/manifest.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "domain": "acaia", - "name": "Acaia", - "bluetooth": [ - { - "manufacturer_id": 16962 - }, - { - "local_name": "ACAIA*" - }, - { - "local_name": "PYXIS-*" - }, - { - "local_name": "LUNAR-*" - }, - { - "local_name": "PROCHBT001" - } - ], - "codeowners": ["@zweckj"], - "config_flow": true, - "dependencies": ["bluetooth_adapters"], - "documentation": "https://www.home-assistant.io/integrations/acaia", - "integration_type": "device", - "iot_class": "local_push", - "loggers": ["aioacaia"], - "requirements": ["aioacaia==0.1.6"] -} diff --git a/homeassistant/components/acaia/strings.json b/homeassistant/components/acaia/strings.json deleted file mode 100644 index f6a1aeb66fd..00000000000 --- a/homeassistant/components/acaia/strings.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "config": { - "flow_title": "{name}", - "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", - "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", - "unsupported_device": "This device is not supported." - }, - "error": { - "device_not_found": "Device could not be found.", - "unknown": "[%key:common::config_flow::error::unknown%]" - }, - "step": { - "bluetooth_confirm": { - "description": "[%key:component::bluetooth::config::step::bluetooth_confirm::description%]" - }, - "user": { - "description": "[%key:component::bluetooth::config::step::user::description%]", - "data": { - "address": "[%key:common::config_flow::data::device%]" - } - } - } - }, - "entity": { - "button": { - "tare": { - "name": "Tare" - }, - "reset_timer": { - "name": "Reset timer" - }, - "start_stop": { - "name": "Start/stop timer" - } - } - } -} diff --git a/homeassistant/components/airzone/manifest.json b/homeassistant/components/airzone/manifest.json index 6bf374087a6..10fb20bb2ce 100644 --- a/homeassistant/components/airzone/manifest.json +++ b/homeassistant/components/airzone/manifest.json @@ -11,5 +11,5 @@ "documentation": "https://www.home-assistant.io/integrations/airzone", "iot_class": "local_polling", "loggers": ["aioairzone"], - "requirements": ["aioairzone==0.9.6"] + "requirements": ["aioairzone==0.9.5"] } diff --git a/homeassistant/components/cambridge_audio/manifest.json b/homeassistant/components/cambridge_audio/manifest.json index c359ca14a21..edacd17f54d 100644 --- a/homeassistant/components/cambridge_audio/manifest.json +++ b/homeassistant/components/cambridge_audio/manifest.json @@ -7,6 +7,6 @@ "integration_type": "device", "iot_class": "local_push", "loggers": ["aiostreammagic"], - "requirements": ["aiostreammagic==2.8.5"], + "requirements": ["aiostreammagic==2.8.4"], "zeroconf": ["_stream-magic._tcp.local.", "_smoip._tcp.local."] } diff --git a/homeassistant/components/cambridge_audio/select.py b/homeassistant/components/cambridge_audio/select.py index c99abc853e5..ca6eebdec6b 100644 --- a/homeassistant/components/cambridge_audio/select.py +++ b/homeassistant/components/cambridge_audio/select.py @@ -51,13 +51,8 @@ CONTROL_ENTITIES: tuple[CambridgeAudioSelectEntityDescription, ...] = ( CambridgeAudioSelectEntityDescription( key="display_brightness", translation_key="display_brightness", - options=[ - DisplayBrightness.BRIGHT.value, - DisplayBrightness.DIM.value, - DisplayBrightness.OFF.value, - ], + options=[x.value for x in DisplayBrightness], entity_category=EntityCategory.CONFIG, - load_fn=lambda client: client.display.brightness != DisplayBrightness.NONE, value_fn=lambda client: client.display.brightness, set_value_fn=lambda client, value: client.set_display_brightness( DisplayBrightness(value) diff --git a/homeassistant/components/camera/webrtc.py b/homeassistant/components/camera/webrtc.py index d627a888169..0612c96e40c 100644 --- a/homeassistant/components/camera/webrtc.py +++ b/homeassistant/components/camera/webrtc.py @@ -6,7 +6,7 @@ from abc import ABC, abstractmethod import asyncio from collections.abc import Awaitable, Callable, Iterable from dataclasses import asdict, dataclass, field -from functools import cache, partial, wraps +from functools import cache, partial import logging from typing import TYPE_CHECKING, Any, Protocol @@ -205,49 +205,6 @@ async def _async_refresh_providers(hass: HomeAssistant) -> None: ) -type WsCommandWithCamera = Callable[ - [websocket_api.ActiveConnection, dict[str, Any], Camera], - Awaitable[None], -] - - -def require_webrtc_support( - error_code: str, -) -> Callable[[WsCommandWithCamera], websocket_api.AsyncWebSocketCommandHandler]: - """Validate that the camera supports WebRTC.""" - - def decorate( - func: WsCommandWithCamera, - ) -> websocket_api.AsyncWebSocketCommandHandler: - """Decorate func.""" - - @wraps(func) - async def validate( - hass: HomeAssistant, - connection: websocket_api.ActiveConnection, - msg: dict[str, Any], - ) -> None: - """Validate that the camera supports WebRTC.""" - entity_id = msg["entity_id"] - camera = get_camera_from_entity_id(hass, entity_id) - if camera.frontend_stream_type != StreamType.WEB_RTC: - connection.send_error( - msg["id"], - error_code, - ( - "Camera does not support WebRTC," - f" frontend_stream_type={camera.frontend_stream_type}" - ), - ) - return - - await func(connection, msg, camera) - - return validate - - return decorate - - @websocket_api.websocket_command( { vol.Required("type"): "camera/webrtc/offer", @@ -256,9 +213,8 @@ def require_webrtc_support( } ) @websocket_api.async_response -@require_webrtc_support("webrtc_offer_failed") async def ws_webrtc_offer( - connection: websocket_api.ActiveConnection, msg: dict[str, Any], camera: Camera + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Handle the signal path for a WebRTC stream. @@ -270,7 +226,20 @@ async def ws_webrtc_offer( Async friendly. """ + entity_id = msg["entity_id"] offer = msg["offer"] + camera = get_camera_from_entity_id(hass, entity_id) + if camera.frontend_stream_type != StreamType.WEB_RTC: + connection.send_error( + msg["id"], + "webrtc_offer_failed", + ( + "Camera does not support WebRTC," + f" frontend_stream_type={camera.frontend_stream_type}" + ), + ) + return + session_id = ulid() connection.subscriptions[msg["id"]] = partial( camera.close_webrtc_session, session_id @@ -309,11 +278,23 @@ async def ws_webrtc_offer( } ) @websocket_api.async_response -@require_webrtc_support("webrtc_get_client_config_failed") async def ws_get_client_config( - connection: websocket_api.ActiveConnection, msg: dict[str, Any], camera: Camera + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Handle get WebRTC client config websocket command.""" + entity_id = msg["entity_id"] + camera = get_camera_from_entity_id(hass, entity_id) + if camera.frontend_stream_type != StreamType.WEB_RTC: + connection.send_error( + msg["id"], + "webrtc_get_client_config_failed", + ( + "Camera does not support WebRTC," + f" frontend_stream_type={camera.frontend_stream_type}" + ), + ) + return + config = camera.async_get_webrtc_client_configuration().to_frontend_dict() connection.send_result( msg["id"], @@ -330,11 +311,23 @@ async def ws_get_client_config( } ) @websocket_api.async_response -@require_webrtc_support("webrtc_candidate_failed") async def ws_candidate( - connection: websocket_api.ActiveConnection, msg: dict[str, Any], camera: Camera + hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict[str, Any] ) -> None: """Handle WebRTC candidate websocket command.""" + entity_id = msg["entity_id"] + camera = get_camera_from_entity_id(hass, entity_id) + if camera.frontend_stream_type != StreamType.WEB_RTC: + connection.send_error( + msg["id"], + "webrtc_candidate_failed", + ( + "Camera does not support WebRTC," + f" frontend_stream_type={camera.frontend_stream_type}" + ), + ) + return + await camera.async_on_webrtc_candidate( msg["session_id"], RTCIceCandidate(msg["candidate"]) ) diff --git a/homeassistant/components/eq3btsmart/__init__.py b/homeassistant/components/eq3btsmart/__init__.py index 84b27161edd..86c555ec151 100644 --- a/homeassistant/components/eq3btsmart/__init__.py +++ b/homeassistant/components/eq3btsmart/__init__.py @@ -21,7 +21,6 @@ from .models import Eq3Config, Eq3ConfigEntryData PLATFORMS = [ Platform.BINARY_SENSOR, Platform.CLIMATE, - Platform.NUMBER, Platform.SWITCH, ] diff --git a/homeassistant/components/eq3btsmart/const.py b/homeassistant/components/eq3btsmart/const.py index 78292940e60..64bc1cf497c 100644 --- a/homeassistant/components/eq3btsmart/const.py +++ b/homeassistant/components/eq3btsmart/const.py @@ -24,11 +24,6 @@ ENTITY_KEY_WINDOW = "window" ENTITY_KEY_LOCK = "lock" ENTITY_KEY_BOOST = "boost" ENTITY_KEY_AWAY = "away" -ENTITY_KEY_COMFORT = "comfort" -ENTITY_KEY_ECO = "eco" -ENTITY_KEY_OFFSET = "offset" -ENTITY_KEY_WINDOW_OPEN_TEMPERATURE = "window_open_temperature" -ENTITY_KEY_WINDOW_OPEN_TIMEOUT = "window_open_timeout" GET_DEVICE_TIMEOUT = 5 # seconds @@ -82,5 +77,3 @@ DEFAULT_SCAN_INTERVAL = 10 # seconds SIGNAL_THERMOSTAT_DISCONNECTED = f"{DOMAIN}.thermostat_disconnected" SIGNAL_THERMOSTAT_CONNECTED = f"{DOMAIN}.thermostat_connected" - -EQ3BT_STEP = 0.5 diff --git a/homeassistant/components/eq3btsmart/icons.json b/homeassistant/components/eq3btsmart/icons.json index e6eb7532f37..fb0862f14bc 100644 --- a/homeassistant/components/eq3btsmart/icons.json +++ b/homeassistant/components/eq3btsmart/icons.json @@ -8,23 +8,6 @@ } } }, - "number": { - "comfort": { - "default": "mdi:sun-thermometer" - }, - "eco": { - "default": "mdi:snowflake-thermometer" - }, - "offset": { - "default": "mdi:thermometer-plus" - }, - "window_open_temperature": { - "default": "mdi:window-open-variant" - }, - "window_open_timeout": { - "default": "mdi:timer-refresh" - } - }, "switch": { "away": { "default": "mdi:home-account", diff --git a/homeassistant/components/eq3btsmart/manifest.json b/homeassistant/components/eq3btsmart/manifest.json index b30f806bf63..bd3f14939ca 100644 --- a/homeassistant/components/eq3btsmart/manifest.json +++ b/homeassistant/components/eq3btsmart/manifest.json @@ -23,5 +23,5 @@ "iot_class": "local_polling", "loggers": ["eq3btsmart"], "quality_scale": "silver", - "requirements": ["eq3btsmart==1.4.1", "bleak-esphome==1.1.0"] + "requirements": ["eq3btsmart==1.2.1", "bleak-esphome==1.1.0"] } diff --git a/homeassistant/components/eq3btsmart/models.py b/homeassistant/components/eq3btsmart/models.py index 858465effa8..8ea0955dbdd 100644 --- a/homeassistant/components/eq3btsmart/models.py +++ b/homeassistant/components/eq3btsmart/models.py @@ -2,6 +2,7 @@ from dataclasses import dataclass +from eq3btsmart.const import DEFAULT_AWAY_HOURS, DEFAULT_AWAY_TEMP from eq3btsmart.thermostat import Thermostat from .const import ( @@ -22,6 +23,8 @@ class Eq3Config: target_temp_selector: TargetTemperatureSelector = DEFAULT_TARGET_TEMP_SELECTOR external_temp_sensor: str = "" scan_interval: int = DEFAULT_SCAN_INTERVAL + default_away_hours: float = DEFAULT_AWAY_HOURS + default_away_temperature: float = DEFAULT_AWAY_TEMP @dataclass(slots=True) diff --git a/homeassistant/components/eq3btsmart/number.py b/homeassistant/components/eq3btsmart/number.py deleted file mode 100644 index 2e069180fa3..00000000000 --- a/homeassistant/components/eq3btsmart/number.py +++ /dev/null @@ -1,158 +0,0 @@ -"""Platform for eq3 number entities.""" - -from collections.abc import Awaitable, Callable -from dataclasses import dataclass -from typing import TYPE_CHECKING - -from eq3btsmart import Thermostat -from eq3btsmart.const import ( - EQ3BT_MAX_OFFSET, - EQ3BT_MAX_TEMP, - EQ3BT_MIN_OFFSET, - EQ3BT_MIN_TEMP, -) -from eq3btsmart.models import Presets - -from homeassistant.components.number import ( - NumberDeviceClass, - NumberEntity, - NumberEntityDescription, - NumberMode, -) -from homeassistant.const import EntityCategory, UnitOfTemperature, UnitOfTime -from homeassistant.core import HomeAssistant -from homeassistant.helpers.entity_platform import AddEntitiesCallback - -from . import Eq3ConfigEntry -from .const import ( - ENTITY_KEY_COMFORT, - ENTITY_KEY_ECO, - ENTITY_KEY_OFFSET, - ENTITY_KEY_WINDOW_OPEN_TEMPERATURE, - ENTITY_KEY_WINDOW_OPEN_TIMEOUT, - EQ3BT_STEP, -) -from .entity import Eq3Entity - - -@dataclass(frozen=True, kw_only=True) -class Eq3NumberEntityDescription(NumberEntityDescription): - """Entity description for eq3 number entities.""" - - value_func: Callable[[Presets], float] - value_set_func: Callable[ - [Thermostat], - Callable[[float], Awaitable[None]], - ] - mode: NumberMode = NumberMode.BOX - entity_category: EntityCategory | None = EntityCategory.CONFIG - - -NUMBER_ENTITY_DESCRIPTIONS = [ - Eq3NumberEntityDescription( - key=ENTITY_KEY_COMFORT, - value_func=lambda presets: presets.comfort_temperature.value, - value_set_func=lambda thermostat: thermostat.async_configure_comfort_temperature, - translation_key=ENTITY_KEY_COMFORT, - native_min_value=EQ3BT_MIN_TEMP, - native_max_value=EQ3BT_MAX_TEMP, - native_step=EQ3BT_STEP, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - device_class=NumberDeviceClass.TEMPERATURE, - ), - Eq3NumberEntityDescription( - key=ENTITY_KEY_ECO, - value_func=lambda presets: presets.eco_temperature.value, - value_set_func=lambda thermostat: thermostat.async_configure_eco_temperature, - translation_key=ENTITY_KEY_ECO, - native_min_value=EQ3BT_MIN_TEMP, - native_max_value=EQ3BT_MAX_TEMP, - native_step=EQ3BT_STEP, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - device_class=NumberDeviceClass.TEMPERATURE, - ), - Eq3NumberEntityDescription( - key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE, - value_func=lambda presets: presets.window_open_temperature.value, - value_set_func=lambda thermostat: thermostat.async_configure_window_open_temperature, - translation_key=ENTITY_KEY_WINDOW_OPEN_TEMPERATURE, - native_min_value=EQ3BT_MIN_TEMP, - native_max_value=EQ3BT_MAX_TEMP, - native_step=EQ3BT_STEP, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - device_class=NumberDeviceClass.TEMPERATURE, - ), - Eq3NumberEntityDescription( - key=ENTITY_KEY_OFFSET, - value_func=lambda presets: presets.offset_temperature.value, - value_set_func=lambda thermostat: thermostat.async_configure_temperature_offset, - translation_key=ENTITY_KEY_OFFSET, - native_min_value=EQ3BT_MIN_OFFSET, - native_max_value=EQ3BT_MAX_OFFSET, - native_step=EQ3BT_STEP, - native_unit_of_measurement=UnitOfTemperature.CELSIUS, - device_class=NumberDeviceClass.TEMPERATURE, - ), - Eq3NumberEntityDescription( - key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT, - value_set_func=lambda thermostat: thermostat.async_configure_window_open_duration, - value_func=lambda presets: presets.window_open_time.value.total_seconds() / 60, - translation_key=ENTITY_KEY_WINDOW_OPEN_TIMEOUT, - native_min_value=0, - native_max_value=60, - native_step=5, - native_unit_of_measurement=UnitOfTime.MINUTES, - ), -] - - -async def async_setup_entry( - hass: HomeAssistant, - entry: Eq3ConfigEntry, - async_add_entities: AddEntitiesCallback, -) -> None: - """Set up the entry.""" - - async_add_entities( - Eq3NumberEntity(entry, entity_description) - for entity_description in NUMBER_ENTITY_DESCRIPTIONS - ) - - -class Eq3NumberEntity(Eq3Entity, NumberEntity): - """Base class for all eq3 number entities.""" - - entity_description: Eq3NumberEntityDescription - - def __init__( - self, entry: Eq3ConfigEntry, entity_description: Eq3NumberEntityDescription - ) -> None: - """Initialize the entity.""" - - super().__init__(entry, entity_description.key) - self.entity_description = entity_description - - @property - def native_value(self) -> float: - """Return the state of the entity.""" - - if TYPE_CHECKING: - assert self._thermostat.status is not None - assert self._thermostat.status.presets is not None - - return self.entity_description.value_func(self._thermostat.status.presets) - - async def async_set_native_value(self, value: float) -> None: - """Set the state of the entity.""" - - await self.entity_description.value_set_func(self._thermostat)(value) - - @property - def available(self) -> bool: - """Return whether the entity is available.""" - - return ( - self._thermostat.status is not None - and self._thermostat.status.presets is not None - and self._attr_available - ) diff --git a/homeassistant/components/eq3btsmart/strings.json b/homeassistant/components/eq3btsmart/strings.json index acfd5082f45..03c3b21b964 100644 --- a/homeassistant/components/eq3btsmart/strings.json +++ b/homeassistant/components/eq3btsmart/strings.json @@ -25,23 +25,6 @@ "name": "Daylight saving time" } }, - "number": { - "comfort": { - "name": "Comfort temperature" - }, - "eco": { - "name": "Eco temperature" - }, - "offset": { - "name": "Offset temperature" - }, - "window_open_temperature": { - "name": "Window open temperature" - }, - "window_open_timeout": { - "name": "Window open timeout" - } - }, "switch": { "lock": { "name": "Lock" diff --git a/homeassistant/components/hunterdouglas_powerview/number.py b/homeassistant/components/hunterdouglas_powerview/number.py index fb8c9f76d79..f893b04b2d1 100644 --- a/homeassistant/components/hunterdouglas_powerview/number.py +++ b/homeassistant/components/hunterdouglas_powerview/number.py @@ -95,7 +95,7 @@ class PowerViewNumber(ShadeEntity, RestoreNumber): self.entity_description = description self._attr_unique_id = f"{self._attr_unique_id}_{description.key}" - async def async_set_native_value(self, value: float) -> None: + def set_native_value(self, value: float) -> None: """Update the current value.""" self._attr_native_value = value self.entity_description.store_value_fn(self.coordinator, self._shade.id, value) diff --git a/homeassistant/components/lcn/__init__.py b/homeassistant/components/lcn/__init__.py index eb26ef48e4e..27f911822b5 100644 --- a/homeassistant/components/lcn/__init__.py +++ b/homeassistant/components/lcn/__init__.py @@ -20,8 +20,7 @@ from homeassistant.const import ( Platform, ) from homeassistant.core import HomeAssistant -from homeassistant.helpers import config_validation as cv, device_registry as dr -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers import device_registry as dr from .const import ( ADD_ENTITIES_CALLBACKS, @@ -42,26 +41,15 @@ from .helpers import ( register_lcn_address_devices, register_lcn_host_device, ) -from .services import register_services +from .services import SERVICES from .websocket import register_panel_and_ws_api _LOGGER = logging.getLogger(__name__) -CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN) - - -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the LCN component.""" - hass.data.setdefault(DOMAIN, {}) - - await register_services(hass) - await register_panel_and_ws_api(hass) - - return True - async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up a connection to PCHK host from a config entry.""" + hass.data.setdefault(DOMAIN, {}) if config_entry.entry_id in hass.data[DOMAIN]: return False @@ -121,6 +109,15 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b ) lcn_connection.register_for_inputs(input_received) + # register service calls + for service_name, service in SERVICES: + if not hass.services.has_service(DOMAIN, service_name): + hass.services.async_register( + DOMAIN, service_name, service(hass).async_call_service, service.schema + ) + + await register_panel_and_ws_api(hass) + return True @@ -171,6 +168,11 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> host = hass.data[DOMAIN].pop(config_entry.entry_id) await host[CONNECTION].async_close() + # unregister service calls + if unload_ok and not hass.data[DOMAIN]: # check if this is the last entry to unload + for service_name, _ in SERVICES: + hass.services.async_remove(DOMAIN, service_name) + return unload_ok diff --git a/homeassistant/components/lcn/services.py b/homeassistant/components/lcn/services.py index 92f5863c47e..611a7353bcd 100644 --- a/homeassistant/components/lcn/services.py +++ b/homeassistant/components/lcn/services.py @@ -429,11 +429,3 @@ SERVICES = ( (LcnService.DYN_TEXT, DynText), (LcnService.PCK, Pck), ) - - -async def register_services(hass: HomeAssistant) -> None: - """Register services for LCN.""" - for service_name, service in SERVICES: - hass.services.async_register( - DOMAIN, service_name, service(hass).async_call_service, service.schema - ) diff --git a/homeassistant/components/reolink/manifest.json b/homeassistant/components/reolink/manifest.json index 7921bdb6ed5..22fd625770f 100644 --- a/homeassistant/components/reolink/manifest.json +++ b/homeassistant/components/reolink/manifest.json @@ -18,5 +18,5 @@ "documentation": "https://www.home-assistant.io/integrations/reolink", "iot_class": "local_push", "loggers": ["reolink_aio"], - "requirements": ["reolink-aio==0.11.1"] + "requirements": ["reolink-aio==0.11.0"] } diff --git a/homeassistant/components/ring/event.py b/homeassistant/components/ring/event.py index 71a4bc8aea5..e6d9d25542f 100644 --- a/homeassistant/components/ring/event.py +++ b/homeassistant/components/ring/event.py @@ -96,7 +96,7 @@ class RingEvent(RingBaseEntity[RingListenCoordinator, RingDeviceT], EventEntity) @callback def _handle_coordinator_update(self) -> None: - if (alert := self._get_coordinator_alert()) and not alert.is_update: + if alert := self._get_coordinator_alert(): self._async_handle_event(alert.kind) super()._handle_coordinator_update() diff --git a/homeassistant/components/roborock/coordinator.py b/homeassistant/components/roborock/coordinator.py index fe592074f71..20bc50f9855 100644 --- a/homeassistant/components/roborock/coordinator.py +++ b/homeassistant/components/roborock/coordinator.py @@ -2,6 +2,7 @@ from __future__ import annotations +import asyncio from datetime import timedelta import logging @@ -106,12 +107,8 @@ class RoborockDataUpdateCoordinator(DataUpdateCoordinator[DeviceProp]): async def _async_update_data(self) -> DeviceProp: """Update data via library.""" try: - # Update device props and standard api information - await self._update_device_prop() - # Set the new map id from the updated device props + await asyncio.gather(*(self._update_device_prop(), self.get_rooms())) self._set_current_map() - # Get the rooms for that map id. - await self.get_rooms() except RoborockException as ex: raise UpdateFailed(ex) from ex return self.roborock_device_info.props diff --git a/homeassistant/components/roborock/select.py b/homeassistant/components/roborock/select.py index 73cb95d2d7c..3dfe0e72a7b 100644 --- a/homeassistant/components/roborock/select.py +++ b/homeassistant/components/roborock/select.py @@ -135,9 +135,6 @@ class RoborockCurrentMapSelectEntity(RoborockCoordinatedEntityV1, SelectEntity): RoborockCommand.LOAD_MULTI_MAP, [map_id], ) - # Update the current map id manually so that nothing gets broken - # if another service hits the api. - self.coordinator.current_map = map_id # We need to wait after updating the map # so that other commands will be executed correctly. await asyncio.sleep(MAP_SLEEP) @@ -151,9 +148,6 @@ class RoborockCurrentMapSelectEntity(RoborockCoordinatedEntityV1, SelectEntity): @property def current_option(self) -> str | None: """Get the current status of the select entity from device_status.""" - if ( - (current_map := self.coordinator.current_map) is not None - and current_map in self.coordinator.maps - ): # 63 means it is searching for a map. + if (current_map := self.coordinator.current_map) is not None: return self.coordinator.maps[current_map].name return None diff --git a/homeassistant/components/ruckus_unleashed/manifest.json b/homeassistant/components/ruckus_unleashed/manifest.json index 8d56f3a5563..2066b65221e 100644 --- a/homeassistant/components/ruckus_unleashed/manifest.json +++ b/homeassistant/components/ruckus_unleashed/manifest.json @@ -7,5 +7,5 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["aioruckus"], - "requirements": ["aioruckus==0.42"] + "requirements": ["aioruckus==0.41"] } diff --git a/homeassistant/components/smarty/strings.json b/homeassistant/components/smarty/strings.json index 341a300a26e..188459b4f16 100644 --- a/homeassistant/components/smarty/strings.json +++ b/homeassistant/components/smarty/strings.json @@ -28,10 +28,6 @@ "deprecated_yaml_import_issue_auth_error": { "title": "YAML import failed due to an authentication error", "description": "Configuring {integration_title} using YAML is being removed but there was an authentication error while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your {integration_title} is operating correctly and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the `{domain}` configuration from your configuration.yaml entirely, restart Home Assistant, and add the {integration_title} integration manually." - }, - "deprecated_yaml_import_issue_cannot_connect": { - "title": "YAML import failed due to a connection error", - "description": "Configuring {integration_title} using YAML is being removed but there was a connect error while importing your existing configuration.\nSetup will not proceed.\n\nVerify that your {integration_title} is operating correctly and restart Home Assistant to attempt the import again.\n\nAlternatively, you may remove the `{domain}` configuration from your configuration.yaml entirely, restart Home Assistant, and add the {integration_title} integration manually." } }, "entity": { diff --git a/homeassistant/components/template/manifest.json b/homeassistant/components/template/manifest.json index f1225f74f06..57188aebaa3 100644 --- a/homeassistant/components/template/manifest.json +++ b/homeassistant/components/template/manifest.json @@ -2,7 +2,7 @@ "domain": "template", "name": "Template", "after_dependencies": ["group"], - "codeowners": ["@PhracturedBlue", "@home-assistant/core"], + "codeowners": ["@PhracturedBlue", "@tetienne", "@home-assistant/core"], "config_flow": true, "dependencies": ["blueprint"], "documentation": "https://www.home-assistant.io/integrations/template", diff --git a/homeassistant/components/tesla_fleet/oauth.py b/homeassistant/components/tesla_fleet/oauth.py index 8b43460436b..00976abf56f 100644 --- a/homeassistant/components/tesla_fleet/oauth.py +++ b/homeassistant/components/tesla_fleet/oauth.py @@ -49,7 +49,6 @@ class TeslaSystemImplementation(config_entry_oauth2_flow.LocalOAuth2Implementati def extra_authorize_data(self) -> dict[str, Any]: """Extra data that needs to be appended to the authorize url.""" return { - "prompt": "login", "scope": " ".join(SCOPES), "code_challenge": self.code_challenge, # PKCE } @@ -84,4 +83,4 @@ class TeslaUserImplementation(AuthImplementation): @property def extra_authorize_data(self) -> dict[str, Any]: """Extra data that needs to be appended to the authorize url.""" - return {"prompt": "login", "scope": " ".join(SCOPES)} + return {"scope": " ".join(SCOPES)} diff --git a/homeassistant/components/vodafone_station/sensor.py b/homeassistant/components/vodafone_station/sensor.py index 307fcaf0ea8..fb76253eb3d 100644 --- a/homeassistant/components/vodafone_station/sensor.py +++ b/homeassistant/components/vodafone_station/sensor.py @@ -22,7 +22,7 @@ from .const import _LOGGER, DOMAIN, LINE_TYPES from .coordinator import VodafoneStationRouter NOT_AVAILABLE: list = ["", "N/A", "0.0.0.0"] -UPTIME_DEVIATION = 60 +UPTIME_DEVIATION = 45 @dataclass(frozen=True, kw_only=True) diff --git a/homeassistant/components/zha/config_flow.py b/homeassistant/components/zha/config_flow.py index f3f7f38772d..1c7e0d105c4 100644 --- a/homeassistant/components/zha/config_flow.py +++ b/homeassistant/components/zha/config_flow.py @@ -33,7 +33,6 @@ from homeassistant.config_entries import ( from homeassistant.const import CONF_NAME from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError -from homeassistant.helpers.hassio import is_hassio from homeassistant.helpers.selector import FileSelector, FileSelectorConfig from homeassistant.util import dt as dt_util @@ -105,26 +104,25 @@ async def list_serial_ports(hass: HomeAssistant) -> list[ListPortInfo]: yellow_radio.description = "Yellow Zigbee module" yellow_radio.manufacturer = "Nabu Casa" - if is_hassio(hass): - # Present the multi-PAN addon as a setup option, if it's available - multipan_manager = ( - await silabs_multiprotocol_addon.get_multiprotocol_addon_manager(hass) + # Present the multi-PAN addon as a setup option, if it's available + multipan_manager = await silabs_multiprotocol_addon.get_multiprotocol_addon_manager( + hass + ) + + try: + addon_info = await multipan_manager.async_get_addon_info() + except (AddonError, KeyError): + addon_info = None + + if addon_info is not None and addon_info.state != AddonState.NOT_INSTALLED: + addon_port = ListPortInfo( + device=silabs_multiprotocol_addon.get_zigbee_socket(), + skip_link_detection=True, ) - try: - addon_info = await multipan_manager.async_get_addon_info() - except (AddonError, KeyError): - addon_info = None - - if addon_info is not None and addon_info.state != AddonState.NOT_INSTALLED: - addon_port = ListPortInfo( - device=silabs_multiprotocol_addon.get_zigbee_socket(), - skip_link_detection=True, - ) - - addon_port.description = "Multiprotocol add-on" - addon_port.manufacturer = "Nabu Casa" - ports.append(addon_port) + addon_port.description = "Multiprotocol add-on" + addon_port.manufacturer = "Nabu Casa" + ports.append(addon_port) return ports diff --git a/homeassistant/generated/bluetooth.py b/homeassistant/generated/bluetooth.py index a105efc2685..c4612898cb2 100644 --- a/homeassistant/generated/bluetooth.py +++ b/homeassistant/generated/bluetooth.py @@ -8,26 +8,6 @@ from __future__ import annotations from typing import Final BLUETOOTH: Final[list[dict[str, bool | str | int | list[int]]]] = [ - { - "domain": "acaia", - "manufacturer_id": 16962, - }, - { - "domain": "acaia", - "local_name": "ACAIA*", - }, - { - "domain": "acaia", - "local_name": "PYXIS-*", - }, - { - "domain": "acaia", - "local_name": "LUNAR-*", - }, - { - "domain": "acaia", - "local_name": "PROCHBT001", - }, { "domain": "airthings_ble", "manufacturer_id": 820, diff --git a/homeassistant/generated/config_flows.py b/homeassistant/generated/config_flows.py index ffe61b915c6..78e16126542 100644 --- a/homeassistant/generated/config_flows.py +++ b/homeassistant/generated/config_flows.py @@ -24,7 +24,6 @@ FLOWS = { ], "integration": [ "abode", - "acaia", "accuweather", "acmeda", "adax", diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index f007db87868..33a7d02776f 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -11,12 +11,6 @@ "config_flow": true, "iot_class": "cloud_push" }, - "acaia": { - "name": "Acaia", - "integration_type": "device", - "config_flow": true, - "iot_class": "local_push" - }, "accuweather": { "name": "AccuWeather", "integration_type": "service", diff --git a/requirements_all.txt b/requirements_all.txt index 65ef5f1ebf2..e9b5cb8129f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -172,9 +172,6 @@ aio-geojson-usgs-earthquakes==0.3 # homeassistant.components.gdacs aio-georss-gdacs==0.10 -# homeassistant.components.acaia -aioacaia==0.1.6 - # homeassistant.components.airq aioairq==0.3.2 @@ -182,7 +179,7 @@ aioairq==0.3.2 aioairzone-cloud==0.6.10 # homeassistant.components.airzone -aioairzone==0.9.6 +aioairzone==0.9.5 # homeassistant.components.ambient_network # homeassistant.components.ambient_station @@ -357,7 +354,7 @@ aiorecollect==2023.09.0 aioridwell==2024.01.0 # homeassistant.components.ruckus_unleashed -aioruckus==0.42 +aioruckus==0.41 # homeassistant.components.russound_rio aiorussound==4.1.0 @@ -384,7 +381,7 @@ aiosolaredge==0.2.0 aiosteamist==1.0.0 # homeassistant.components.cambridge_audio -aiostreammagic==2.8.5 +aiostreammagic==2.8.4 # homeassistant.components.switcher_kis aioswitcher==4.4.0 @@ -863,7 +860,7 @@ epion==0.0.3 epson-projector==0.5.1 # homeassistant.components.eq3btsmart -eq3btsmart==1.4.1 +eq3btsmart==1.2.1 # homeassistant.components.esphome esphome-dashboard-api==1.2.3 @@ -2556,7 +2553,7 @@ renault-api==0.2.7 renson-endura-delta==1.7.1 # homeassistant.components.reolink -reolink-aio==0.11.1 +reolink-aio==0.11.0 # homeassistant.components.idteck_prox rfk101py==0.0.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b61e65f3c68..de08e2db395 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -160,9 +160,6 @@ aio-geojson-usgs-earthquakes==0.3 # homeassistant.components.gdacs aio-georss-gdacs==0.10 -# homeassistant.components.acaia -aioacaia==0.1.6 - # homeassistant.components.airq aioairq==0.3.2 @@ -170,7 +167,7 @@ aioairq==0.3.2 aioairzone-cloud==0.6.10 # homeassistant.components.airzone -aioairzone==0.9.6 +aioairzone==0.9.5 # homeassistant.components.ambient_network # homeassistant.components.ambient_station @@ -339,7 +336,7 @@ aiorecollect==2023.09.0 aioridwell==2024.01.0 # homeassistant.components.ruckus_unleashed -aioruckus==0.42 +aioruckus==0.41 # homeassistant.components.russound_rio aiorussound==4.1.0 @@ -366,7 +363,7 @@ aiosolaredge==0.2.0 aiosteamist==1.0.0 # homeassistant.components.cambridge_audio -aiostreammagic==2.8.5 +aiostreammagic==2.8.4 # homeassistant.components.switcher_kis aioswitcher==4.4.0 @@ -732,7 +729,7 @@ epion==0.0.3 epson-projector==0.5.1 # homeassistant.components.eq3btsmart -eq3btsmart==1.4.1 +eq3btsmart==1.2.1 # homeassistant.components.esphome esphome-dashboard-api==1.2.3 @@ -2047,7 +2044,7 @@ renault-api==0.2.7 renson-endura-delta==1.7.1 # homeassistant.components.reolink -reolink-aio==0.11.1 +reolink-aio==0.11.0 # homeassistant.components.rflink rflink==0.0.66 diff --git a/requirements_top.txt b/requirements_top.txt new file mode 100644 index 00000000000..b8e04ab1e54 --- /dev/null +++ b/requirements_top.txt @@ -0,0 +1,1112 @@ +# Home Assistant Core, full dependency set +# Automatically generated by gen_requirements_all.py, do not edit + +-r requirements.txt + +# homeassistant.components.aemet +AEMET-OpenData==0.5.4 + +# homeassistant.components.honeywell +AIOSomecomfort==0.0.25 + +# homeassistant.components.doorbird +DoorBirdPy==3.0.8 + +# homeassistant.components.homekit +HAP-python==4.9.2 + +# homeassistant.components.tasmota +HATasmota==0.9.2 + +# homeassistant.components.doods +# homeassistant.components.generic +# homeassistant.components.image_upload +# homeassistant.components.matrix +# homeassistant.components.proxy +# homeassistant.components.qrcode +# homeassistant.components.seven_segments +# homeassistant.components.sighthound +# homeassistant.components.tensorflow +Pillow==11.0.0 + +# homeassistant.components.plex +PlexAPI==4.15.16 + +# homeassistant.components.cast +PyChromecast==14.0.5 + +# homeassistant.components.flume +PyFlume==0.6.5 + +# homeassistant.components.fronius +PyFronius==0.7.3 + +# homeassistant.components.met +# homeassistant.components.norway_air +PyMetno==0.13.0 + +# homeassistant.components.nina +PyNINA==0.3.3 + +# homeassistant.components.mobile_app +# homeassistant.components.owntracks +PyNaCl==1.5.0 + +# homeassistant.auth.mfa_modules.totp +# homeassistant.components.homekit +PyQRCode==1.2.1 + +# homeassistant.components.switchbot +PySwitchbot==0.51.0 + +# homeassistant.components.syncthru +PySyncThru==0.7.10 + +# homeassistant.components.camera +# homeassistant.components.stream +PyTurboJPEG==1.7.5 + +# homeassistant.components.vicare +PyViCare==2.35.0 + +# homeassistant.components.xiaomi_aqara +PyXiaomiGateway==0.14.3 + +# homeassistant.components.rachio +RachioPy==1.1.0 + +# homeassistant.components.python_script +RestrictedPython==7.4 + +# homeassistant.components.recorder +# homeassistant.components.sql +SQLAlchemy==2.0.31 + +# homeassistant.components.onvif +WSDiscovery==2.0.0 + +# homeassistant.components.accuweather +accuweather==3.0.0 + +# homeassistant.components.androidtv +adb-shell[async]==0.4.4 + +# homeassistant.components.adguard +adguardhome==0.7.0 + +# homeassistant.components.frontier_silicon +afsapi==0.2.7 + +# homeassistant.components.gdacs +aio-georss-gdacs==0.10 + +# homeassistant.components.ambient_network +# homeassistant.components.ambient_station +aioambient==2024.08.0 + +# homeassistant.components.apcupsd +aioapcaccess==0.4.2 + +# homeassistant.components.asuswrt +aioasuswrt==1.4.0 + +# homeassistant.components.husqvarna_automower +aioautomower==2024.10.3 + +# homeassistant.components.dhcp +aiodhcpwatcher==1.0.2 + +# homeassistant.components.dhcp +aiodiscover==2.1.0 + +# homeassistant.components.dnsip +aiodns==3.2.0 + +# homeassistant.components.ecowitt +aioecowitt==2024.2.1 + +# homeassistant.components.co2signal +aioelectricitymaps==0.4.0 + +# homeassistant.components.esphome +aioesphomeapi==27.0.1 + +# homeassistant.components.github +# homeassistant.components.iron_os +aiogithubapi==24.6.0 + +# homeassistant.components.harmony +aioharmony==0.2.10 + +# homeassistant.components.hassio +aiohasupervisor==0.2.1 + +# homeassistant.components.homekit_controller +aiohomekit==3.2.6 + +# homeassistant.components.hue +aiohue==4.7.3 + +# homeassistant.components.imap +aioimaplib==1.1.0 + +# homeassistant.components.lifx +aiolifx-effects==0.3.2 + +# homeassistant.components.lifx +aiolifx-themes==0.5.5 + +# homeassistant.components.lifx +aiolifx==1.1.1 + +# homeassistant.components.lyric +aiolyric==2.0.1 + +# homeassistant.components.yamaha_musiccast +aiomusiccast==0.14.8 + +# homeassistant.components.nanoleaf +aionanoleaf==0.2.1 + +# homeassistant.components.nut +aionut==4.3.3 + +# homeassistant.components.nmap_tracker +aiooui==0.1.7 + +# homeassistant.components.pvpc_hourly_pricing +aiopvpc==4.2.2 + +# homeassistant.components.lidarr +# homeassistant.components.radarr +# homeassistant.components.sonarr +aiopyarr==23.4.0 + +# homeassistant.components.shelly +aioshelly==12.0.1 + +# homeassistant.components.solaredge +aiosolaredge==0.2.0 + +# homeassistant.components.tankerkoenig +aiotankerkoenig==0.4.2 + +# homeassistant.components.tractive +aiotractive==0.6.0 + +# homeassistant.components.unifi +aiounifi==80 + +# homeassistant.components.vlc_telnet +aiovlc==0.5.1 + +# homeassistant.components.waqi +aiowaqi==3.1.0 + +# homeassistant.components.webostv +aiowebostv==0.4.2 + +# homeassistant.components.withings +aiowithings==3.1.3 + +# homeassistant.components.airthings_ble +airthings-ble==0.9.2 + +# homeassistant.components.airthings +airthings-cloud==0.2.0 + +# homeassistant.components.amcrest +amcrest==1.9.8 + +# homeassistant.components.androidtv +androidtv[async]==0.0.73 + +# homeassistant.components.androidtv_remote +androidtvremote2==0.1.2 + +# homeassistant.components.dlna_dmr +# homeassistant.components.dlna_dms +# homeassistant.components.samsungtv +# homeassistant.components.ssdp +# homeassistant.components.upnp +# homeassistant.components.yeelight +async-upnp-client==0.41.0 + +# homeassistant.components.sleepiq +asyncsleepiq==1.5.2 + +# homeassistant.components.aurora +auroranoaa==0.0.5 + +# homeassistant.components.generic +# homeassistant.components.stream +av==13.1.0 + +# homeassistant.components.axis +axis==63 + +# homeassistant.components.holiday +babel==2.15.0 + +# homeassistant.components.homekit +base36==0.1.1 + +# homeassistant.components.scrape +beautifulsoup4==4.12.3 + +# homeassistant.components.bmw_connected_drive +bimmer-connected[china]==0.16.4 + +# homeassistant.components.eq3btsmart +# homeassistant.components.esphome +bleak-esphome==1.1.0 + +# homeassistant.components.bluetooth +bleak-retry-connector==3.6.0 + +# homeassistant.components.bluetooth +bleak==0.22.3 + +# homeassistant.components.blink +blinkpy==0.23.0 + +# homeassistant.components.bluetooth +bluetooth-adapters==0.20.0 + +# homeassistant.components.bluetooth +bluetooth-auto-recovery==1.4.2 + +# homeassistant.components.bluetooth +# homeassistant.components.ld2410_ble +# homeassistant.components.led_ble +# homeassistant.components.private_ble_device +bluetooth-data-tools==1.20.0 + +# homeassistant.components.bond +bond-async==0.2.1 + +# homeassistant.components.bring +bring-api==0.9.1 + +# homeassistant.components.broadlink +broadlink==0.19.0 + +# homeassistant.components.brother +brother==4.3.1 + +# homeassistant.components.bthome +bthome-ble==3.9.1 + +# homeassistant.components.buienradar +buienradar==1.0.6 + +# homeassistant.components.dhcp +cached-ipaddress==0.8.0 + +# homeassistant.components.caldav +caldav==1.3.9 + +# homeassistant.components.xiaomi_miio +construct==2.10.68 + +# homeassistant.components.utility_meter +cronsim==2.6 + +# homeassistant.components.metoffice +datapoint==0.9.9 + +# homeassistant.components.bluetooth +dbus-fast==2.24.3 + +# homeassistant.components.ecovacs +deebot-client==8.4.1 + +# homeassistant.components.denonavr +denonavr==1.0.0 + +# homeassistant.components.devolo_home_network +devolo-plc-api==1.4.1 + +# homeassistant.components.dsmr +dsmr-parser==1.4.2 + +# homeassistant.components.dwd_weather_warnings +dwdwfsapi==1.0.7 + +# homeassistant.components.elgato +elgato==5.1.2 + +# homeassistant.components.emulated_roku +emulated-roku==0.3.0 + +# homeassistant.components.energyzero +energyzero==2.1.1 + +# homeassistant.components.environment_canada +env-canada==0.7.2 + +# homeassistant.components.season +ephem==4.1.6 + +# homeassistant.components.epic_games_store +epicstore-api==0.1.7 + +# homeassistant.components.esphome +esphome-dashboard-api==1.2.3 + +# homeassistant.components.evohome +evohome-async==0.4.20 + +# homeassistant.components.fastdotcom +fastdotcom==0.0.3 + +# homeassistant.components.feedreader +feedparser==6.0.11 + +# homeassistant.components.file +file-read-backwards==2.0.0 + +# homeassistant.components.flux_led +flux-led==1.0.4 + +# homeassistant.components.homekit +# homeassistant.components.recorder +fnv-hash-fast==1.0.2 + +# homeassistant.components.forecast_solar +forecast-solar==3.1.0 + +# homeassistant.components.freebox +freebox-api==1.1.0 + +# homeassistant.components.fritz +# homeassistant.components.fritzbox_callmonitor +fritzconnection[qr]==1.14.0 + +# homeassistant.components.google_translate +gTTS==2.2.4 + +# homeassistant.components.google_assistant_sdk +gassist-text==0.0.11 + +# homeassistant.components.google +gcal-sync==6.2.0 + +# homeassistant.components.dlna_dmr +# homeassistant.components.kef +# homeassistant.components.nmap_tracker +# homeassistant.components.samsungtv +# homeassistant.components.upnp +getmac==0.9.4 + +# homeassistant.components.glances +glances-api==0.8.0 + +# homeassistant.components.goodwe +goodwe==0.3.6 + +# homeassistant.components.google_mail +# homeassistant.components.google_tasks +google-api-python-client==2.71.0 + +# homeassistant.components.google_generative_ai_conversation +google-generativeai==0.8.2 + +# homeassistant.components.nest +google-nest-sdm==6.1.5 + +# homeassistant.components.google_travel_time +googlemaps==2.5.1 + +# homeassistant.components.govee_ble +govee-ble==0.40.0 + +# homeassistant.components.govee_light_local +govee-local-api==1.5.3 + +# homeassistant.components.gree +greeclimate==2.1.0 + +# homeassistant.components.growatt_server +growattServer==1.5.0 + +# homeassistant.components.google_sheets +gspread==5.5.0 + +# homeassistant.components.profiler +guppy3==3.1.4.post1;python_version<'3.13' + +# homeassistant.components.ffmpeg +ha-ffmpeg==3.2.2 + +# homeassistant.components.philips_js +ha-philipsjs==3.2.2 + +# homeassistant.components.bluetooth +habluetooth==3.6.0 + +# homeassistant.components.cloud +hass-nabucasa==0.84.0 + +# homeassistant.components.conversation +hassil==2.0.1 + +# homeassistant.components.pi_hole +hole==0.8.0 + +# homeassistant.components.holiday +# homeassistant.components.workday +holidays==0.60 + +# homeassistant.components.frontend +home-assistant-frontend==20241106.2 + +# homeassistant.components.conversation +home-assistant-intents==2024.11.13 + +# homeassistant.components.home_connect +homeconnect==0.8.0 + +# homeassistant.components.homematicip_cloud +homematicip==1.1.2 + +# homeassistant.components.hyperion +hyperion-py==0.7.5 + +# homeassistant.components.ibeacon +ibeacon-ble==1.2.0 + +# homeassistant.components.google +# homeassistant.components.local_calendar +# homeassistant.components.local_todo +ical==8.2.0 + +# homeassistant.components.ping +icmplib==3.0 + +# homeassistant.components.network +ifaddr==0.2.0 + +# homeassistant.components.influxdb +influxdb-client==1.24.0 + +# homeassistant.components.influxdb +influxdb==5.3.1 + +# homeassistant.components.inkbird +inkbird-ble==0.5.8 + +# homeassistant.components.insteon +insteon-frontend-home-assistant==0.5.0 + +# homeassistant.components.jellyfin +jellyfin-apiclient-python==1.9.2 + +# homeassistant.components.command_line +# homeassistant.components.rest +jsonpath==0.82.2 + +# homeassistant.components.knx +knx-frontend==2024.9.10.221729 + +# homeassistant.components.konnected +konnected==1.2.0 + +# homeassistant.components.ld2410_ble +ld2410-ble==0.1.1 + +# homeassistant.components.foscam +libpyfoscam==1.2.2 + +# homeassistant.components.mikrotik +librouteros==3.2.0 + +# homeassistant.components.soundtouch +libsoundtouch==0.8 + +# homeassistant.components.scrape +lxml==5.3.0 + +# homeassistant.components.minecraft_server +mcstatus==11.1.1 + +# homeassistant.components.meater +meater-python==0.0.8 + +# homeassistant.components.meteo_france +meteofrance-api==1.3.0 + +# homeassistant.components.xiaomi_miio +micloud==0.5 + +# homeassistant.components.mill +mill-local==0.3.0 + +# homeassistant.components.mill +millheater==0.12.2 + +# homeassistant.components.motion_blinds +motionblinds==0.6.25 + +# homeassistant.components.motioneye +motioneye-client==0.3.14 + +# homeassistant.components.tts +mutagen==1.47.0 + +# homeassistant.components.keenetic_ndms2 +ndms2-client==0.1.2 + +# homeassistant.components.nmap_tracker +netmap==0.7.0.2 + +# homeassistant.components.nextcloud +nextcloudmonitor==1.5.1 + +# homeassistant.components.discord +nextcord==2.6.0 + +# homeassistant.components.nfandroidtv +notifications-android-tv==0.1.5 + +# homeassistant.components.compensation +# homeassistant.components.iqvia +# homeassistant.components.stream +# homeassistant.components.tensorflow +# homeassistant.components.trend +numpy==2.1.3 + +# homeassistant.components.google +oauth2client==4.1.3 + +# homeassistant.components.profiler +objgraph==3.5.0 + +# homeassistant.components.ollama +ollama==0.3.3 + +# homeassistant.components.onvif +onvif-zeep-async==3.1.12 + +# homeassistant.components.open_meteo +open-meteo==0.3.1 + +# homeassistant.components.openai_conversation +openai==1.35.7 + +# homeassistant.components.opower +opower==0.8.6 + +# homeassistant.components.oralb +oralb-ble==0.17.6 + +# homeassistant.components.mqtt +paho-mqtt==1.6.1 + +# homeassistant.components.panasonic_viera +panasonic-viera==0.4.2 + +# homeassistant.components.plex +plexauth==0.0.6 + +# homeassistant.components.plex +plexwebsocket==0.0.14 + +# homeassistant.components.prometheus +prometheus-client==0.21.0 + +# homeassistant.components.proxmoxve +proxmoxer==2.0.1 + +# homeassistant.components.hardware +# homeassistant.components.recorder +# homeassistant.components.systemmonitor +psutil-home-assistant==0.0.1 + +# homeassistant.components.systemmonitor +psutil==6.1.0 + +# homeassistant.components.androidtv +pure-python-adb[async]==0.3.0.dev0 + +# homeassistant.components.pushbullet +pushbullet.py==0.11.0 + +# homeassistant.components.pushover +pushover_complete==1.1.1 + +# homeassistant.components.cpuspeed +py-cpuinfo==9.0.0 + +# homeassistant.components.ecovacs +py-sucks==0.9.10 + +# homeassistant.components.synology_dsm +py-synologydsm-api==2.5.3 + +# homeassistant.components.hikvision +pyHik==0.3.2 + +# homeassistant.components.rfxtrx +pyRFXtrx==0.31.1 + +# homeassistant.components.tibber +pyTibber==0.30.8 + +# homeassistant.components.airvisual +# homeassistant.components.airvisual_pro +pyairvisual==2023.08.1 + +# homeassistant.components.asuswrt +pyasuswrt==0.1.21 + +# homeassistant.components.netatmo +pyatmo==8.1.0 + +# homeassistant.components.apple_tv +pyatv==0.15.1 + +# homeassistant.components.braviatv +pybravia==0.3.4 + +# homeassistant.components.cloudflare +pycfdns==3.0.0 + +# homeassistant.components.radio_browser +pycountry==24.6.1 + +# homeassistant.components.daikin +pydaikin==2.13.7 + +# homeassistant.components.deconz +pydeconz==118 + +# homeassistant.components.hydrawise +pydrawise==2024.9.0 + +# homeassistant.components.android_ip_webcam +pydroid-ipcam==2.0.0 + +# homeassistant.components.econet +pyeconet==0.1.23 + +# homeassistant.components.onkyo +pyeiscp==0.0.7 + +# homeassistant.components.enphase_envoy +pyenphase==1.22.0 + +# homeassistant.components.ezviz +pyezviz==0.2.1.2 + +# homeassistant.components.fritzbox +pyfritzhome==0.6.12 + +# homeassistant.components.ifttt +pyfttt==0.3 + +# homeassistant.components.version +pyhaversion==22.8.0 + +# homeassistant.components.heos +pyheos==0.7.2 + +# homeassistant.components.hive +pyhiveapi==0.5.16 + +# homeassistant.components.homematic +pyhomematic==0.1.77 + +# homeassistant.components.icloud +pyicloud==1.0.0 + +# homeassistant.components.insteon +pyinsteon==1.6.3 + +# homeassistant.components.ipp +pyipp==0.17.0 + +# homeassistant.components.iss +pyiss==1.0.1 + +# homeassistant.components.kodi +pykodi==0.2.7 + +# homeassistant.components.kostal_plenticore +pykoplenti==1.2.2 + +# homeassistant.components.litterrobot +pylitterbot==2023.5.0 + +# homeassistant.components.lutron_caseta +pylutron-caseta==0.21.1 + +# homeassistant.components.melcloud +pymelcloud==2.5.9 + +# homeassistant.components.assist_pipeline +pymicro-vad==1.0.1 + +# homeassistant.components.modbus +pymodbus==3.6.9 + +# homeassistant.components.netgear +pynetgear==0.10.10 + +# homeassistant.components.nuki +pynuki==1.6.3 + +# homeassistant.components.nws +pynws[retry]==1.8.2 + +# homeassistant.components.octoprint +pyoctoprintapi==0.1.12 + +# homeassistant.components.openuv +pyopenuv==2023.02.0 + +# homeassistant.components.openweathermap +pyopenweathermap==0.2.1 + +# homeassistant.components.overkiz +pyoverkiz==1.14.1 + +# homeassistant.components.profiler +pyprof2calltree==1.4.5 + +# homeassistant.components.prusalink +pyprusalink==2.1.1 + +# homeassistant.components.ps4 +pyps4-2ndscreen==1.3.1 + +# homeassistant.components.rainbird +pyrainbird==6.0.1 + +# homeassistant.components.thread +pyroute2==0.7.5 + +# homeassistant.components.sabnzbd +pysabnzbd==1.1.1 + +# homeassistant.components.schlage +pyschlage==2024.8.0 + +# homeassistant.components.sensibo +pysensibo==1.1.0 + +# homeassistant.components.acer_projector +# homeassistant.components.crownstone +# homeassistant.components.usb +# homeassistant.components.zwave_js +pyserial==3.5 + +# homeassistant.components.seventeentrack +pyseventeentrack==1.0.1 + +# homeassistant.components.sma +pysma==0.7.3 + +# homeassistant.components.smartthings +pysmartapp==0.3.5 + +# homeassistant.components.smartthings +pysmartthings==0.7.8 + +# homeassistant.components.smlight +pysmlight==0.1.3 + +# homeassistant.components.assist_pipeline +pyspeex-noise==1.0.2 + +# homeassistant.components.squeezebox +pysqueezebox==0.10.0 + +# homeassistant.components.tautulli +pytautulli==23.1.1 + +# homeassistant.components.awair +python-awair==0.2.4 + +# homeassistant.components.ecobee +python-ecobee-api==0.2.20 + +# homeassistant.components.fully_kiosk +python-fullykiosk==0.0.14 + +# homeassistant.components.homewizard +python-homewizard-energy==v6.3.0 + +# homeassistant.components.tplink +python-kasa[speedups]==0.7.7 + +# homeassistant.components.linkplay +python-linkplay==0.0.20 + +# homeassistant.components.matter +python-matter-server==6.6.0 + +# homeassistant.components.xiaomi_miio +python-miio==0.5.12 + +# homeassistant.components.mpd +python-mpd2==3.1.1 + +# homeassistant.components.otbr +# homeassistant.components.thread +python-otbr-api==2.6.0 + +# homeassistant.components.roborock +python-roborock==2.7.2 + +# homeassistant.components.songpal +python-songpal==0.16.2 + +# homeassistant.components.tado +python-tado==0.17.7 + +# homeassistant.components.telegram_bot +python-telegram-bot[socks]==21.5 + +# homeassistant.components.tile +pytile==2023.12.0 + +# homeassistant.components.tomorrowio +pytomorrowio==0.3.6 + +# homeassistant.components.tradfri +pytradfri[async]==9.0.1 + +# homeassistant.components.usb +pyudev==0.24.1 + +# homeassistant.components.vesync +pyvesync==2.1.12 + +# homeassistant.components.vizio +pyvizio==0.1.61 + +# homeassistant.components.volumio +pyvolumio==0.1.5 + +# homeassistant.components.waze_travel_time +pywaze==1.0.2 + +# homeassistant.components.weatherflow +pyweatherflowudp==1.4.5 + +# homeassistant.components.html5 +pywebpush==1.14.1 + +# homeassistant.components.wemo +pywemo==1.4.0 + +# homeassistant.components.wiz +pywizlight==0.5.14 + +# homeassistant.components.qbittorrent +qbittorrent-api==2024.2.59 + +# homeassistant.components.qnap +qnapstats==0.4.0 + +# homeassistant.components.radio_browser +radios==0.3.2 + +# homeassistant.components.renault +renault-api==0.2.7 + +# homeassistant.components.reolink +reolink-aio==0.11.0 + +# homeassistant.components.ring +ring-doorbell==0.9.12 + +# homeassistant.components.roku +rokuecp==0.19.3 + +# homeassistant.components.roomba +roombapy==1.8.1 + +# homeassistant.components.rpi_power +rpi-bad-power==0.1.0 + +# homeassistant.components.rtsp_to_webrtc +rtsp-to-webrtc==0.5.1 + +# homeassistant.components.ruuvitag_ble +ruuvitag-ble==0.1.2 + +# homeassistant.components.samsungtv +samsungctl[websocket]==0.7.1 + +# homeassistant.components.samsungtv +samsungtvws[async,encrypted]==2.6.0 + +# homeassistant.components.backup +securetar==2024.2.1 + +# homeassistant.components.emulated_kasa +# homeassistant.components.sense +sense-energy==0.13.3 + +# homeassistant.components.sharkiq +sharkiq==1.0.2 + +# homeassistant.components.simplisafe +simplisafe-python==2024.01.0 + +# homeassistant.components.smhi +smhi-pkg==1.0.18 + +# homeassistant.components.sonos +soco==0.30.6 + +# homeassistant.components.sonos +sonos-websocket==0.1.3 + +# homeassistant.components.speedtestdotnet +speedtest-cli==2.1.3 + +# homeassistant.components.spotify +spotifyaio==0.8.8 + +# homeassistant.components.sql +sqlparse==0.5.0 + +# homeassistant.components.steam_online +steamodd==4.21 + +# homeassistant.components.huawei_lte +# homeassistant.components.solaredge +# homeassistant.components.traccar +stringcase==1.2.0 + +# homeassistant.components.surepetcare +surepy==0.9.0 + +# homeassistant.components.switchbot_cloud +switchbot-api==2.2.1 + +# homeassistant.components.tailscale +tailscale==0.6.1 + +# homeassistant.components.tesla_fleet +# homeassistant.components.teslemetry +# homeassistant.components.tessie +tesla-fleet-api==0.8.4 + +# homeassistant.components.powerwall +tesla-powerwall==0.5.2 + +# homeassistant.components.tesla_wall_connector +tesla-wall-connector==1.0.2 + +# homeassistant.components.thermopro +thermopro-ble==0.10.0 + +# homeassistant.components.lg_thinq +thinqconnect==1.0.0 + +# homeassistant.components.todoist +todoist-api-python==2.1.2 + +# homeassistant.components.tplink_omada +tplink-omada-client==1.4.3 + +# homeassistant.components.transmission +transmission-rpc==7.0.3 + +# homeassistant.components.twinkly +ttls==1.8.3 + +# homeassistant.components.tuya +tuya-device-sharing-sdk==0.2.1 + +# homeassistant.components.twilio +twilio==6.32.0 + +# homeassistant.components.unifiprotect +uiprotect==6.4.0 + +# homeassistant.components.unifiprotect +unifi-discovery==1.2.0 + +# homeassistant.components.zha +universal-silabs-flasher==0.0.24 + +# homeassistant.components.huawei_lte +# homeassistant.components.syncthru +# homeassistant.components.zwave_me +url-normalize==1.4.3 + +# homeassistant.components.roborock +vacuum-map-parser-roborock==0.1.2 + +# homeassistant.components.voip +voip-utils==0.1.0 + +# homeassistant.components.volvooncall +volvooncall==0.10.3 + +# homeassistant.components.verisure +vsure==2.6.7 + +# homeassistant.components.samsungtv +# homeassistant.components.wake_on_lan +wakeonlan==2.1.0 + +# homeassistant.components.wallbox +wallbox==0.7.0 + +# homeassistant.components.wled +wled==0.20.2 + +# homeassistant.components.wyoming +wyoming==1.5.4 + +# homeassistant.components.xbox +xbox-webapi==2.0.11 + +# homeassistant.components.xiaomi_ble +xiaomi-ble==0.33.0 + +# homeassistant.components.knx +xknx==3.3.0 + +# homeassistant.components.knx +xknxproject==3.8.1 + +# homeassistant.components.fritz +# homeassistant.components.rest +# homeassistant.components.startca +# homeassistant.components.ted5000 +# homeassistant.components.zestimate +xmltodict==0.13.0 + +# homeassistant.components.august +# homeassistant.components.yale +# homeassistant.components.yalexs_ble +yalexs-ble==2.5.0 + +# homeassistant.components.august +# homeassistant.components.yale +yalexs==8.10.0 + +# homeassistant.components.yeelight +yeelight==0.7.14 + +# homeassistant.components.yolink +yolink-api==0.4.7 + +# homeassistant.components.media_extractor +yt-dlp[default]==2024.11.04 + +# homeassistant.components.zeroconf +zeroconf==0.136.0 + +# homeassistant.components.zha +zha==0.0.37 + +# homeassistant.components.zwave_js +zwave-js-server-python==0.59.1 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 7d53741c661..fd8c4f4b88e 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -3,6 +3,7 @@ from __future__ import annotations +import asyncio import difflib import importlib from operator import itemgetter @@ -13,6 +14,11 @@ import sys import tomllib from typing import Any +from python_homeassistant_analytics import ( + CurrentAnalytics, + HomeassistantAnalyticsClient, +) + from homeassistant.util.yaml.loader import load_yaml from script.hassfest.model import Config, Integration @@ -551,6 +557,11 @@ def diff_file(filename: str, content: str) -> list[str]: ) +async def _get_analytics() -> CurrentAnalytics: + client = HomeassistantAnalyticsClient() + return await client.get_current_analytics() + + def main(validate: bool, ci: bool) -> int: """Run the script.""" if not Path("requirements_all.txt").is_file(): @@ -587,6 +598,26 @@ def main(validate: bool, ci: bool) -> int: for action, reqs_all_file in reqs_all_action_files.items() ) + # Get analytics data + analytics = asyncio.get_event_loop().run_until_complete(_get_analytics()) + top_integrations = [f"homeassistant.components.{i}" for i, c in analytics.integrations.items() if c > 1000] + + top = top_integrations + + data_top = {} + + for req, integrations in data.items(): + for integration in integrations: + if integration in top: + data_top[req] = integrations + + files.append( + ( + "requirements_top.txt", + requirements_all_output(data_top), + ) + ) + if validate: errors = [] diff --git a/script/hassfest/docker.py b/script/hassfest/docker.py index 57d86bc4def..137bbc7ff66 100644 --- a/script/hassfest/docker.py +++ b/script/hassfest/docker.py @@ -80,7 +80,7 @@ WORKDIR /config _HASSFEST_TEMPLATE = r"""# Automatically generated by hassfest. # # To update, run python3 -m script.hassfest -p docker -FROM python:3.13-alpine +FROM python:3.12-alpine ENV \ UV_SYSTEM_PYTHON=true \ @@ -161,8 +161,6 @@ def _generate_hassfest_dockerimage( packages.update( gather_recursive_requirements(platform.value, already_checked_domains) ) - # Add go2rtc requirements as this file needs the go2rtc integration - packages.update(gather_recursive_requirements("go2rtc", already_checked_domains)) return File( _HASSFEST_TEMPLATE.format( diff --git a/script/hassfest/docker/Dockerfile b/script/hassfest/docker/Dockerfile index 0fa0a1a89fa..c921cf0e186 100644 --- a/script/hassfest/docker/Dockerfile +++ b/script/hassfest/docker/Dockerfile @@ -1,7 +1,7 @@ # Automatically generated by hassfest. # # To update, run python3 -m script.hassfest -p docker -FROM python:3.13-alpine +FROM python:3.12-alpine ENV \ UV_SYSTEM_PYTHON=true \ @@ -23,7 +23,7 @@ RUN --mount=from=ghcr.io/astral-sh/uv:0.5.0,source=/uv,target=/bin/uv \ -c /usr/src/homeassistant/homeassistant/package_constraints.txt \ -r /usr/src/homeassistant/requirements.txt \ stdlib-list==0.10.0 pipdeptree==2.23.4 tqdm==4.66.5 ruff==0.7.3 \ - PyTurboJPEG==1.7.5 go2rtc-client==0.1.1 ha-ffmpeg==3.2.2 hassil==2.0.1 home-assistant-intents==2024.11.13 mutagen==1.47.0 pymicro-vad==1.0.1 pyspeex-noise==1.0.2 + PyTurboJPEG==1.7.5 ha-ffmpeg==3.2.2 hassil==2.0.1 home-assistant-intents==2024.11.13 mutagen==1.47.0 pymicro-vad==1.0.1 pyspeex-noise==1.0.2 LABEL "name"="hassfest" LABEL "maintainer"="Home Assistant " diff --git a/tests/components/acaia/__init__.py b/tests/components/acaia/__init__.py deleted file mode 100644 index f4eaa39e615..00000000000 --- a/tests/components/acaia/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -"""Common test tools for the acaia integration.""" - -from homeassistant.core import HomeAssistant - -from tests.common import MockConfigEntry - - -async def setup_integration( - hass: HomeAssistant, mock_config_entry: MockConfigEntry -) -> None: - """Set up the acaia integration for testing.""" - mock_config_entry.add_to_hass(hass) - await hass.config_entries.async_setup(mock_config_entry.entry_id) - await hass.async_block_till_done() diff --git a/tests/components/acaia/conftest.py b/tests/components/acaia/conftest.py deleted file mode 100644 index 1dc6ff31051..00000000000 --- a/tests/components/acaia/conftest.py +++ /dev/null @@ -1,80 +0,0 @@ -"""Common fixtures for the acaia tests.""" - -from collections.abc import Generator -from unittest.mock import AsyncMock, MagicMock, patch - -from aioacaia.acaiascale import AcaiaDeviceState -from aioacaia.const import UnitMass as AcaiaUnitOfMass -import pytest - -from homeassistant.components.acaia.const import CONF_IS_NEW_STYLE_SCALE, DOMAIN -from homeassistant.const import CONF_ADDRESS -from homeassistant.core import HomeAssistant - -from . import setup_integration - -from tests.common import MockConfigEntry - - -@pytest.fixture -def mock_setup_entry() -> Generator[AsyncMock]: - """Override async_setup_entry.""" - with patch( - "homeassistant.components.acaia.async_setup_entry", return_value=True - ) as mock_setup_entry: - yield mock_setup_entry - - -@pytest.fixture -def mock_verify() -> Generator[AsyncMock]: - """Override is_new_scale check.""" - with patch( - "homeassistant.components.acaia.config_flow.is_new_scale", return_value=True - ) as mock_verify: - yield mock_verify - - -@pytest.fixture -def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry: - """Return the default mocked config entry.""" - return MockConfigEntry( - title="LUNAR-DDEEFF", - domain=DOMAIN, - version=1, - data={ - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - CONF_IS_NEW_STYLE_SCALE: True, - }, - unique_id="aa:bb:cc:dd:ee:ff", - ) - - -@pytest.fixture -async def init_integration( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_scale: MagicMock -) -> None: - """Set up the acaia integration for testing.""" - await setup_integration(hass, mock_config_entry) - - -@pytest.fixture -def mock_scale() -> Generator[MagicMock]: - """Return a mocked acaia scale client.""" - with ( - patch( - "homeassistant.components.acaia.coordinator.AcaiaScale", - autospec=True, - ) as scale_mock, - ): - scale = scale_mock.return_value - scale.connected = True - scale.mac = "aa:bb:cc:dd:ee:ff" - scale.model = "Lunar" - scale.timer_running = True - scale.heartbeat_task = None - scale.process_queue_task = None - scale.device_state = AcaiaDeviceState( - battery_level=42, units=AcaiaUnitOfMass.GRAMS - ) - scale.weight = 123.45 - yield scale diff --git a/tests/components/acaia/snapshots/test_button.ambr b/tests/components/acaia/snapshots/test_button.ambr deleted file mode 100644 index cd91ca1a17a..00000000000 --- a/tests/components/acaia/snapshots/test_button.ambr +++ /dev/null @@ -1,139 +0,0 @@ -# serializer version: 1 -# name: test_buttons[button.lunar_ddeeff_reset_timer-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'button', - 'entity_category': None, - 'entity_id': 'button.lunar_ddeeff_reset_timer', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Reset timer', - 'platform': 'acaia', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'reset_timer', - 'unique_id': 'aa:bb:cc:dd:ee:ff_reset_timer', - 'unit_of_measurement': None, - }) -# --- -# name: test_buttons[button.lunar_ddeeff_reset_timer-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'LUNAR-DDEEFF Reset timer', - }), - 'context': , - 'entity_id': 'button.lunar_ddeeff_reset_timer', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_buttons[button.lunar_ddeeff_start_stop_timer-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'button', - 'entity_category': None, - 'entity_id': 'button.lunar_ddeeff_start_stop_timer', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Start/stop timer', - 'platform': 'acaia', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'start_stop', - 'unique_id': 'aa:bb:cc:dd:ee:ff_start_stop', - 'unit_of_measurement': None, - }) -# --- -# name: test_buttons[button.lunar_ddeeff_start_stop_timer-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'LUNAR-DDEEFF Start/stop timer', - }), - 'context': , - 'entity_id': 'button.lunar_ddeeff_start_stop_timer', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- -# name: test_buttons[button.lunar_ddeeff_tare-entry] - EntityRegistryEntrySnapshot({ - 'aliases': set({ - }), - 'area_id': None, - 'capabilities': None, - 'config_entry_id': , - 'device_class': None, - 'device_id': , - 'disabled_by': None, - 'domain': 'button', - 'entity_category': None, - 'entity_id': 'button.lunar_ddeeff_tare', - 'has_entity_name': True, - 'hidden_by': None, - 'icon': None, - 'id': , - 'labels': set({ - }), - 'name': None, - 'options': dict({ - }), - 'original_device_class': None, - 'original_icon': None, - 'original_name': 'Tare', - 'platform': 'acaia', - 'previous_unique_id': None, - 'supported_features': 0, - 'translation_key': 'tare', - 'unique_id': 'aa:bb:cc:dd:ee:ff_tare', - 'unit_of_measurement': None, - }) -# --- -# name: test_buttons[button.lunar_ddeeff_tare-state] - StateSnapshot({ - 'attributes': ReadOnlyDict({ - 'friendly_name': 'LUNAR-DDEEFF Tare', - }), - 'context': , - 'entity_id': 'button.lunar_ddeeff_tare', - 'last_changed': , - 'last_reported': , - 'last_updated': , - 'state': 'unknown', - }) -# --- diff --git a/tests/components/acaia/snapshots/test_init.ambr b/tests/components/acaia/snapshots/test_init.ambr deleted file mode 100644 index 1cc3d8dbbc0..00000000000 --- a/tests/components/acaia/snapshots/test_init.ambr +++ /dev/null @@ -1,33 +0,0 @@ -# serializer version: 1 -# name: test_device - DeviceRegistryEntrySnapshot({ - 'area_id': 'kitchen', - 'config_entries': , - 'configuration_url': None, - 'connections': set({ - }), - 'disabled_by': None, - 'entry_type': None, - 'hw_version': None, - 'id': , - 'identifiers': set({ - tuple( - 'acaia', - 'aa:bb:cc:dd:ee:ff', - ), - }), - 'is_new': False, - 'labels': set({ - }), - 'manufacturer': 'Acaia', - 'model': 'Lunar', - 'model_id': None, - 'name': 'LUNAR-DDEEFF', - 'name_by_user': None, - 'primary_config_entry': , - 'serial_number': None, - 'suggested_area': 'Kitchen', - 'sw_version': None, - 'via_device_id': None, - }) -# --- diff --git a/tests/components/acaia/test_button.py b/tests/components/acaia/test_button.py deleted file mode 100644 index f68f85e253d..00000000000 --- a/tests/components/acaia/test_button.py +++ /dev/null @@ -1,90 +0,0 @@ -"""Tests for the acaia buttons.""" - -from datetime import timedelta -from unittest.mock import MagicMock, patch - -from freezegun.api import FrozenDateTimeFactory -from syrupy import SnapshotAssertion - -from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS -from homeassistant.const import ( - ATTR_ENTITY_ID, - STATE_UNAVAILABLE, - STATE_UNKNOWN, - Platform, -) -from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity_registry as er - -from . import setup_integration - -from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform - -BUTTONS = ( - "tare", - "reset_timer", - "start_stop_timer", -) - - -async def test_buttons( - hass: HomeAssistant, - entity_registry: er.EntityRegistry, - snapshot: SnapshotAssertion, - mock_scale: MagicMock, - mock_config_entry: MockConfigEntry, -) -> None: - """Test the acaia buttons.""" - - with patch("homeassistant.components.acaia.PLATFORMS", [Platform.BUTTON]): - await setup_integration(hass, mock_config_entry) - await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) - - -async def test_button_presses( - hass: HomeAssistant, - mock_scale: MagicMock, - mock_config_entry: MockConfigEntry, -) -> None: - """Test the acaia button presses.""" - - await setup_integration(hass, mock_config_entry) - - for button in BUTTONS: - await hass.services.async_call( - BUTTON_DOMAIN, - SERVICE_PRESS, - { - ATTR_ENTITY_ID: f"button.lunar_ddeeff_{button}", - }, - blocking=True, - ) - - function = getattr(mock_scale, button) - function.assert_called_once() - - -async def test_buttons_unavailable_on_disconnected_scale( - hass: HomeAssistant, - mock_scale: MagicMock, - mock_config_entry: MockConfigEntry, - freezer: FrozenDateTimeFactory, -) -> None: - """Test the acaia buttons are unavailable when the scale is disconnected.""" - - await setup_integration(hass, mock_config_entry) - - for button in BUTTONS: - state = hass.states.get(f"button.lunar_ddeeff_{button}") - assert state - assert state.state == STATE_UNKNOWN - - mock_scale.connected = False - freezer.tick(timedelta(minutes=10)) - async_fire_time_changed(hass) - await hass.async_block_till_done() - - for button in BUTTONS: - state = hass.states.get(f"button.lunar_ddeeff_{button}") - assert state - assert state.state == STATE_UNAVAILABLE diff --git a/tests/components/acaia/test_config_flow.py b/tests/components/acaia/test_config_flow.py deleted file mode 100644 index 2bf4b1dbe8a..00000000000 --- a/tests/components/acaia/test_config_flow.py +++ /dev/null @@ -1,242 +0,0 @@ -"""Test the acaia config flow.""" - -from collections.abc import Generator -from unittest.mock import AsyncMock, patch - -from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError, AcaiaUnknownDevice -import pytest - -from homeassistant.components.acaia.const import CONF_IS_NEW_STYLE_SCALE, DOMAIN -from homeassistant.config_entries import SOURCE_BLUETOOTH, SOURCE_USER -from homeassistant.const import CONF_ADDRESS -from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResultType -from homeassistant.helpers.service_info.bluetooth import BluetoothServiceInfo - -from tests.common import MockConfigEntry - -service_info = BluetoothServiceInfo( - name="LUNAR-DDEEFF", - address="aa:bb:cc:dd:ee:ff", - rssi=-63, - manufacturer_data={}, - service_data={}, - service_uuids=[], - source="local", -) - - -@pytest.fixture -def mock_discovered_service_info() -> Generator[AsyncMock]: - """Override getting Bluetooth service info.""" - with patch( - "homeassistant.components.acaia.config_flow.async_discovered_service_info", - return_value=[service_info], - ) as mock_discovered_service_info: - yield mock_discovered_service_info - - -async def test_form( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_verify: AsyncMock, - mock_discovered_service_info: AsyncMock, -) -> None: - """Test we get the form.""" - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER} - ) - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "user" - - user_input = { - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - } - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - user_input=user_input, - ) - - assert result2["type"] is FlowResultType.CREATE_ENTRY - assert result2["title"] == "LUNAR-DDEEFF" - assert result2["data"] == { - **user_input, - CONF_IS_NEW_STYLE_SCALE: True, - } - - -async def test_bluetooth_discovery( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_verify: AsyncMock, -) -> None: - """Test we can discover a device.""" - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_BLUETOOTH}, data=service_info - ) - - assert result["type"] is FlowResultType.FORM - assert result["step_id"] == "bluetooth_confirm" - - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - user_input={}, - ) - - assert result2["type"] is FlowResultType.CREATE_ENTRY - assert result2["title"] == service_info.name - assert result2["data"] == { - CONF_ADDRESS: service_info.address, - CONF_IS_NEW_STYLE_SCALE: True, - } - - -@pytest.mark.parametrize( - ("exception", "error"), - [ - (AcaiaDeviceNotFound("Error"), "device_not_found"), - (AcaiaError, "unknown"), - (AcaiaUnknownDevice, "unsupported_device"), - ], -) -async def test_bluetooth_discovery_errors( - hass: HomeAssistant, - mock_verify: AsyncMock, - exception: Exception, - error: str, -) -> None: - """Test abortions of Bluetooth discovery.""" - mock_verify.side_effect = exception - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_BLUETOOTH}, data=service_info - ) - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == error - - -async def test_already_configured( - hass: HomeAssistant, - mock_config_entry: MockConfigEntry, - mock_verify: AsyncMock, - mock_discovered_service_info: AsyncMock, -) -> None: - """Ensure we can't add the same device twice.""" - - mock_config_entry.add_to_hass(hass) - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER} - ) - assert result["type"] is FlowResultType.FORM - - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - { - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - }, - ) - await hass.async_block_till_done() - - assert result2["type"] is FlowResultType.ABORT - assert result2["reason"] == "already_configured" - - -async def test_already_configured_bluetooth_discovery( - hass: HomeAssistant, - mock_config_entry: MockConfigEntry, -) -> None: - """Ensure configure device is not discovered again.""" - - mock_config_entry.add_to_hass(hass) - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_BLUETOOTH}, data=service_info - ) - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" - - -@pytest.mark.parametrize( - ("exception", "error"), - [ - (AcaiaDeviceNotFound("Error"), "device_not_found"), - (AcaiaError, "unknown"), - ], -) -async def test_recoverable_config_flow_errors( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_verify: AsyncMock, - mock_discovered_service_info: AsyncMock, - exception: Exception, - error: str, -) -> None: - """Test recoverable errors.""" - mock_verify.side_effect = exception - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER} - ) - assert result["type"] is FlowResultType.FORM - - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - { - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - }, - ) - - assert result2["type"] is FlowResultType.FORM - assert result2["errors"] == {"base": error} - - # recover - mock_verify.side_effect = None - result3 = await hass.config_entries.flow.async_configure( - result2["flow_id"], - { - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - }, - ) - assert result3["type"] is FlowResultType.CREATE_ENTRY - - -async def test_unsupported_device( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_verify: AsyncMock, - mock_discovered_service_info: AsyncMock, -) -> None: - """Test flow aborts on unsupported device.""" - mock_verify.side_effect = AcaiaUnknownDevice - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER} - ) - assert result["type"] is FlowResultType.FORM - - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - { - CONF_ADDRESS: "aa:bb:cc:dd:ee:ff", - }, - ) - - assert result2["type"] is FlowResultType.ABORT - assert result2["reason"] == "unsupported_device" - - -async def test_no_bluetooth_devices( - hass: HomeAssistant, - mock_setup_entry: AsyncMock, - mock_discovered_service_info: AsyncMock, -) -> None: - """Test flow aborts on unsupported device.""" - mock_discovered_service_info.return_value = [] - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_USER} - ) - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "no_devices_found" diff --git a/tests/components/acaia/test_init.py b/tests/components/acaia/test_init.py deleted file mode 100644 index 8ad988d3b9b..00000000000 --- a/tests/components/acaia/test_init.py +++ /dev/null @@ -1,65 +0,0 @@ -"""Test init of acaia integration.""" - -from datetime import timedelta -from unittest.mock import MagicMock - -from aioacaia.exceptions import AcaiaDeviceNotFound, AcaiaError -from freezegun.api import FrozenDateTimeFactory -import pytest -from syrupy import SnapshotAssertion - -from homeassistant.components.acaia.const import DOMAIN -from homeassistant.config_entries import ConfigEntryState -from homeassistant.core import HomeAssistant -from homeassistant.helpers import device_registry as dr - -from tests.common import MockConfigEntry, async_fire_time_changed - -pytestmark = pytest.mark.usefixtures("init_integration") - - -async def test_load_unload_config_entry( - hass: HomeAssistant, - mock_config_entry: MockConfigEntry, -) -> None: - """Test loading and unloading the integration.""" - - assert mock_config_entry.state is ConfigEntryState.LOADED - - await hass.config_entries.async_unload(mock_config_entry.entry_id) - await hass.async_block_till_done() - - assert mock_config_entry.state is ConfigEntryState.NOT_LOADED - - -@pytest.mark.parametrize( - "exception", [AcaiaError, AcaiaDeviceNotFound("Boom"), TimeoutError] -) -async def test_update_exception_leads_to_active_disconnect( - hass: HomeAssistant, - mock_scale: MagicMock, - freezer: FrozenDateTimeFactory, - exception: Exception, -) -> None: - """Test scale gets disconnected on exception.""" - - mock_scale.connect.side_effect = exception - mock_scale.connected = False - - freezer.tick(timedelta(minutes=10)) - async_fire_time_changed(hass) - await hass.async_block_till_done() - - mock_scale.device_disconnected_handler.assert_called_once() - - -async def test_device( - mock_scale: MagicMock, - device_registry: dr.DeviceRegistry, - snapshot: SnapshotAssertion, -) -> None: - """Snapshot the device from registry.""" - - device = device_registry.async_get_device({(DOMAIN, mock_scale.mac)}) - assert device - assert device == snapshot diff --git a/tests/components/camera/test_webrtc.py b/tests/components/camera/test_webrtc.py index 29fb9d61c4e..ba5cf35c52f 100644 --- a/tests/components/camera/test_webrtc.py +++ b/tests/components/camera/test_webrtc.py @@ -139,46 +139,42 @@ async def init_test_integration( return test_camera -@pytest.mark.usefixtures("mock_camera", "mock_stream_source") +@pytest.mark.usefixtures("mock_camera", "mock_stream", "mock_stream_source") async def test_async_register_webrtc_provider( hass: HomeAssistant, ) -> None: """Test registering a WebRTC provider.""" + await async_setup_component(hass, "camera", {}) + camera = get_camera_from_entity_id(hass, "camera.demo_camera") - assert camera.camera_capabilities.frontend_stream_types == {StreamType.HLS} + assert camera.frontend_stream_type is StreamType.HLS provider = SomeTestProvider() unregister = async_register_webrtc_provider(hass, provider) await hass.async_block_till_done() - assert camera.camera_capabilities.frontend_stream_types == { - StreamType.HLS, - StreamType.WEB_RTC, - } + assert camera.frontend_stream_type is StreamType.WEB_RTC # Mark stream as unsupported provider._is_supported = False # Manually refresh the provider await camera.async_refresh_providers() - assert camera.camera_capabilities.frontend_stream_types == {StreamType.HLS} + assert camera.frontend_stream_type is StreamType.HLS # Mark stream as supported provider._is_supported = True # Manually refresh the provider await camera.async_refresh_providers() - assert camera.camera_capabilities.frontend_stream_types == { - StreamType.HLS, - StreamType.WEB_RTC, - } + assert camera.frontend_stream_type is StreamType.WEB_RTC unregister() await hass.async_block_till_done() - assert camera.camera_capabilities.frontend_stream_types == {StreamType.HLS} + assert camera.frontend_stream_type is StreamType.HLS -@pytest.mark.usefixtures("mock_camera", "mock_stream_source") +@pytest.mark.usefixtures("mock_camera", "mock_stream", "mock_stream_source") async def test_async_register_webrtc_provider_twice( hass: HomeAssistant, register_test_provider: SomeTestProvider, @@ -196,11 +192,13 @@ async def test_async_register_webrtc_provider_camera_not_loaded( async_register_webrtc_provider(hass, SomeTestProvider()) -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera", "mock_stream", "mock_stream_source") async def test_async_register_ice_server( hass: HomeAssistant, ) -> None: """Test registering an ICE server.""" + await async_setup_component(hass, "camera", {}) + # Clear any existing ICE servers hass.data[DATA_ICE_SERVERS].clear() @@ -218,7 +216,7 @@ async def test_async_register_ice_server( unregister = async_register_ice_servers(hass, get_ice_servers) assert not called - camera = get_camera_from_entity_id(hass, "camera.async") + camera = get_camera_from_entity_id(hass, "camera.demo_camera") config = camera.async_get_webrtc_client_configuration() assert config.configuration.ice_servers == [ @@ -279,7 +277,7 @@ async def test_async_register_ice_server( assert config.configuration.ice_servers == [] -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_get_client_config( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -288,7 +286,7 @@ async def test_ws_get_client_config( client = await hass_ws_client(hass) await client.send_json_auto_id( - {"type": "camera/webrtc/get_client_config", "entity_id": "camera.async"} + {"type": "camera/webrtc/get_client_config", "entity_id": "camera.demo_camera"} ) msg = await client.receive_json() @@ -322,7 +320,7 @@ async def test_ws_get_client_config( async_register_ice_servers(hass, get_ice_server) await client.send_json_auto_id( - {"type": "camera/webrtc/get_client_config", "entity_id": "camera.async"} + {"type": "camera/webrtc/get_client_config", "entity_id": "camera.demo_camera"} ) msg = await client.receive_json() @@ -372,7 +370,7 @@ async def test_ws_get_client_config_sync_offer( } -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_get_client_config_custom_config( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -386,7 +384,7 @@ async def test_ws_get_client_config_custom_config( client = await hass_ws_client(hass) await client.send_json_auto_id( - {"type": "camera/webrtc/get_client_config", "entity_id": "camera.async"} + {"type": "camera/webrtc/get_client_config", "entity_id": "camera.demo_camera"} ) msg = await client.receive_json() @@ -437,7 +435,7 @@ def mock_rtsp_to_webrtc_fixture(hass: HomeAssistant) -> Generator[Mock]: unsub() -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_websocket_webrtc_offer( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -446,7 +444,7 @@ async def test_websocket_webrtc_offer( await client.send_json_auto_id( { "type": "camera/webrtc/offer", - "entity_id": "camera.async", + "entity_id": "camera.demo_camera", "offer": WEBRTC_OFFER, } ) @@ -557,11 +555,11 @@ async def test_websocket_webrtc_offer_webrtc_provider( mock_async_close_session.assert_called_once_with(session_id) +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_websocket_webrtc_offer_invalid_entity( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: """Test WebRTC with a camera entity that does not exist.""" - await async_setup_component(hass, "camera", {}) client = await hass_ws_client(hass) await client.send_json_auto_id( { @@ -580,7 +578,7 @@ async def test_websocket_webrtc_offer_invalid_entity( } -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_websocket_webrtc_offer_missing_offer( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -607,6 +605,7 @@ async def test_websocket_webrtc_offer_missing_offer( (TimeoutError(), "Timeout handling WebRTC offer"), ], ) +@pytest.mark.usefixtures("mock_camera_webrtc_frontendtype_only") async def test_websocket_webrtc_offer_failure( hass: HomeAssistant, hass_ws_client: WebSocketGenerator, @@ -950,7 +949,7 @@ async def test_rtsp_to_webrtc_offer_not_accepted( unsub() -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_webrtc_candidate( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -958,13 +957,13 @@ async def test_ws_webrtc_candidate( client = await hass_ws_client(hass) session_id = "session_id" candidate = "candidate" - with patch.object( - get_camera_from_entity_id(hass, "camera.async"), "async_on_webrtc_candidate" + with patch( + "homeassistant.components.camera.Camera.async_on_webrtc_candidate" ) as mock_on_webrtc_candidate: await client.send_json_auto_id( { "type": "camera/webrtc/candidate", - "entity_id": "camera.async", + "entity_id": "camera.demo_camera", "session_id": session_id, "candidate": candidate, } @@ -977,7 +976,7 @@ async def test_ws_webrtc_candidate( ) -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_webrtc_candidate_not_supported( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -986,7 +985,7 @@ async def test_ws_webrtc_candidate_not_supported( await client.send_json_auto_id( { "type": "camera/webrtc/candidate", - "entity_id": "camera.sync", + "entity_id": "camera.demo_camera", "session_id": "session_id", "candidate": "candidate", } @@ -1029,11 +1028,11 @@ async def test_ws_webrtc_candidate_webrtc_provider( ) +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_webrtc_candidate_invalid_entity( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: """Test ws WebRTC candidate command with a camera entity that does not exist.""" - await async_setup_component(hass, "camera", {}) client = await hass_ws_client(hass) await client.send_json_auto_id( { @@ -1053,7 +1052,7 @@ async def test_ws_webrtc_candidate_invalid_entity( } -@pytest.mark.usefixtures("mock_test_webrtc_cameras") +@pytest.mark.usefixtures("mock_camera_webrtc") async def test_ws_webrtc_canidate_missing_candidate( hass: HomeAssistant, hass_ws_client: WebSocketGenerator ) -> None: @@ -1062,7 +1061,7 @@ async def test_ws_webrtc_canidate_missing_candidate( await client.send_json_auto_id( { "type": "camera/webrtc/candidate", - "entity_id": "camera.async", + "entity_id": "camera.demo_camera", "session_id": "session_id", } ) diff --git a/tests/components/conftest.py b/tests/components/conftest.py index 363d39a2e63..5535ec3b976 100644 --- a/tests/components/conftest.py +++ b/tests/components/conftest.py @@ -26,12 +26,7 @@ from homeassistant.config_entries import ( ) from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import ( - FlowContext, - FlowHandler, - FlowManager, - FlowResultType, -) +from homeassistant.data_entry_flow import FlowHandler, FlowManager, FlowResultType from homeassistant.helpers.translation import async_get_translations if TYPE_CHECKING: @@ -562,12 +557,12 @@ def _validate_translation_placeholders( description_placeholders is None or placeholder not in description_placeholders ): - ignore_translations[full_key] = ( + pytest.fail( f"Description not found for placeholder `{placeholder}` in {full_key}" ) -async def _validate_translation( +async def _ensure_translation_exists( hass: HomeAssistant, ignore_translations: dict[str, StoreInfo], category: str, @@ -593,7 +588,7 @@ async def _validate_translation( ignore_translations[full_key] = "used" return - ignore_translations[full_key] = ( + pytest.fail( f"Translation not found for {component}: `{category}.{key}`. " f"Please add to homeassistant/components/{component}/strings.json" ) @@ -609,106 +604,84 @@ def ignore_translations() -> str | list[str]: return [] -async def _check_config_flow_result_translations( - manager: FlowManager, - flow: FlowHandler, - result: FlowResult[FlowContext, str], - ignore_translations: dict[str, str], -) -> None: - if isinstance(manager, ConfigEntriesFlowManager): - category = "config" - integration = flow.handler - elif isinstance(manager, OptionsFlowManager): - category = "options" - integration = flow.hass.config_entries.async_get_entry(flow.handler).domain - else: - return - - # Check if this flow has been seen before - # Gets set to False on first run, and to True on subsequent runs - setattr(flow, "__flow_seen_before", hasattr(flow, "__flow_seen_before")) - - if result["type"] is FlowResultType.FORM: - if step_id := result.get("step_id"): - # neither title nor description are required - # - title defaults to integration name - # - description is optional - for header in ("title", "description"): - await _validate_translation( - flow.hass, - ignore_translations, - category, - integration, - f"step.{step_id}.{header}", - result["description_placeholders"], - translation_required=False, - ) - if errors := result.get("errors"): - for error in errors.values(): - await _validate_translation( - flow.hass, - ignore_translations, - category, - integration, - f"error.{error}", - result["description_placeholders"], - ) - return - - if result["type"] is FlowResultType.ABORT: - # We don't need translations for a discovery flow which immediately - # aborts, since such flows won't be seen by users - if not flow.__flow_seen_before and flow.source in DISCOVERY_SOURCES: - return - await _validate_translation( - flow.hass, - ignore_translations, - category, - integration, - f"abort.{result["reason"]}", - result["description_placeholders"], - ) - - @pytest.fixture(autouse=True) -def check_translations(ignore_translations: str | list[str]) -> Generator[None]: - """Check that translation requirements are met. - - Current checks: - - data entry flow results (ConfigFlow/OptionsFlow) - """ +def check_config_translations(ignore_translations: str | list[str]) -> Generator[None]: + """Ensure config_flow translations are available.""" if not isinstance(ignore_translations, list): ignore_translations = [ignore_translations] _ignore_translations = {k: "unused" for k in ignore_translations} + _original = FlowManager._async_handle_step - # Keep reference to original functions - _original_flow_manager_async_handle_step = FlowManager._async_handle_step - - # Prepare override functions - async def _flow_manager_async_handle_step( + async def _async_handle_step( self: FlowManager, flow: FlowHandler, *args ) -> FlowResult: - result = await _original_flow_manager_async_handle_step(self, flow, *args) - await _check_config_flow_result_translations( - self, flow, result, _ignore_translations - ) + result = await _original(self, flow, *args) + if isinstance(self, ConfigEntriesFlowManager): + category = "config" + component = flow.handler + elif isinstance(self, OptionsFlowManager): + category = "options" + component = flow.hass.config_entries.async_get_entry(flow.handler).domain + else: + return result + + # Check if this flow has been seen before + # Gets set to False on first run, and to True on subsequent runs + setattr(flow, "__flow_seen_before", hasattr(flow, "__flow_seen_before")) + + if result["type"] is FlowResultType.FORM: + if step_id := result.get("step_id"): + # neither title nor description are required + # - title defaults to integration name + # - description is optional + for header in ("title", "description"): + await _ensure_translation_exists( + flow.hass, + _ignore_translations, + category, + component, + f"step.{step_id}.{header}", + result["description_placeholders"], + translation_required=False, + ) + if errors := result.get("errors"): + for error in errors.values(): + await _ensure_translation_exists( + flow.hass, + _ignore_translations, + category, + component, + f"error.{error}", + result["description_placeholders"], + ) + return result + + if result["type"] is FlowResultType.ABORT: + # We don't need translations for a discovery flow which immediately + # aborts, since such flows won't be seen by users + if not flow.__flow_seen_before and flow.source in DISCOVERY_SOURCES: + return result + await _ensure_translation_exists( + flow.hass, + _ignore_translations, + category, + component, + f"abort.{result["reason"]}", + result["description_placeholders"], + ) + return result - # Use override functions with patch( "homeassistant.data_entry_flow.FlowManager._async_handle_step", - _flow_manager_async_handle_step, + _async_handle_step, ): yield - # Run final checks unused_ignore = [k for k, v in _ignore_translations.items() if v == "unused"] if unused_ignore: pytest.fail( f"Unused ignore translations: {', '.join(unused_ignore)}. " "Please remove them from the ignore_translations fixture." ) - for description in _ignore_translations.values(): - if description not in {"used", "unused"}: - pytest.fail(description) diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index 87ba46a4ced..1382c5c2569 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -21,7 +21,7 @@ import zigpy.types from homeassistant import config_entries from homeassistant.components import ssdp, usb, zeroconf -from homeassistant.components.hassio import AddonError, AddonState +from homeassistant.components.hassio import AddonState from homeassistant.components.ssdp import ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL from homeassistant.components.zha import config_flow, radio_manager from homeassistant.components.zha.const import ( @@ -1878,23 +1878,10 @@ async def test_config_flow_port_yellow_port_name(hass: HomeAssistant) -> None: ) -async def test_config_flow_ports_no_hassio(hass: HomeAssistant) -> None: - """Test config flow serial port name when this is not a hassio install.""" - - with ( - patch("homeassistant.components.zha.config_flow.is_hassio", return_value=False), - patch("serial.tools.list_ports.comports", MagicMock(return_value=[])), - ): - ports = await config_flow.list_serial_ports(hass) - - assert ports == [] - - async def test_config_flow_port_multiprotocol_port_name(hass: HomeAssistant) -> None: """Test config flow serial port name for multiprotocol add-on.""" with ( - patch("homeassistant.components.zha.config_flow.is_hassio", return_value=True), patch( "homeassistant.components.hassio.addon_manager.AddonManager.async_get_addon_info" ) as async_get_addon_info, @@ -1902,28 +1889,16 @@ async def test_config_flow_port_multiprotocol_port_name(hass: HomeAssistant) -> ): async_get_addon_info.return_value.state = AddonState.RUNNING async_get_addon_info.return_value.hostname = "core-silabs-multiprotocol" - ports = await config_flow.list_serial_ports(hass) - assert len(ports) == 1 - assert ports[0].description == "Multiprotocol add-on" - assert ports[0].manufacturer == "Nabu Casa" - assert ports[0].device == "socket://core-silabs-multiprotocol:9999" + result = await hass.config_entries.flow.async_init( + DOMAIN, + context={CONF_SOURCE: SOURCE_USER}, + ) - -async def test_config_flow_port_no_multiprotocol(hass: HomeAssistant) -> None: - """Test config flow serial port listing when addon info fails to load.""" - - with ( - patch("homeassistant.components.zha.config_flow.is_hassio", return_value=True), - patch( - "homeassistant.components.hassio.addon_manager.AddonManager.async_get_addon_info", - side_effect=AddonError, - ), - patch("serial.tools.list_ports.comports", MagicMock(return_value=[])), - ): - ports = await config_flow.list_serial_ports(hass) - - assert ports == [] + assert ( + result["data_schema"].schema["path"].container[0] + == "socket://core-silabs-multiprotocol:9999 - Multiprotocol add-on - Nabu Casa" + ) @patch("serial.tools.list_ports.comports", MagicMock(return_value=[com_port()]))