If you like BoxMatrix then please contribute Supportdata, Supportdata2, Firmware and/or Hardware (get in touch).
My metamonk@yahoo.com is not reachable by me since years. Please use hippie2000@webnmail.de instead.

0
U

Property:smarthome rest.lua

From BoxMatrix


BoxMatrix >> Webinterface >> smarthome_rest.lua @ BoxMatrix   -   IRC-Chat   -   Translate: de es fr it nl pl
News Selectors Models Accessories Components Environment Config Commands System Webif Software Develop Lexicon Community Project Media

UI-Structure UI-Modules HTML-Files XML-Files Lua-Scripts Javascript Browser SSI-Files SSI-Directives HTML-Text Event-Text Help-Pages CSS-Files Graphics Research

Lua-Script

Goto:   Functions  -  Dependencies   -   Model-Matrix   -   SMW-Browser

Details

This has been found in Labor, but did not make it to Release. It may be a test case or a future feature.

smarthome_rest.lua is the REST-API Module for box notifications.
It is loaded by rest_config.lua and provides the smarthome endpoint, which is accessible by:

GET /api/v0/smarthome                               # get smarthome infos, devices, templates
GET /api/v0/smarthome/simplified                    # get smarthome infos, devices, templates, simplified

GET /api/v0/smarthome/devices                       # get smarthome devices list
GET /api/v0/smarthome/devices/simplified            # get smarthome devices list, simplified

GET /api/v0/smarthome/devices/<string>                   # get a single device
GET /api/v0/smarthome/devices/<string>/<string>          # get a sublevel 1 device
GET /api/v0/smarthome/devices/<string>/<string>/<string> # get a sublevel 2 device
PUT /api/v0/smarthome/devices/<string>                   # set a single device
PUT /api/v0/smarthome/devices/<string>/<string>          # set a sublevel 1 device
PUT /api/v0/smarthome/devices/<string>/<string>/<string> # set a sublevel 2 device

GET /api/v0/smarthome/templates                     # get templates list
GET /api/v0/smarthome/templates/<string>            # get a single template
GET /api/v0/smarthome/templates/<string>/<string>   # get a sublevel 1 template
PUT /api/v0/smarthome/templates/<string>            # set a single template
POST /api/v0/smarthome/templates/<string>           # create a single template

GET /api/v0/smarthome/triggers                      # get triggers list
GET /api/v0/smarthome/triggers/<string>             # get a single trigger
PUT /api/v0/smarthome/triggers/<string>             # set a single trigger

GET /api/v0/smarthome/statistics/<string>           # get device statistics
GET /api/v0/smarthome/statistics/<string>/<string>  # get subkey device statistics

GET /api/v0/smarthome/global                        # get smarthome list
GET /api/v0/smarthome/global/<string>               # get subkey smarthome list 

REST-API:

Functions

The function names of scripts often help to understand function blocks (and show gaps in the docs). fw 7530-7.39-96136 functions:

$ grep -e '^function' -e '^local function' /usr/rest_api/smarthome_rest.lua

# Get smarthome ressources.
function smarthome_rest.getRestRessources(rootPath)

# Helper function to check if the libaha lua lib is loaded.
local function assert_smarthome()

# Get Device ID, check params if AIN or ID.
local function get_deviceid(params)

# Get Tempalte ID, check params if AIN or ID.
local function get_templateid(params)

# Get Trigger Identifier/UID.
local function get_triggeruid(params)

# Send json-data-reponse, wrapper
local function send_response(data, key)

# empty
local function getglobalinfos()

# Send timer lua-table to json compatible table, array with values[].
local function jsonformat_values(timer)

# Check and convert device-lua-table to json compatible tables.
local function jsonformat_device(device)

# Check and convert template-lua-table to json compatible tables
local function jsonformat_template(template)

# Get json compatible devicelist-table.
local function get_wrapped_enhdevicelist(simplified)

# Get json compatible device-table.
local function get_wrapped_enhdevice(id)

# Get json compatible templatelist-table.
local function get_wrapped_templatelist(simplified)

