Giter VIP home page Giter VIP logo

yoto_api's Introduction

Introduction

Early days of this API. Plan is to use this for home assistant. So far basic device data comes back including online. The library of cards is also populated. Pause command functions. Not other commands work yet.

Credit

A big thank you to @buzzeddesign for helping to sniff some of the API and make sense of it. Thank you to @fuatakgun for creating to core architecture is based on over in kia_uvo.

Example Test Code

To run this code for test I am doing:

from pathlib import Path
import logging
import sys
import os

path_root = r"C:path to files GitHub\main\yoto_api"
sys.path.append(str(path_root))
from yoto_api import *

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format='%(asctime)s %(name)s %(levelname)s:%(message)s')
logger = logging.getLogger(__name__)

ym = YotoManager(username="username", password="password")
ym.check_and_refresh_token()
ym.update_player_status()
print (ym.players)
ym.connect_to_events()
# Pauses the first player
ym.pause_player(next(iter(ym.players)))
# Sleep will let the terminal show events coming back. For dev today.
time.sleep(60)

Usage

For additional methods not mentioned below follow the file here for all functionality: https://github.com/cdnninja/yoto_api/blob/master/yoto_api/YotoManager.py

Check and refresh token will pull the first set of data. It also should be run regularly if you keep your code running for days. It will check if the token is valid. If it isn't it will refresh the token. If this is first run of the command and no data has been pulled it will also run update_player_status() and update_cards() for you.

ym.check_and_refresh_token()

Check and refresh token will pull the first set of data. It also should be run regularly if you keep your code running for days. It will check if the token is valid. If it isn't it will refresh the token. If this is first run of the command and no data has been pulled it will also run update_player_status() and update_cards() for you.

ym.update_player_status()

Connects to the MQTT broker. This must be run before any command and also get get useful data.

ym.connect_to_events()

Pauses the player for the player ID sent. ID can be found in ym.players.keys()

ym.pause_player(player_id: str)

Updates the library of cards. This is done as part of check_refresh_token so only needed if data is stale.

ym.update_cards()

Contains player object with data values you can access.

ym.players

Contains the library of cards. Each card being an object with the data values you can use.

ym.library

Get Set Up For Development

Set up pyenv:

pyenv install

Install the dependencies:

pip install -r requirements.txt
pip install -r requirements_dev.txt

Tests

Create a .env file in the root of the project with the following content:

YOTO_USERNAME=your_username
YOTO_PASSWORD=your_password

Run the tests with:

python -m pytest

Other Notes

This is not associated or affiliated with yoto play in any way.

yoto_api's People

Contributors

cdnninja avatar actions-user avatar pre-commit-ci[bot] avatar buzzeddesign avatar robertbeal avatar dependabot[bot] avatar cjb0001 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.