Giter Site home page Giter Site logo

fbxtools's Introduction

Fbxtools

Provide intialisation, connect and disconnect functions for Freebox OS application.

Installation

pip install fbxtools

Get started

Fbx class

from fbxtools.fbx import Fbx

Accept 3 arguments:

  • url (str) : Freebox OS API url's
  • app_infos (str) : filepath of app_infos file (default: 'app_infos.json')
  • app_auth (str) : filepath of app_auth file (default: 'app_auth.json')
  • verify_cert (bool or str) : disable SSL cert verification or get certfile path. (default True)
  • mute (bool) : disable fbxtools message (default: False)

app_infos.json file

This file provide application informations. Must be created manually.

See http://dev.freebox.fr/sdk/os/login/#tokenrequest-object

example :

{
	"app_id": "fr.freebox.test",
	"app_name": "test",
	"app_version": "0.0.1",
	"device_name": "mycomputer"
}

app_auth.json file:

This file provide connect informations. Automatically generated with Fbx.get_app_token().

See http://dev.freebox.fr/sdk/os/login/#tokenrequest-object

example :

{
	"track_id": 6, 
	"app_token": "vfItuATAq8luiuDmo3ZeVVhb0Cv9uImxN2/VJRLa1rOjUsjkBxbEgPY9VwiwpSxq"
}

First use (Init app)

from fbxtools.fbx import Fbx

app = Fbx('http://mafreebox.freebox.fr')
app.get_app_token()

This function generated automatically 'app_auth.json' file. For Fbx.url argument, you can use:

example :

from fbxtools.utils import get_url_api
from fbxtools.fbx import Fbx

url_api = get_url_api()
app = Fbx(url_api)
app.get_app_token()

Work only on the same network as your freebox (local network).

Call API.

from fbxtools.fbx import Fbx

app = Fbx('http://mafreebox.freebox.fr')
app.get_session_token()


@app.api.call('/lcd/config')
def get_config():
	'''
	http://dev.freebox.fr/sdk/os/lcd/#get-the-current-lcd-configuration
	''' 
	return {}


@app.api.call('/lcd/config', method='PUT')
def update_config(config):
	'''
	http://dev.freebox.fr/sdk/os/lcd/#update-the-lcd-configuration
	'''
	return {'data': config, 'is_json': True}


if __name__ == "__main__":
	new_config = {	
		"brightness": 50,
		"orientation": 90,
		"orientation_forced": False
	}

	resp = get_config()
	print(resp)

fbxtools's People

Contributors

herrersystem avatar

Watchers

James Cloos avatar  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.