use uv, fix devcontainer, and drop support for HA ≤2023.6 (#1151)

* Update .devcontainer

* Drop support for ≤2023.6

* Add .vscode/settings.json

* Use async_process_ha_core_config

* Fix for HA ≤2023.10

* pop normalized_name

* Add comments

* use . instead of source

* set pytest args

* set country

* use py3.13 for dev branch of core

* set country in test_adaptive_lighting_time_zones_with_default_settings

* Add comment
This commit is contained in:
Bas Nijholt 2025-01-01 16:11:22 -08:00 • committed by GitHub
commit f8719994a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 46 deletions

View file

@ -11,7 +11,6 @@ from random import randint
from typing import Any
from unittest.mock import Mock, patch
import homeassistant.config as config_util
import homeassistant.util.dt as dt_util
import pytest
import ulid_transform
@ -362,6 +361,19 @@ async def test_adaptive_lighting_switches(hass):
assert len(data.keys()) == 5
def async_process_ha_core_config(hass, config):
"""Set up the Home Assistant configuration."""
try:
# ha >= "2023.11.0"
from homeassistant.core_config import async_process_ha_core_config
return async_process_ha_core_config(hass, config)
except ModuleNotFoundError:
import homeassistant.config as config_util
return config_util.async_process_ha_core_config(hass, config)
@pytest.mark.parametrize(("lat", "long", "timezone"), LAT_LONG_TZS)
async def test_adaptive_lighting_time_zones_with_default_settings(
hass,
@ -371,9 +383,9 @@ async def test_adaptive_lighting_time_zones_with_default_settings(
reset_time_zone, # pylint: disable=redefined-outer-name
):
"""Test setting up the Adaptive Lighting switches with different timezones."""
await config_util.async_process_ha_core_config(
await async_process_ha_core_config(
hass,
{"latitude": lat, "longitude": long, "time_zone": timezone},
{"latitude": lat, "longitude": long, "time_zone": timezone, "country": "US"},
)
_, switch = await setup_switch(hass, {})
# Shouldn't raise an exception ever
@ -394,9 +406,9 @@ async def test_adaptive_lighting_time_zones_and_sun_settings(
Also test the (sleep) brightness and color temperature settings.
"""
await config_util.async_process_ha_core_config(
await async_process_ha_core_config(
hass,
{"latitude": lat, "longitude": long, "time_zone": timezone},
{"latitude": lat, "longitude": long, "time_zone": timezone, "country": "US"},
)
_, switch = await setup_switch(
hass,
@ -1359,6 +1371,8 @@ def mock_area_registry(
area_kwargs["icon"] = None
if dt >= datetime.date(2024, 3, 1):
area_kwargs["floor_id"] = "test-floor"
if dt >= datetime.date(2024, 11, 1):
area_kwargs.pop("normalized_name")
# This mess... 🤯
if dt >= datetime.date(2024, 2, 1) and dt != datetime.date(2024, 4, 1):
@ -1588,6 +1602,7 @@ async def test_proactive_adaptation(hass):
assert state.attributes[ATTR_COLOR_TEMP_KELVIN] == 3448
# TODO: Breaks since 2024.5.0!
async def test_proactive_adaptation_with_separate_commands(hass):
"""Validate that a split proactive adaptation yields one additional service call."""
switch, _ = await setup_lights_and_switch(
@ -1927,9 +1942,9 @@ async def test_adapt_until_sleep_and_rgb_colors(hass):
Also test the (sleep) brightness and color temperature settings.
"""
lat, long, timezone = (32.87336, -117.22743, "US/Pacific")
await config_util.async_process_ha_core_config(
await async_process_ha_core_config(
hass,
{"latitude": lat, "longitude": long, "time_zone": timezone},
{"latitude": lat, "longitude": long, "time_zone": timezone, "country": "US"},
)
switch, lights = await setup_lights_and_switch(
hass,