File tree Expand file tree Collapse file tree 3 files changed +50
-2
lines changed
Expand file tree Collapse file tree 3 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ 22.14.0
Original file line number Diff line number Diff line change 11import asyncio
2+ import logging
23import os
34from pathlib import Path
45
56import orjson
67from pysmartthings import Capability , SmartThings
78import yaml
89
10+ LOGGER = logging .getLogger (__name__ )
11+
912async 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" )
You can’t perform that action at this time.
0 commit comments