merge with origin\main

This commit is contained in:
Benjamin Auquite 2023-04-10 05:21:51 -05:00
commit dced97b5ca
22 changed files with 1433 additions and 517 deletions

1
.github/CODEOWNERS vendored Normal file
View file

@ -0,0 +1 @@
* @basnijholt

View file

@ -1,17 +1,63 @@
---
name: 'Bug Report'
about: 'Report a bug in adaptive-lighting.'
labels: kind/bug, need/triage
name: Bug Report
about: Report a bug in adaptive-lighting.
title: ''
labels: kind/bug, kind/feature, need/triage
assignees: ''
---
#### Version information:
# Home Assistant Adaptive Lighting Issue Template
## Bug Reports
If you need help with using or configuring Adaptive Lighting, please [open a Q&A discussion thread here](https://github.com/basnijholt/adaptive-lighting/discussions/new?category=q-a) instead.
### Before submitting a bug report, please follow these troubleshooting steps:
Please confirm that you have completed the following steps:
- [ ] I have updated to the [latest Adaptive Lighting version](https://github.com/basnijholt/adaptive-lighting/releases) available in [HACS](https://hacs.xyz/).
- [ ] I have reviewed the [Troubleshooting Section](https://github.com/basnijholt/adaptive-lighting#troubleshooting) in the [README](https://github.com/basnijholt/adaptive-lighting#readme).
- [ ] (If using Zigbee2MQTT) I have read the [Zigbee2MQTT troubleshooting guide](https://github.com/basnijholt/adaptive-lighting#zigbee2mqtt) in the [README](https://github.com/basnijholt/adaptive-lighting#readme).
- [ ] I have checked the [V2 Roadmap](https://github.com/basnijholt/adaptive-lighting/discussions/291) and [open issues](https://github.com/basnijholt/adaptive-lighting/issues) to ensure my issue isn't a duplicate.
#### Description:
<!-- This is where you get to tell us what went wrong. When doing so, please make sure to include *all* relevant information.
### Required information for bug reports:
Please try to include:
* What you were doing when you experienced the bug.
* Any error messages you saw, *where* you saw them, and what you believe may have caused them (if you have any ideas).
* When possible, steps to reliably produce the bug.
-->
Please include the following information in your issue.
*Issues missing this information may not be addressed.*
1. **Debug logs** captured while the issue occurred. [See here for instructions on enabling debug logging](https://github.com/basnijholt/adaptive-lighting#troubleshooting):
```
```
2. [Your Adaptive Lighting configuration](https://github.com/basnijholt/adaptive-lighting#gear-configuration):
```
```
3. (If using Zigbee2MQTT), provide your configuration files (**remove all personal information before posting**):
- `devices.yaml`
- `groups.yaml`
- `configuration.yaml` ⚠️; **Warning** _**REMOVE ALL of the PERSONAL INFORMATION BELOW before posting**_ ⚠️;
- mqtt: `server`:
- mqtt: `user`:
- mqtt: `password`:
- advanced: `pan_id`:
- advanced: `network_key`:
- anything in `log_syslog` if you use this
- Brand and model number of problematic light(s)
```
```
4. Describe the bug and how to reproduce it:
5. Steps to reproduce the behavior:

View file

@ -1,7 +1,10 @@
---
name: 'Documentation Issue'
about: 'Report missing, erroneous docs, broken links or propose new docs'
name: Documentation Issue
about: Report missing, erroneous docs, broken links or propose new docs
title: ''
labels: kind/docs_issue, need/triage
assignees: ''
---
#### Location

View file

@ -1,5 +1,8 @@
---
name: 'Enhancement'
about: 'Suggest an improvement to an existing feature.'
name: Enhancement
about: Suggest an improvement to an existing feature.
title: ''
labels: kind/enhancement, need/triage
assignees: ''
---

View file

@ -1,5 +1,8 @@
---
name: 'Feature'
about: 'Suggest a new feature'
name: Feature
about: Suggest a new feature
title: ''
labels: kind/feature, need/triage
assignees: ''
---

25
.github/update-services.py vendored Normal file
View file

@ -0,0 +1,25 @@
from pathlib import Path
import sys
import yaml
sys.path.append(str(Path(__file__).parent.parent))
from custom_components.adaptive_lighting import const # noqa: E402
services_filename = "custom_components/adaptive_lighting/services.yaml"
with open(services_filename) as f:
services = yaml.safe_load(f)
for service_name, dct in services.items():
_docs = {"set_manual_control": const.DOCS_MANUAL_CONTROL, "apply": const.DOCS_APPLY}
alternative_docs = _docs.get(service_name, const.DOCS)
for field_name, field in dct["fields"].items():
description = alternative_docs.get(field_name, const.DOCS[field_name])
field["description"] = description
comment = "# This file is auto-generated by .github/update-services.py."
with open(services_filename, "w") as f:
f.write(comment + "\n")
yaml.dump(services, f, sort_keys=False, width=1000, allow_unicode=True)

31
.github/update-strings.py vendored Normal file
View file

@ -0,0 +1,31 @@
import json
from pathlib import Path
import sys
sys.path.append(str(Path(__file__).parent.parent))
from custom_components.adaptive_lighting import const # noqa: E402
strings_fname = "custom_components/adaptive_lighting/strings.json"
en_fname = "custom_components/adaptive_lighting/translations/en.json"
with open(strings_fname) as f:
strings = json.load(f)
data = {k: f"{k}: {const.DOCS[k]}" for k, _, _ in const.VALIDATION_TUPLES}
strings["options"]["step"]["init"]["data"] = data
with open(strings_fname, "w") as f:
json.dump(strings, f, indent=2, ensure_ascii=False)
f.write("\n")
# Sync changes from strings.json to en.json
with open(en_fname) as f:
en = json.load(f)
en["config"]["step"]["user"] = strings["config"]["step"]["user"]
en["options"]["step"]["init"]["data"] = data
with open(en_fname, "w") as f:
json.dump(en, f, indent=2, ensure_ascii=False)
f.write("\n")

View file

@ -1,10 +1,14 @@
name: 'Install Dependencies'
description: 'Install Home Assistant and test dependencies'
inputs:
python_version:
python-version:
description: 'Python version'
required: true
default: '3.10'
core-version:
description: 'Home Assistant core version'
required: false
default: 'dev'
runs:
using: "composite"
@ -21,11 +25,12 @@ runs:
with:
repository: home-assistant/core
path: core
- name: Set up Python ${{ inputs.python_version }}
ref: ${{ inputs.core-version }}
- name: Set up Python ${{ inputs.python-version }}
id: python
uses: actions/setup-python@v4.1.0
with:
python-version: ${{ inputs.python_version }}
python-version: ${{ inputs.python-version }}
- name: Install dependencies
shell: bash
run: |
@ -33,4 +38,5 @@ runs:
pip install -r core/requirements.txt --use-pep517
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

View file

@ -11,8 +11,10 @@ jobs:
runs-on: ubuntu-20.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
core-version: ["2023.2.5", "2023.3.6", "2023.4.0", "dev"]
steps:
- name: Check out code from GitHub
uses: actions/checkout@v3
@ -20,7 +22,8 @@ jobs:
- name: Install Home Assistant
uses: ./.github/workflows/install_dependencies
with:
python_version: ${{ matrix.python-version }}
python-version: ${{ matrix.python-version }}
core-version: ${{ matrix.core-version }}
- name: Click here for troubleshooting steps if tests break again.
run: |
@ -31,8 +34,8 @@ jobs:
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: Run pytest
timeout-minutes: 60
- name: Link custom_components/adaptive_lighting
run: |
cd core
@ -46,6 +49,10 @@ jobs:
ln -fs ../../../tests adaptive_lighting
cd -
- name: Run pytest
timeout-minutes: 60
run: |
cd core
python3 -X dev -m pytest \
-qq \
--timeout=9 \

View file

@ -20,23 +20,42 @@ jobs:
- name: Install Home Assistant
uses: ./.github/workflows/install_dependencies
with:
python_version: "3.10"
python-version: "3.10"
- name: Install pandas and tabulate
- name: Install markdown-code-runner and README code dependencies
run: |
pip install markdown-code-runner pandas tabulate
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
- name: Commit updated README.md
- name: Run update strings.json
run: python .github/update-strings.py
- name: Run update services.yaml
run: python .github/update-services.py
- name: Commit updated README.md, strings.json, and services.yaml
id: commit
run: |
git add README.md
git add -u .
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff --quiet && git diff --staged --quiet || git commit -m "Update README.md"
if git diff --quiet && git diff --staged --quiet; then
echo "No changes in README.md, strings.json, and services.yaml, skipping commit."
echo "commit_status=skipped" >> $GITHUB_ENV
else
git commit -m "Update README.md, strings.json, and services.yaml"
echo "commit_status=committed" >> $GITHUB_ENV
fi
- name: Push changes
if: env.commit_status == 'committed'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}