Skip to content

Update device: Zigbee 4 button remote - 12 scene (TS0044_1) by Tuya b… #1186

Update device: Zigbee 4 button remote - 12 scene (TS0044_1) by Tuya b…

Update device: Zigbee 4 button remote - 12 scene (TS0044_1) by Tuya b… #1186

name: JSON Library Sorter and Doc Gen
on:
workflow_dispatch:
push:
paths:
- 'custom_components/battery_notes/data/library.json'
- '.github/workflows/json_librarian.yml'
- '.github/workflows/scripts/library_doc/**'
jobs:
librarian:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: Clean up JSON library file
id: update-json
uses: jannekem/run-python-script-action@v1
with:
script: |
import json
# Load the existing JSON library file
with open("custom_components/battery_notes/data/library.json", "r", encoding="UTF-8") as f:
devices_json = json.loads(f.read())
devices = devices_json.get("devices")
# Sort the devices by manufacturer and model
devices.sort(key=lambda k: (k["manufacturer"].lower(), k.get("model_match_method", "").lower(), k["model"].lower(), k.get("model_id", "").lower(), k.get("hw_version", "").lower()))
with open("custom_components/battery_notes/data/library.json", "w", encoding="UTF-8") as f:
f.write(json.dumps(devices_json, indent=4))
- name: Install library doc generator dependencies
run: |
python -m pip install -r ${{ github.workspace }}/.github/scripts/library_doc/requirements.txt
- name: Generate library doc
run: |
python3 ${{ github.workspace }}/.github/scripts/library_doc/generate_file.py
- name: Commit any changes
uses: stefanzweifel/git-auto-commit-action@v5