Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt authored Apr 7, 2024
2 parents c945763 + d23f6ec commit 4fff3c7
Show file tree
Hide file tree
Showing 24 changed files with 309 additions and 170 deletions.
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,33 @@
"contributions": [
"code"
]
},
{
"login": "scuricvladimir",
"name": "scuricvladimir",
"avatar_url": "https://avatars.githubusercontent.com/u/46634162?v=4",
"profile": "https://github.com/scuricvladimir",
"contributions": [
"translation"
]
},
{
"login": "Welsyntoffie",
"name": "Pieter",
"avatar_url": "https://avatars.githubusercontent.com/u/47089904?v=4",
"profile": "https://github.com/Welsyntoffie",
"contributions": [
"translation"
]
},
{
"login": "san80068259",
"name": "san80068259",
"avatar_url": "https://avatars.githubusercontent.com/u/68324107?v=4",
"profile": "https://github.com/san80068259",
"contributions": [
"translation"
]
}
],
"contributorsPerLine": 7,
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "basnijholt/adaptive_lighting",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.11-bullseye",
"postCreateCommand": "scripts/setup",
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.12",
"postCreateCommand": "scripts/setup-devcontainer",
"forwardPorts": [
8123
],
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/install_dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,5 @@ runs:
- name: Install dependencies
shell: bash
run: |
echo "::warning::### WARNING! Deprecation warnings muted with option '--use-pep517' please address this at some point in pytest.yaml. ###"
pip install -r core/requirements.txt --use-pep517
# because they decided to pull codecov the package from PyPI...
sed -i '/codecov/d' core/requirements_test.txt
pip install -r core/requirements_test.txt --use-pep517
pip install -e core/ --use-pep517
pip install ulid-transform # this is in Adaptive-lighting's manifest.json
pip install $(python test_dependencies.py) --use-pep517
./scripts/setup-dependencies
./scripts/setup-symlinks
47 changes: 23 additions & 24 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,30 @@ jobs:
- python-version: "3.10"
core-version: "2023.4.6"
- python-version: "3.10"
core-version: "2023.5.2"
core-version: "2023.5.4"
- python-version: "3.11"
core-version: "2023.6.1"
core-version: "2023.6.3"
- python-version: "3.11"
core-version: "2023.7.3"
- python-version: "3.11"
core-version: "2023.8.4"
- python-version: "3.11"
core-version: "2023.9.3"
- python-version: "3.11"
core-version: "2023.10.5"
- python-version: "3.11"
core-version: "2023.11.3"
- python-version: "3.11"
core-version: "2023.12.4"
- python-version: "3.11"
core-version: "2024.1.6"
- python-version: "3.11"
core-version: "2024.2.5"
- python-version: "3.12"
core-version: "2024.3.3"
- python-version: "3.12"
core-version: "2024.4.1"
- python-version: "3.12"
core-version: "dev"
steps:
- name: Check out code from GitHub
Expand All @@ -42,25 +62,6 @@ jobs:
python-version: ${{ matrix.python-version }}
core-version: ${{ matrix.core-version }}

- name: Click here for troubleshooting steps if tests break again.
run: |
echo "::notice::### If tests fail, try these debug steps: ###"
echo "::notice::### 1. Replace '-qq' from .github/workflow/pytest.yaml. with '-v' for extra verbosity. ###"
echo "::notice::### 2. Push or run action again. ###"
echo "::notice::### 3. Check for any log messages in github actions resembling the following using CTRL+F ###
echo "::notice::### 4. ERROR:homeassistant.setup:Setup failed for 'component': Unable to import component: No module named ''module'' ###"
echo "::notice::### 5. add 'component'.'module' (without the '') from the above log into the 'required' list inside of 'test_dependencies.py' ###"
echo "::notice::### 6. Try again! If more issues persist they should be easily solvable by reading the verbose logs now. ###"
- name: Link custom_components/adaptive_lighting
run: |
cd core
# Link adaptive_lighting tests
cd tests/components/
ln -fs ../../../tests adaptive_lighting
cd -
- name: Run pytest
timeout-minutes: 60
run: |
Expand All @@ -71,10 +72,8 @@ jobs:
-qq \
--timeout=9 \
--durations=10 \
--cov="custom_components.adaptive_lighting" \
--cov="homeassistant" \
--cov-report=xml \
-o console_output_style=count \
-p no:sugar \
tests/components/adaptive_lighting
env:
HA_CLONE: true
7 changes: 1 addition & 6 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@ jobs:
- name: Install Home Assistant
uses: ./.github/workflows/install_dependencies
with:
python-version: "3.11"
python-version: "3.12"

