Skip to content

Commit

Permalink
Merge branch 'dev' into alarm_control_panel-default-code
Browse files Browse the repository at this point in the history
  • Loading branch information
gjohansson-ST committed May 9, 2024
2 parents b14441a + 3fa2db8 commit d86eee7
Show file tree
Hide file tree
Showing 874 changed files with 14,292 additions and 4,863 deletions.
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ omit =
homeassistant/components/alarmdecoder/sensor.py
homeassistant/components/alpha_vantage/sensor.py
homeassistant/components/amazon_polly/*
homeassistant/components/ambiclimate/climate.py
homeassistant/components/ambient_station/__init__.py
homeassistant/components/ambient_station/binary_sensor.py
homeassistant/components/ambient_station/entity.py
Expand Down Expand Up @@ -811,6 +810,8 @@ omit =
homeassistant/components/moehlenhoff_alpha2/binary_sensor.py
homeassistant/components/moehlenhoff_alpha2/climate.py
homeassistant/components/moehlenhoff_alpha2/sensor.py
homeassistant/components/monzo/__init__.py
homeassistant/components/monzo/api.py
homeassistant/components/motion_blinds/__init__.py
homeassistant/components/motion_blinds/coordinator.py
homeassistant/components/motion_blinds/cover.py
Expand Down Expand Up @@ -1202,7 +1203,6 @@ omit =
homeassistant/components/screenlogic/light.py
homeassistant/components/screenlogic/number.py
homeassistant/components/screenlogic/sensor.py
homeassistant/components/screenlogic/services.py
homeassistant/components/screenlogic/switch.py
homeassistant/components/scsgate/*
homeassistant/components/sendgrid/notify.py
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
uses: actions/checkout@v4.1.4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3.25.3
uses: github/codeql-action/init@v3.25.4
with:
languages: python

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.25.3
uses: github/codeql-action/analyze@v3.25.4
with:
category: "/language:python"
3 changes: 2 additions & 1 deletion .strict-typing
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ homeassistant.components.adax.*
homeassistant.components.adguard.*
homeassistant.components.aftership.*
homeassistant.components.air_quality.*
homeassistant.components.airgradient.*
homeassistant.components.airly.*
homeassistant.components.airnow.*
homeassistant.components.airq.*
Expand All @@ -65,7 +66,6 @@ homeassistant.components.alexa.*
homeassistant.components.alpha_vantage.*
homeassistant.components.amazon_polly.*
homeassistant.components.amberelectric.*
homeassistant.components.ambiclimate.*
homeassistant.components.ambient_network.*
homeassistant.components.ambient_station.*
homeassistant.components.amcrest.*
Expand Down Expand Up @@ -301,6 +301,7 @@ homeassistant.components.minecraft_server.*
homeassistant.components.mjpeg.*
homeassistant.components.modbus.*
homeassistant.components.modem_callerid.*
homeassistant.components.monzo.*
homeassistant.components.moon.*
homeassistant.components.mopeka.*
homeassistant.components.motionmount.*
Expand Down
6 changes: 4 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ build.json @home-assistant/supervisor
/tests/components/agent_dvr/ @ispysoftware
/homeassistant/components/air_quality/ @home-assistant/core
/tests/components/air_quality/ @home-assistant/core
/homeassistant/components/airgradient/ @airgradienthq @joostlek
/tests/components/airgradient/ @airgradienthq @joostlek
/homeassistant/components/airly/ @bieniu
/tests/components/airly/ @bieniu
/homeassistant/components/airnow/ @asymworks
Expand Down Expand Up @@ -88,8 +90,6 @@ build.json @home-assistant/supervisor
/tests/components/alexa/ @home-assistant/cloud @ochlocracy @jbouwh
/homeassistant/components/amberelectric/ @madpilot
/tests/components/amberelectric/ @madpilot
/homeassistant/components/ambiclimate/ @danielhiversen
/tests/components/ambiclimate/ @danielhiversen
/homeassistant/components/ambient_network/ @thomaskistler
/tests/components/ambient_network/ @thomaskistler
/homeassistant/components/ambient_station/ @bachya
Expand Down Expand Up @@ -869,6 +869,8 @@ build.json @home-assistant/supervisor
/tests/components/moehlenhoff_alpha2/ @j-a-n
/homeassistant/components/monoprice/ @etsinko @OnFreund
/tests/components/monoprice/ @etsinko @OnFreund
/homeassistant/components/monzo/ @jakemartin-icl
/tests/components/monzo/ @jakemartin-icl
/homeassistant/components/moon/ @fabaff @frenck
/tests/components/moon/ @fabaff @frenck
/homeassistant/components/mopeka/ @bdraco
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/auth/mfa_modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.importlib import async_import_module
from homeassistant.util.decorator import Registry
from homeassistant.util.hass_dict import HassKey

MULTI_FACTOR_AUTH_MODULES: Registry[str, type[MultiFactorAuthModule]] = Registry()

Expand All @@ -29,7 +30,7 @@
extra=vol.ALLOW_EXTRA,
)

DATA_REQS = "mfa_auth_module_reqs_processed"
DATA_REQS: HassKey[set[str]] = HassKey("mfa_auth_module_reqs_processed")

_LOGGER = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion homeassistant/auth/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
from homeassistant.helpers.importlib import async_import_module
from homeassistant.util import dt as dt_util
from homeassistant.util.decorator import Registry
from homeassistant.util.hass_dict import HassKey

from ..auth_store import AuthStore
from ..const import MFA_SESSION_EXPIRATION
from ..models import AuthFlowResult, Credentials, RefreshToken, User, UserMeta

_LOGGER = logging.getLogger(__name__)
DATA_REQS = "auth_prov_reqs_processed"
DATA_REQS: HassKey[set[str]] = HassKey("auth_prov_reqs_processed")

AUTH_PROVIDERS: Registry[str, type[AuthProvider]] = Registry()

Expand Down
11 changes: 6 additions & 5 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
async_setup_component,
)
from .util.async_ import create_eager_task
from .util.hass_dict import HassKey
from .util.logging import async_activate_log_queue_handler
from .util.package import async_get_user_site, is_virtual_env

Expand All @@ -120,7 +121,7 @@
ERROR_LOG_FILENAME = "home-assistant.log"

# hass.data key for logging information.
DATA_REGISTRIES_LOADED = "bootstrap_registries_loaded"
DATA_REGISTRIES_LOADED: HassKey[None] = HassKey("bootstrap_registries_loaded")

LOG_SLOW_STARTUP_INTERVAL = 60
SLOW_STARTUP_CHECK_INTERVAL = 1
Expand Down Expand Up @@ -680,7 +681,7 @@ def _async_watch(self) -> None:

if remaining_with_setup_started:
_LOGGER.debug("Integration remaining: %s", remaining_with_setup_started)
elif waiting_tasks := self._hass._active_tasks: # pylint: disable=protected-access
elif waiting_tasks := self._hass._active_tasks: # noqa: SLF001
_LOGGER.debug("Waiting on tasks: %s", waiting_tasks)
self._async_dispatch(remaining_with_setup_started)
if (
Expand Down Expand Up @@ -984,7 +985,7 @@ async def _async_set_up_integrations(
except TimeoutError:
_LOGGER.warning(
"Setup timed out for stage 1 waiting on %s - moving forward",
hass._active_tasks, # pylint: disable=protected-access
hass._active_tasks, # noqa: SLF001
)

# Add after dependencies when setting up stage 2 domains
Expand All @@ -1000,7 +1001,7 @@ async def _async_set_up_integrations(
except TimeoutError:
_LOGGER.warning(
"Setup timed out for stage 2 waiting on %s - moving forward",
hass._active_tasks, # pylint: disable=protected-access
hass._active_tasks, # noqa: SLF001
)

# Wrap up startup
Expand All @@ -1011,7 +1012,7 @@ async def _async_set_up_integrations(
except TimeoutError:
_LOGGER.warning(
"Setup timed out for bootstrap waiting on %s - moving forward",
hass._active_tasks, # pylint: disable=protected-access
hass._active_tasks, # noqa: SLF001
)

watcher.async_stop()
Expand Down
25 changes: 9 additions & 16 deletions homeassistant/components/accuweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ class AccuWeatherData:
coordinator_daily_forecast: AccuWeatherDailyForecastDataUpdateCoordinator


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
AccuWeatherConfigEntry = ConfigEntry[AccuWeatherData]


async def async_setup_entry(hass: HomeAssistant, entry: AccuWeatherConfigEntry) -> bool:
"""Set up AccuWeather as config entry."""
api_key: str = entry.data[CONF_API_KEY]
name: str = entry.data[CONF_NAME]
Expand Down Expand Up @@ -64,9 +67,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await coordinator_observation.async_config_entry_first_refresh()
await coordinator_daily_forecast.async_config_entry_first_refresh()

entry.async_on_unload(entry.add_update_listener(update_listener))

hass.data.setdefault(DOMAIN, {})[entry.entry_id] = AccuWeatherData(
entry.runtime_data = AccuWeatherData(
coordinator_observation=coordinator_observation,
coordinator_daily_forecast=coordinator_daily_forecast,
)
Expand All @@ -84,16 +85,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(
hass: HomeAssistant, entry: AccuWeatherConfigEntry
) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)

if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)

return unload_ok


async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update listener."""
await hass.config_entries.async_reload(entry.entry_id)
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
8 changes: 3 additions & 5 deletions homeassistant/components/accuweather/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
from typing import Any

from homeassistant.components.diagnostics import async_redact_data
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant

from . import AccuWeatherData
from .const import DOMAIN
from . import AccuWeatherConfigEntry, AccuWeatherData

TO_REDACT = {CONF_API_KEY, CONF_LATITUDE, CONF_LONGITUDE}


async def async_get_config_entry_diagnostics(
hass: HomeAssistant, config_entry: ConfigEntry
hass: HomeAssistant, config_entry: AccuWeatherConfigEntry
) -> dict[str, Any]:
"""Return diagnostics for a config entry."""
accuweather_data: AccuWeatherData = hass.data[DOMAIN][config_entry.entry_id]
accuweather_data: AccuWeatherData = config_entry.runtime_data

return {
"config_entry_data": async_redact_data(dict(config_entry.data), TO_REDACT),
Expand Down
15 changes: 6 additions & 9 deletions homeassistant/components/accuweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONCENTRATION_PARTS_PER_CUBIC_METER,
PERCENTAGE,
Expand All @@ -28,7 +27,7 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from . import AccuWeatherData
from . import AccuWeatherConfigEntry
from .const import (
API_METRIC,
ATTR_CATEGORY,
Expand All @@ -38,7 +37,6 @@
ATTR_SPEED,
ATTR_VALUE,
ATTRIBUTION,
DOMAIN,
MAX_FORECAST_DAYS,
)
from .coordinator import (
Expand Down Expand Up @@ -458,17 +456,16 @@ class AccuWeatherForecastSensorDescription(AccuWeatherSensorDescription):


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
hass: HomeAssistant,
entry: AccuWeatherConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add AccuWeather entities from a config_entry."""

accuweather_data: AccuWeatherData = hass.data[DOMAIN][entry.entry_id]

observation_coordinator: AccuWeatherObservationDataUpdateCoordinator = (
accuweather_data.coordinator_observation
entry.runtime_data.coordinator_observation
)
forecast_daily_coordinator: AccuWeatherDailyForecastDataUpdateCoordinator = (
accuweather_data.coordinator_daily_forecast
entry.runtime_data.coordinator_daily_forecast
)

sensors: list[AccuWeatherSensor | AccuWeatherForecastSensor] = [
Expand Down
9 changes: 6 additions & 3 deletions homeassistant/components/accuweather/system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from homeassistant.components import system_health
from homeassistant.core import HomeAssistant, callback

from . import AccuWeatherConfigEntry
from .const import DOMAIN


Expand All @@ -22,9 +23,11 @@ def async_register(

async def system_health_info(hass: HomeAssistant) -> dict[str, Any]:
"""Get info for the info page."""
remaining_requests = list(hass.data[DOMAIN].values())[
0
].coordinator_observation.accuweather.requests_remaining
config_entry: AccuWeatherConfigEntry = hass.config_entries.async_entries(DOMAIN)[0]

remaining_requests = (
config_entry.runtime_data.coordinator_observation.accuweather.requests_remaining
)

return {
"can_reach_server": system_health.async_check_can_reach_url(hass, ENDPOINT),
Expand Down
12 changes: 5 additions & 7 deletions homeassistant/components/accuweather/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
Forecast,
WeatherEntityFeature,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
UnitOfLength,
UnitOfPrecipitationDepth,
Expand All @@ -33,15 +32,14 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.dt import utc_from_timestamp

from . import AccuWeatherData
from . import AccuWeatherConfigEntry, AccuWeatherData
from .const import (
API_METRIC,
ATTR_DIRECTION,
ATTR_SPEED,
ATTR_VALUE,
ATTRIBUTION,
CONDITION_MAP,
DOMAIN,
)
from .coordinator import (
AccuWeatherDailyForecastDataUpdateCoordinator,
Expand All @@ -52,12 +50,12 @@


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
hass: HomeAssistant,
entry: AccuWeatherConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Add a AccuWeather weather entity from a config_entry."""
accuweather_data: AccuWeatherData = hass.data[DOMAIN][entry.entry_id]

async_add_entities([AccuWeatherEntity(accuweather_data)])
async_add_entities([AccuWeatherEntity(entry.runtime_data)])


class AccuWeatherEntity(
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/agent_dvr/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def __init__(self, device):
"""Initialize as a subclass of MjpegCamera."""
self.device = device
self._removed = False
self._attr_unique_id = f"{device._client.unique}_{device.typeID}_{device.id}"
self._attr_unique_id = f"{device.client.unique}_{device.typeID}_{device.id}"
super().__init__(
name=device.name,
mjpeg_url=f"{device.client._server_url}{device.mjpeg_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}",
still_image_url=f"{device.client._server_url}{device.still_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}",
mjpeg_url=f"{device.client._server_url}{device.mjpeg_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}", # noqa: SLF001
still_image_url=f"{device.client._server_url}{device.still_image_url}&size={device.mjpegStreamWidth}x{device.mjpegStreamHeight}", # noqa: SLF001
)
self._attr_device_info = DeviceInfo(
identifiers={(AGENT_DOMAIN, self.unique_id)},
Expand Down
Loading

0 comments on commit d86eee7

Please sign in to comment.