Skip to content

ulukyn/fbxtools

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Interface within Freebox API and Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%