Skip to content

Commit 3cfc820

Browse files
committed
Initial commit
1 parent 75dd769 commit 3cfc820

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

.github/workflows/update.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Update data
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
accessToken:
9+
description: 'Access token to use for the SmartThings api'
10+
required: true
11+
12+
env:
13+
DEFAULT_PYTHON: "3.13"
14+
15+
jobs:
16+
update:
17+
name: Update
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: ⤵️ Check out code from GitHub
21+
uses: actions/checkout@v4.2.2
22+
- name: 🏗 Set up uv
23+
uses: astral-sh/setup-uv@v5.2.2
24+
with:
25+
enable-cache: true
26+
python-version: ${{ env.DEFAULT_PYTHON }}
27+
- name: 🏗 Install dependencies
28+
run: uv sync --extra cli --frozen --dev
29+
- name: 🏗 Set up Node.js
30+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
31+
with:
32+
node-version-file: ".nvmrc"
33+
cache: "npm"
34+
- name: 🏗 Install NPM dependencies
35+
run: npm install
36+
- name: 🚀 Update data
37+
env:
38+
SMARTTHINGS_TOKEN: ${{ github.event.inputs.accessToken }}
39+
run: python download.py
40+
- name: Create Pull Request
41+
uses: peter-evans/create-pull-request@v7

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22.14.0

download.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import asyncio
2+
import logging
23
import os
34
from pathlib import Path
45

56
import orjson
67
from pysmartthings import Capability, SmartThings
78
import yaml
89

10+
LOGGER = logging.getLogger(__name__)
11+
912
async def main():
13+
LOGGER.info("Downloading capabilities")
1014
json_root = Path("json")
1115
json_root.mkdir(exist_ok=True)
1216
yaml_root = Path("yaml")
1317
yaml_root.mkdir(exist_ok=True)
1418
async with SmartThings() as client:
15-
client.authenticate("")
16-
for capability in [Capability.VALVE]:
19+
client.authenticate(os.getenv("SMARTTHINGS_TOKEN"))
20+
for capability in Capability:
21+
LOGGER.info("Downloading %s", capability)
1722
standard_namespace = "." not in capability
1823
namespace = "standard" if standard_namespace else capability.split(".")[0]
1924
schema = await client.get_capability(capability)
@@ -24,6 +29,7 @@ async def main():
2429
yaml_path.mkdir(exist_ok=True)
2530
with open(yaml_path / f"{capability}.yaml", "w") as f:
2631
yaml.dump(orjson.loads(schema), f, sort_keys=False)
32+
LOGGER.info("Downloaded %s", capability)
2733
await asyncio.sleep(1)
2834

2935
os.system("npm run prettier")

0 commit comments

Comments
 (0)