mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-12-06 18:44:14 -05:00
📝 Add docstrings to mqtt
Docstrings generation was requested by @natekspencer. * https://github.com/natekspencer/hacs-oasis_mini/pull/98#issuecomment-3568450288 The following files were modified: * `custom_components/oasis_mini/__init__.py` * `custom_components/oasis_mini/binary_sensor.py` * `custom_components/oasis_mini/button.py` * `custom_components/oasis_mini/config_flow.py` * `custom_components/oasis_mini/coordinator.py` * `custom_components/oasis_mini/entity.py` * `custom_components/oasis_mini/helpers.py` * `custom_components/oasis_mini/image.py` * `custom_components/oasis_mini/light.py` * `custom_components/oasis_mini/media_player.py` * `custom_components/oasis_mini/number.py` * `custom_components/oasis_mini/pyoasiscontrol/clients/cloud_client.py` * `custom_components/oasis_mini/pyoasiscontrol/clients/http_client.py` * `custom_components/oasis_mini/pyoasiscontrol/clients/mqtt_client.py` * `custom_components/oasis_mini/pyoasiscontrol/clients/transport.py` * `custom_components/oasis_mini/pyoasiscontrol/device.py` * `custom_components/oasis_mini/pyoasiscontrol/utils.py` * `custom_components/oasis_mini/select.py` * `custom_components/oasis_mini/sensor.py` * `custom_components/oasis_mini/switch.py` * `custom_components/oasis_mini/update.py` * `update_tracks.py`
This commit is contained in:
committed by
GitHub
parent
cf21a5d995
commit
4ef28fc741
@@ -14,13 +14,29 @@ ACCESS_TOKEN = os.getenv("GROUNDED_TOKEN")
|
||||
|
||||
|
||||
def get_author_name(data: dict) -> str:
|
||||
"""Get author name from a dict."""
|
||||
"""
|
||||
Extracts the author's display name from a nested track data dictionary.
|
||||
|
||||
Parameters:
|
||||
data (dict): A mapping representing track/result data. Expected shapes include
|
||||
{"author": {"user": {"name": ..., "nickname": ...}}} or {"author": {"name": ..., "nickname": ...}}.
|
||||
|
||||
Returns:
|
||||
str: The author's `name` if present, otherwise the author's `nickname`, otherwise "Kinetic Oasis".
|
||||
"""
|
||||
author = (data.get("author") or {}).get("user") or {}
|
||||
return author.get("name") or author.get("nickname") or "Kinetic Oasis"
|
||||
|
||||
|
||||
async def update_tracks() -> None:
|
||||
"""Update tracks."""
|
||||
"""
|
||||
Fetch tracks from the Grounded Labs cloud, detect new or changed public tracks compared to the local TRACKS mapping, augment changed entries with author and reduced SVG content, and persist the merged, sorted track list to custom_components/oasis_mini/pyoasiscontrol/tracks.json.
|
||||
|
||||
Side effects:
|
||||
- May print error or status messages to stdout.
|
||||
- Writes the updated tracks JSON file.
|
||||
- Ensures the OasisCloudClient session is closed and returns early on errors or unexpected data.
|
||||
"""
|
||||
client = OasisCloudClient(access_token=ACCESS_TOKEN)
|
||||
|
||||
try:
|
||||
@@ -71,4 +87,4 @@ async def update_tracks() -> None:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(update_tracks())
|
||||
asyncio.run(update_tracks())
|
||||
Reference in New Issue
Block a user