diff --git a/homeassistant/components/youtube/coordinator.py b/homeassistant/components/youtube/coordinator.py index 4cbe19d4845..fd489e37e98 100644 --- a/homeassistant/components/youtube/coordinator.py +++ b/homeassistant/components/youtube/coordinator.py @@ -31,7 +31,8 @@ from .const import ( def get_upload_playlist_id(channel_id: str) -> str: """Return the playlist id with the uploads of the channel. - Replacing the UC in the channel id (UCxxxxxxxxxxxx) with UU is the way to do it without extra request (UUxxxxxxxxxxxx). + Replacing the UC in the channel id (UCxxxxxxxxxxxx) with UU is + the way to do it without extra request (UUxxxxxxxxxxxx). """ return channel_id.replace("UC", "UU", 1) diff --git a/homeassistant/components/youtube/entity.py b/homeassistant/components/youtube/entity.py index 0f1d0c0aeb9..cdc2f98faac 100644 --- a/homeassistant/components/youtube/entity.py +++ b/homeassistant/components/youtube/entity.py @@ -5,13 +5,14 @@ from typing import Any from homeassistant.const import ATTR_ID from homeassistant.helpers.device_registry import DeviceEntryType -from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription +from homeassistant.helpers.entity import DeviceInfo, EntityDescription +from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ATTR_TITLE, DOMAIN, MANUFACTURER from .coordinator import YouTubeDataUpdateCoordinator -class YouTubeChannelEntity(Entity): +class YouTubeChannelEntity(CoordinatorEntity): """An HA implementation for YouTube entity.""" _attr_has_entity_name = True @@ -23,6 +24,7 @@ class YouTubeChannelEntity(Entity): channel: dict[str, Any], ) -> None: """Initialize a Google Mail entity.""" + super().__init__(coordinator) self.entity_description = description self._attr_unique_id = ( f"{coordinator.config_entry.entry_id}_{channel[ATTR_ID]}_{description.key}" diff --git a/homeassistant/components/youtube/strings.json b/homeassistant/components/youtube/strings.json index 24369ab26f9..f9a2d3af0ae 100644 --- a/homeassistant/components/youtube/strings.json +++ b/homeassistant/components/youtube/strings.json @@ -19,16 +19,6 @@ } } }, - "options": { - "step": { - "init": { - "description": "Select the channels you want to add.", - "data": { - "channels": "YouTube channels" - } - } - } - }, "entity": { "sensor": { "latest_upload": { diff --git a/tests/components/youtube/test_sensor.py b/tests/components/youtube/test_sensor.py index 57788924d40..b70b9dc2bd9 100644 --- a/tests/components/youtube/test_sensor.py +++ b/tests/components/youtube/test_sensor.py @@ -1,12 +1,15 @@ """Sensor tests for the YouTube integration.""" +from datetime import timedelta from unittest.mock import patch from google.auth.exceptions import RefreshError from homeassistant import config_entries -from homeassistant.components.youtube import COORDINATOR, DOMAIN +from homeassistant.components.youtube import DOMAIN from homeassistant.core import HomeAssistant +from homeassistant.util import dt +from ...common import async_fire_time_changed from .conftest import TOKEN, ComponentSetup @@ -40,8 +43,8 @@ async def test_sensor_reauth_trigger( await setup_integration() with patch(TOKEN, side_effect=RefreshError): - entry = hass.config_entries.async_entries(DOMAIN)[0] - await hass.data[DOMAIN][entry.entry_id][COORDINATOR].async_refresh() + future = dt.utcnow() + timedelta(minutes=15) + async_fire_time_changed(hass, future) await hass.async_block_till_done() flows = hass.config_entries.flow.async_progress()