Package: pyfbx
Freebox client libraryFeaturesFull API coverageHttps and Mdns discoveryThin client wrapper library (<200 lines)Small script to perform most tasksLibrary usageThe library is available to create your own scripts.
The REST API is generated at runtime with the creation of class attributes for all Freebox subsystems.>>>frompyfbximportFbx>>>f=Fbx()# By default, this will perform MDNS discovery>>>f=Fbx(nomdns=True)# Use faster http api discovery>>>f.<TAB>f.Airmediaf.Download_Configf.Lanf.Rrdf.Upnpavf.Callf.Download_Feedsf.Lcdf.Sharef.Vpnf.Connectionf.Freeplugf.Natf.Storagef.Vpn_Clientf.Contactsf.Fsf.Network_Sharef.Switchf.Wifif.Dhcpf.Ftpf.Parentalf.Systemf.mksession(f.Downloadf.Igdf.Pvrf.Uploadf.register(>>>f.Freeplug.<TAB>f.Freeplug.Get_a_particular_Freeplug_information(f.Freeplug.Reset_a_Freeplug(f.Freeplug.Get_the_current_Freeplugs_networks(# Register application to get app token. Physical access is required.>>>token=f.register("AppId","My App","PC")# Generate session token>>>f.mksession(app_id="AppId",token=token)>>>help(f.Lan.Update_the_current_Lan_configuration)HelponmethodUpdate_the_current_Lan_configuration:Update_the_current_Lan_configuration(post_data)methodofpyfbx.client.LaninstanceUpdatethecurrentLanconfigurationUrlparameters:Postdata:PostData>>>help(f.Contacts.Access_a_given_contact_entry)HelponmethodAccess_a_given_contact_entry:Access_a_given_contact_entry(id)methodofpyfbx.client.ContactsinstanceAccessagivencontactentryUrlparameters:idPostdata:>>>f.Lan.Get_the_current_Lan_configuration(){'name_dns':'freebox-server','name':'Freebox Server','name_mdns':'Freebox-Server','mode':'router','name_netbios':'Freebox_Server','ip':'192.168.1.254'}# Any subsequent call to mksession will refresh the session token>>>f.mksession()ScriptThe included script can perform a lot of tasks.Basics$pyfbx-h
usage:pyfbx[-h][-aAPP_ID][-tTOKEN][-v][-n][-j][-dDELAY][-uURL][-sSEND][-cCOMMAND]optionalarguments:-h,--helpshowthishelpmessageandexit-aAPP_ID,--app_idAPP_IDapplicationidentifier-tTOKEN,--tokenTOKENtoken(orf:<filename>)-v,--verboseincreaseverbositytoINFO,usetwiceforDEBUG-n,--httpdisableMDNSandusehttpknownaddress-j,--jsonjsonoutput-dDELAY,--delayDELAYcylicallysendcommand(numberofseconds)-uURL,--urlURLspecificurltoquery-sSEND,--sendSENDurltosendjsonto-cCOMMAND,--commandCOMMANDcommand,defaultstoSystem.Get_the_current_system_info()First, register the application:$pyfbx-aSuperAppIdOnce registration is done on the device, write down the application token.
You can also create a file with token as first line and application Id as second.Using this app token, acquire a session token to execute a test command.$pyfbx-t'<TOKEN>'-aSuperAppId

$cattoken.txt
2OUDy4hhM/KLQ7ru+70gfi83h5A4DUoOpDztOfqM4c2wuUiWJ+gXTHB1SbxHAFP7
SuperAppId

$pyfbx-tf:token.txt-c'Connection.Get_the_current_Connection_status()'{'bandwidth_down':1000000000,[..]'state':'up','type':'ethernet'}Note: Don't forget to escape token and command with quotes.AdvancedYou can run any commands on the freebox and retrieve complete result or single value$pyfbx-tf:/home/foo/token.txtSuperAppId-c'Contacts.Create_a_contact(\post_data={"display_name": "Sandy Kilo", "first_name": "Sandy", "last_name":"Kilo"})'{'birthday':'',[..]'photo_url':''}$pyfbx-uhttps://0s2efr3i.fbxos.fr:15628-c"Connection.Get_the_current_Connection_status()['rate_up']"-tf:token.txt1700With the delay option, commands can be sent cyclically:$pyfbx-d1-c"Connection.Get_the_current_Connection_status()['rate_up']"-tf:token.txt424605071053400With the send option, result can be sent to a remote URL.
In the following, the result is sent cyclically to example.com in json format.pyfbx-j-shttp://example.com/values-d10-c"Connection.Get_the_current_Connection_status()"-tf:token.txtIt's possible to execute several commands.
Here, two commands are sent cyclically and results sent to an URL.pyfbx-c'System.Get_the_current_system_info()'-c'Connection.Get_the_current_Connection_status()'-d10-j-shttp://localhost:8182/telegraf-tf:token.txtTelegraf http listener v2 input plugin with json format can be used to plot data in realtime.Telegraf and Graphana plotsYou can use a telegraph configuration in /etc/telegraf/telegraf.d/freebox:[[inputs.http_listener_v2]]
    service_address = ":8182"
    path = "/telegraf"
    methods = ["POST"]
    read_timeout = "10s"
    write_timeout = "10s"
    max_body_size = "5KB"
    data_format = "json"
    name_override = "pyfbx"DeveloppmentTestingYou can run tests withpip3install-rrequirements-dev.txt
pytesttestsThe library mechanisms are tested. To get 100% coverage, a Freebox on its default IP (192.168.1.254) is required.The API description is generated and thus not functionnaly tested.