# Get json compatible template-table.
local function get_wrapped_template(id)

# Get devices, templates, triggers.
local function get_smarthome_helper(params, simplified)

# Handler function to Send a global Smarthome infos and the smarthome device and templates list to the client.
# GET /api/v0/smarthome
function smarthome_rest.get_smarthome(params)

# Handler function to Send a global Smarthome infos and the simplified smarthome device and templates list to the client.
# GET /api/v0/smarthome/simplified
function smarthome_rest.get_smarthome_simplified(params)

# Helper function for get_devices
local function get_devices_helper(params, simplified)

# Handler function to Send a Smarthome devices list to the client.
# GET /api/v0/smarthome/devices
function smarthome_rest.get_devices(params)

# Handler function to Send a simplified Smarthome-devices list to the client.
# GET /api/v0/smarthome/devices/simplified
function smarthome_rest.get_devices_simplified(params)

# Handler function to Send a Smarthome device to the client.
# GET /api/v0/smarthome/devices/<string>
function smarthome_rest.get_device(params)

# Handler function to Send a template to the client.
# GET /api/v0/smarthome/templates/<string>
function smarthome_rest.get_template(params)

# Handler function to Send a trigger to the client.
# GET /api/v0/smarthome/triggers/<string>
function smarthome_rest.get_trigger(params)

# Helper function for get_statistics
local function getstatistics(deviceid)

# Handler function to Send a Smarthome device statistic to the client.
# GET /api/v0/smarthome/statistics/<string>
function smarthome_rest.get_statistic(params)

# Handler function to Send a Subkey Smarthome device statistic to the client.
# GET /api/v0/smarthome/statistics/<string>/<string>
function smarthome_rest.get_statistic_sublevel1(params)

# Handler function to Send a Smarthome list to the client.
# GET /api/v0/smarthome/global
function smarthome_rest.get_global(params)

# Handler function to Send the global.subkey Info to the client.
# GET /api/v0/smarthome/global/<string>
function smarthome_rest.get_global_sublevel1(params)

# Handler function to Send a template list to the client.
# GET /api/v0/smarthome/templates
function smarthome_rest.get_templates(params)

# Handler function to Send a trigger list to the client.
# GET /api/v0/smarthome/triggers
function smarthome_rest.get_triggers(params)

# Handler function to Send a Smarthome device to the client.
# GET /api/v0/smarthome/devices/<string>/<string>
function smarthome_rest.get_device_sublevel1(params)

# Handler function to Send a Smarthome device to the client.
# GET /api/v0/smarthome/devices/<string>/<string>/<string>
function smarthome_rest.get_device_sublevel2(params)

# Handler function to Apply a template.
local function checkapply(puttemplate)

# Handler function to set Metadata of a template.
local function checksetmetadata(putobj, prevobj)

# Handler function to active to a trigger.
local function checktriggeractive(puttrigger)

# Handler function to Send a Template to the client.
# GET /api/v0/smarthome/templates/<string>/<string>
function smarthome_rest.get_template_sublevel1(params)

# Helper function
local function checksethkrtemperature(putdevice, device)

# Helper function
local function checksetblindopenclosestop(putdevice, device)

# Helper function
local function checksetcolorcontrol(putdevice, device)

# Helper function
local function checksetlevel(putdevice, device)

# Helper function
local function checksetboost(putdevice, device)

# Helper function
local function checksetwindowopen(putdevice, device)

# Helper function
local function checksetsimpleonoff(putdevice, device)

# Helper function
local function checksetname(putobj, prevobj)

# Helper function
local function putcheck(putdevice,device)

# Helper function
local function puttemplatecheck(puttempalte,template)

# Handler function to Put/Set a Smarthome Template to the client.
# PUT /api/v0/smarthome/templates/<string>
function smarthome_rest.put_template(params)

# Handler function to Post/Create a Smarthome Template.
# POST /api/v0/smarthome/templates/<string>
function smarthome_rest.post_template(params)

# Helper function
local function puttriggercheck(puttrigger,trigger)

