1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-15 08:33:52 -05:00

16 Commits
0.7.7 ... 0.7.8

Author SHA1 Message Date
Nathan Spencer
04e98ee103 Merge pull request #34 from natekspencer/update-tracks
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Update tracks
2024-10-04 13:20:23 -06:00
natekspencer
4945b1e6b7 Update tracks 2024-10-04 19:17:03 +00:00
Nathan Spencer
88537ee3c7 Merge pull request #33 from natekspencer/update-tracks
Some checks are pending
Validate repo / Validate with hassfest (push) Waiting to run
Validate repo / Validate with HACS (push) Waiting to run
Update tracks
2024-10-03 13:46:22 -06:00
natekspencer
d971cc55c6 Update tracks 2024-10-02 19:16:48 +00:00
Nathan Spencer
739ee874d3 Merge pull request #32 from natekspencer/update-tracks
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Handle removed updated_at property for updating tracks
2024-09-18 14:56:22 -06:00
Nathan Spencer
78de49e12c Handle removed updated_at property 2024-09-18 20:54:40 +00:00
Nathan Spencer
57280d46fc Merge pull request #31 from natekspencer/update-tracks
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Update tracks
2024-09-10 10:31:56 -06:00
natekspencer
51c4cee3f6 Update tracks 2024-09-05 19:14:58 +00:00
Nathan Spencer
782a794a32 Merge pull request #30 from natekspencer/update-tracks
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Update tracks
2024-09-01 13:54:45 -06:00
natekspencer
2cd196f0f0 Update tracks 2024-09-01 19:14:44 +00:00
Nathan Spencer
02a073943b Merge pull request #28 from natekspencer/update-tracks
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Update tracks
2024-08-30 14:20:45 -06:00
natekspencer
c7a8732ad5 Update tracks 2024-08-30 19:14:36 +00:00
Nathan Spencer
7b11d79de1 Merge pull request #27 from natekspencer/update-tracks-gha
Some checks are pending
Validate repo / Validate with hassfest (push) Waiting to run
Validate repo / Validate with HACS (push) Waiting to run
Add appropriate permissions
2024-08-30 12:41:05 -06:00
Nathan Spencer
de64e61666 Add appropriate permissions 2024-08-30 12:40:02 -06:00
Nathan Spencer
59134b0473 Merge pull request #26 from natekspencer/update-tracks-gha
Some checks failed
Validate repo / Validate with hassfest (push) Has been cancelled
Validate repo / Validate with HACS (push) Has been cancelled
Add GitHub Action for updating track details
2024-08-30 10:52:51 -06:00
Nathan Spencer
893ac4e327 Add GHA for updating track details 2024-08-30 10:50:56 -06:00
3 changed files with 1092 additions and 2 deletions

33
.github/workflows/update-tracks.yml vendored Normal file
View File

@@ -0,0 +1,33 @@
name: Update tracks
on:
schedule:
- cron: "0 19 * * *"
permissions:
contents: write
pull-requests: write
jobs:
tracks:
name: Search and update new tracks
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install homeassistant
- name: Update tracks
env:
GROUNDED_TOKEN: ${{ secrets.GROUNDED_TOKEN }}
run: python update_tracks.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update tracks
title: Update tracks
body: Update tracks
base: main
labels: automated-pr, tracks
branch: update-tracks

File diff suppressed because it is too large Load Diff

69
update_tracks.py Normal file
View File

@@ -0,0 +1,69 @@
"""Script to update track details from Grounded Labs."""
from __future__ import annotations
import asyncio
import json
import os
from typing import Any
from custom_components.oasis_mini.pyoasismini import OasisMini
from custom_components.oasis_mini.pyoasismini.const import TRACKS
ACCESS_TOKEN = os.getenv("GROUNDED_TOKEN")
async def update_tracks() -> None:
"""Update tracks."""
client = OasisMini("", ACCESS_TOKEN)
try:
data = await client.async_cloud_get_tracks()
except Exception as ex:
print(type(ex).__name__, ex)
await client.session.close()
return
if not isinstance(data, list):
print("Unexpected result:", data)
return
updated_tracks: dict[int, dict[str, Any]] = {}
for result in filter(lambda d: d["public"], data):
if (
(track_id := result["id"]) not in TRACKS
or result["name"] != TRACKS[track_id].get("name")
or result["image"] != TRACKS[track_id].get("image")
):
print(f"Updating track {track_id}: {result["name"]}")
track_info = await client.async_cloud_get_track_info(int(track_id))
if not track_info:
print("No track info")
break
author = (result.get("author") or {}).get("user") or {}
updated_tracks[track_id] = {
"id": track_id,
"name": result["name"],
"author": author.get("name") or author.get("nickname") or "Oasis Mini",
"image": result["image"],
"clean_pattern": track_info.get("cleanPattern", {}).get("id"),
"reduced_svg_content": track_info.get("reduced_svg_content"),
}
await client.session.close()
if not updated_tracks:
print("No updated tracks")
return
tracks = {k: v for k, v in TRACKS.items() if k in map(lambda d: d["id"], data)}
tracks.update(updated_tracks)
tracks = dict(sorted(tracks.items(), key=lambda t: t[1]["name"].lower()))
with open(
"custom_components/oasis_mini/pyoasismini/tracks.json", "w", encoding="utf8"
) as file:
json.dump(tracks, file, indent=2, ensure_ascii=False)
if __name__ == "__main__":
asyncio.run(update_tracks())