- name: Install markdown-code-runner and README code dependencies
run: |
pip install markdown-code-runner==1.0.0 pandas tabulate
- name: Link custom_components/adaptive_lighting
run: |
cd core/homeassistant/components
ln -fs ../../../custom_components/adaptive_lighting adaptive_lighting
- name: Run markdown-code-runner
run: markdown-code-runner --debug README.md

Expand Down
21 changes: 6 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Optionally build the image yourself with:
# docker build -t basnijholt/adaptive-lighting:latest .

FROM python:3.11-buster
FROM python:3.12-bookworm

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
Expand All @@ -16,30 +16,21 @@ RUN apt-get update && \
&& rm -rf /var/lib/apt/lists/*

# Clone home-assistant/core
RUN git clone --depth 1 https://github.com/home-assistant/core.git /core

# Install home-assistant/core dependencies
RUN pip3 install -r /core/requirements.txt --use-pep517 && \
pip3 install -r /core/requirements_test.txt --use-pep517 && \
pip3 install -e /core/ --use-pep517
RUN git clone --depth 1 --branch dev https://github.com/home-assistant/core.git /core

# Copy the Adaptive Lighting repository
COPY . /app/

# Setup symlinks in core
RUN ln -s /app/tests /core/tests/components/adaptive_lighting && \
# For test_dependencies.py
ln -s /core /app/core
RUN ln -s /core /app/core && /app/scripts/setup-symlinks

# Install dependencies of components that Adaptive Lighting depends on
RUN pip3 install $(python3 /app/test_dependencies.py) --use-pep517
# Install home-assistant/core dependencies
RUN /app/scripts/setup-dependencies

WORKDIR /core

# Make 'custom_components/adaptive_lighting' imports available to tests
ENV PYTHONPATH="${PYTHONPATH}:/app"
# Enable testing against HA clone (instead of pytest_homeassistant_custom_component)
ENV HA_CLONE=true

ENTRYPOINT ["python3", \
# Enable Python development mode
Expand All @@ -53,7 +44,7 @@ ENTRYPOINT ["python3", \
# Print the 10 slowest tests
"--durations=10", \
# Measure code coverage for the 'homeassistant' package
"--cov=custom_components.adaptive_lighting", \
"--cov='homeassistant'", \
# Generate an XML report of the code coverage
"--cov-report=xml", \
# Generate an HTML report of the code coverage
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg?style=for-the-badge)](https://github.com/hacs/integration)
![Version](https://img.shields.io/github/v/release/basnijholt/adaptive-lighting?style=for-the-badge)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

# 🌞 Adaptive Lighting: Enhance Your Home's Atmosphere with Smart, Sun-Synchronized Lighting 🌙
Expand Down Expand Up @@ -576,6 +576,9 @@ Notice the values of `brightness_mode_time_light` and `brightness_mode_time_dark
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/droans"><img src="https://avatars.githubusercontent.com/u/49721649?v=4?s=100" width="100px;" alt="droans"/><br /><sub><b>droans</b></sub></a><br /><a href="https://github.com/basnijholt/adaptive-lighting/commits?author=droans" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://blogs.gnome.org/jonathankang/"><img src="https://avatars.githubusercontent.com/u/5607743?v=4?s=100" width="100px;" alt="Jonathan Kang"/><br /><sub><b>Jonathan Kang</b></sub></a><br /><a href="https://github.com/basnijholt/adaptive-lighting/commits?author=JonathanKang" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/scuricvladimir"><img src="https://avatars.githubusercontent.com/u/46634162?v=4?s=100" width="100px;" alt="scuricvladimir"/><br /><sub><b>scuricvladimir</b></sub></a><br /><a href="#translation-scuricvladimir" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Welsyntoffie"><img src="https://avatars.githubusercontent.com/u/47089904?v=4?s=100" width="100px;" alt="Pieter"/><br /><sub><b>Pieter</b></sub></a><br /><a href="#translation-Welsyntoffie" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/san80068259"><img src="https://avatars.githubusercontent.com/u/68324107?v=4?s=100" width="100px;" alt="san80068259"/><br /><sub><b>san80068259</b></sub></a><br /><a href="#translation-san80068259" title="Translation">🌍</a></td>
</tr>
</tbody>
<tfoot>
Expand Down
3 changes: 3 additions & 0 deletions custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ async def async_added_to_hass(self) -> None:
self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_STARTED,
self._setup_listeners,
run_immediately=False,
)
last_state: State | None = await self.async_get_last_state()
is_new_entry = last_state is None # newly added to HA
Expand Down Expand Up @@ -1658,10 +1659,12 @@ def __init__(self, hass: HomeAssistant) -> None:
self.hass.bus.async_listen(
EVENT_CALL_SERVICE,
self.turn_on_off_event_listener,
run_immediately=False,
),
self.hass.bus.async_listen(
EVENT_STATE_CHANGED,
self.state_changed_event_listener,
run_immediately=False,
),
]

Expand Down
40 changes: 40 additions & 0 deletions custom_components/adaptive_lighting/translations/af.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"services": {
"apply": {
"description": "Pas die huidige Adaptive Lighting-instellings op ligte toe.",
"fields": {
"lights": {
"description": "'n Lig (of lys van ligte) om die instellings op toe te pas. 💡"
}
}
},
"change_switch_settings": {
"fields": {
"only_once": {
"description": "Pas ligte net aan wanneer hulle aangeskakel is (`true`) of hou aan om dit aan te pas (`false`)"
},
"sunrise_offset": {
"description": "Pas sonsopkomstyd aan met 'n positiewe of negatiewe afwyking in sekondes. ⏰"
},
"sunset_offset": {
"description": "Pas sonsondergangtyd aan met 'n positiewe of negatiewe afwyking in sekondes. ⏰"
}
}
}
},
"options": {
"step": {
"init": {
"title": "Aanpasbare beligting opsies",
"data": {
"adapt_only_on_bare_turn_on": "adapt_only_on_bare_turn_on: Wanneer ligte aanvanklik aangeskakel word. As dit op \"true\" gestel is, pas AL slegs aan as \"light.turn_on\" opgeroep word sonder om kleur of helderheid te spesifiseer. ❌🌈 Dit verhoed bv. aanpassing wanneer 'n toneel geaktiveer word. As `onwaar`, pas AL aan ongeag die teenwoordigheid van kleur of helderheid in die aanvanklike `diens_data`. Moet `oorname_beheer` geaktiveer moet word. 🕵️ "
},
"data_description": {
"sunrise_offset": "Pas sonsopkomstyd aan met 'n positiewe of negatiewe afwyking in sekondes. ⏰",
"sunset_offset": "Pas sonsondergangtyd aan met 'n positiewe of negatiewe afwyking in sekondes. ⏰"
}
}
}
},
"title": "Aanpasbare beligting"
}
19 changes: 19 additions & 0 deletions custom_components/adaptive_lighting/translations/hr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"options": {
"step": {
"init": {
"title": "Opcije prilagodljivog osvjetljenja"
}
}
},
"title": "prilagodi svjetlinu",
"services": {
"change_switch_settings": {
"fields": {
"only_once": {
"description": "Prilagodi svjetla samo kada su uključena (true) ili ih neprestano prilagođavaj (false). 🔄"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/setup

This file was deleted.

16 changes: 16 additions & 0 deletions scripts/setup-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "$0")/.."

pip install -r core/requirements.txt

if grep -q 'codecov' core/requirements_test.txt; then
# Older HA versions still have `codecov` in `requirements_test.txt`
# however it is removed from PyPI, so we cannot install it
sed -i '/codecov/d' core/requirements_test.txt
fi
pip install -r core/requirements_test.txt

pip install -e core/
pip install ulid-transform # this is in Adaptive-lighting's manifest.json
pip install $(python test_dependencies.py)
18 changes: 18 additions & 0 deletions scripts/setup-devcontainer
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."

# Clone only if the folder doesn't exist
if [[ ! -d "core" ]]; then
git clone --depth 1 --branch dev https://github.com/home-assistant/core.git
fi

pip install \
colorlog==6.7.0 \
pip>=21.0,<23.2 \
ruff==0.0.265 \
pre-commit

./scripts/setup-dependencies
./scripts/setup-symlinks
pre-commit install-hooks
13 changes: 13 additions & 0 deletions scripts/setup-symlinks
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -ex
cd "$(dirname "$0")/.."

# Link custom components
cd core/homeassistant/components/
ln -fs ../../../custom_components/adaptive_lighting adaptive_lighting
cd -

# Link tests
cd core/tests/components/
ln -fs ../../../tests/ adaptive_lighting
cd -
2 changes: 2 additions & 0 deletions test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"components.stream",
"components.conversation", # only available after HA≥2023.2
"components.cloud",
"components.ffmpeg", # needed since 2024.1
]
to_install = [package for r in required for package in deps[r]]
to_install.append("flaky")

print(" ".join(to_install)) # noqa: T201
Loading

0 comments on commit 4fff3c7

Please sign in to comment.