# Handler function to Put/Set a Smarthome trigger to the client.
# PUT /api/v0/smarthome/triggers/<string>
function smarthome_rest.put_trigger(params)

# Handler function to Put/Set a Smarthome device to the client.
# PUT /api/v0/smarthome/devices/<string>
function smarthome_rest.put_device(params)

# Handler function to Put/Set a Smarthome Device to the client.
# PUT /api/v0/smarthome/devices/<string>/<string>
function smarthome_rest.put_device_sublevel1(params)

# Handler function to Put/Set a Smarthome Device to the client.
# PUT /api/v0/smarthome/devices/<string>/<string>/<string>
function smarthome_rest.put_device_sublevel2(params)

# Einen einfachen Table in einen String verwandelt, der gültiger Luacode ist.
function dumptable(tbl, level, done)

# Stringvergleich fürs Sortieren
function _.cmp(str1, str2)

# Ein Iterator wie pairs, der die Tableeinträge in nach den Keys sortierter Reihenfolge ausgibt.
function _.sorted_pairs(tbl)

# Capiterm-Ausgaben.
local function capiterm_write(...)

# Funktion zur Ausgabe beliebig vieler Parameter in Capiterm.
function smarthome_rest.cprint(...)

# Funktion zur Ausgabe eines Tables im Capiterm mit dumptable
function smarthome_rest.cdump(txt, t)

Not listed in the Dependencies: This loads the libaha.so library.

Dependencies

Daily updated index of all dependencies of this script. Last update: 2024-04-18 08:35 GMT.
A * in the Mod column marks info from Supportdata-Probes, which will always stay incomplete.
If an Object includes itself then this is a file with the same name but another Path and the dependencies are merged.

Relation Typ Object Mod Firmware Info Origin
Requires lua response.lua 17 7.39 - 7.90 REST-API Response API AVM
Requires lua rest_api_const.lua 17 7.39 - 7.90 REST-API Const Tables AVM
Includes js box.js 17 7.39 - 7.90 TODO AVM
3 dependencies for this script

Model-Matrix

Daily updated index of the presence, path and size of this script for each model. Last update: 2024-04-18 06:18 GMT.
Showing all models using this script. Click any column header (click-wait-click) to sort the list by the respective data.
The (main/scrpn/boot/arm/prx/atom) label in the Model column shows which CPU is meant for models with multiple Linux instances.
Note that this list is merged from Firmware-Probes of all known AVM firmware for a model, including Recovery.exe and Labor-Files.

Model Firmware Path Size/Bytes
FRITZ!Box 5530 Fiber (main) 7.70 - 7.80 /usr/rest_api 47.4k
FRITZ!Box 5590 Fiber (arm) 7.70 - 7.90 /usr/rest_api 47.4k - 49.7k
FRITZ!Box 5590 Fiber (prx) 7.70 - 7.90 /usr/rest_api 47.4k - 49.7k
FRITZ!Box 6591 Cable (arm) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6591 Cable (atom) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6660 Cable (arm) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6660 Cable (atom) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6690 Cable (arm) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6690 Cable (atom) 7.39 /usr/rest_api 43.6k
FRITZ!Box 6890 LTE 7.39 /usr/rest_api 43.6k
FRITZ!Box 6890 LTE v1 7.39 /usr/rest_api 43.6k
FRITZ!Box 6890 LTE v2 7.39 /usr/rest_api 43.6k
FRITZ!Box 7530 7.39 /usr/rest_api 43.6k
FRITZ!Box 7530 AX 7.70 - 7.90 /usr/rest_api 47.4k - 49.7k
FRITZ!Box 7590 7.39 - 7.90 /usr/rest_api 39.8k - 49.7k
FRITZ!Box 7590 AX 7.39 - 7.90 /usr/rest_api 43.6k - 49.7k
FRITZ!Repeater 2400 7.39 /usr/rest_api 43.6k
17 models use this script

SMW-Browser

Information is currently being retrieved from the backend.
 

Synonyms

Showing 1 related property.

s