JavaScript API
From MiOS
(Difference between revisions)
(→Functions) |
|||
Line 35: | Line 35: | ||
== Functions == | == Functions == | ||
− | ==== | + | ==== variable_get (serviceId, variable, deviceId, dynamic) ==== |
+ | |||
+ | (wrapper for '''get_device_state (deviceId, serviceId, variable, dynamic)''') | ||
+ | |||
'''Input:''' | '''Input:''' | ||
− | * | + | * serviceId (string) |
− | + | ||
* variable (string) | * variable (string) | ||
− | * dynamic (number): if '''1''' the variable value is taken from ''lu_status'', else the variable value is taken from ''user_data'' | + | * deviceId (number) |
+ | * dynamic (number): if '''1''', the variable's value is taken from ''lu_status'', else, the variable's value is taken from ''user_data''. ''user_data'' is read at Luup startup, so for variables that change their value frequently (like Watts, Temperature, etc.) ''dynamic'' should be '''1'''. | ||
'''Output:''' | '''Output:''' | ||
* variable value (string or ''undefined'') | * variable value (string or ''undefined'') | ||
− | ==== variable_set | + | ==== variable_set (serviceId, variable, value, deviceId, dynamic) ==== |
− | (wrapper for '''set_device_state ( | + | (wrapper for '''set_device_state (deviceId, serviceId, variable, value, dynamic)''') |
'''Input:''' | '''Input:''' | ||
Line 54: | Line 57: | ||
*variable (string) | *variable (string) | ||
*value (string) | *value (string) | ||
− | * | + | *deviceId (number) |
− | *dynamic (number): if '''1''', the variable's value is saved to ''lu_status'' (the value is lost after Luup is restarted), else the variable's value is saved to ''user_data'' (requires restart to save the new value). | + | *dynamic (number): if '''1''', the variable's value is saved to ''lu_status'' (the value is lost after Luup is restarted), else, the variable's value is saved to ''user_data'' (requires restart to save the new value). |
'''Output:''' | '''Output:''' |
Revision as of 11:43, 23 May 2011
Contents |
Variables
jsonp.ud
This is the user data.
- Type: object
- Members:
- devices (array)
- scenes (array)
- users (array)
- rooms (array)
- eventList (array)
- etc.
jsonp.ud.devices
- Type: array
- Members:
- id (number)
- device_type (string)
- room (number)
- name (string)
- category_num (number)
- etc.
jsonp.ud.scenes
- Type: array
- Members:
- id (number)
- name (string)
- room (number)
- Timer_ids (array)
- Timer (object)
- etc.
Functions
variable_get (serviceId, variable, deviceId, dynamic)
(wrapper for get_device_state (deviceId, serviceId, variable, dynamic))
Input:
- serviceId (string)
- variable (string)
- deviceId (number)
- dynamic (number): if 1, the variable's value is taken from lu_status, else, the variable's value is taken from user_data. user_data is read at Luup startup, so for variables that change their value frequently (like Watts, Temperature, etc.) dynamic should be 1.
Output:
- variable value (string or undefined)
variable_set (serviceId, variable, value, deviceId, dynamic)
(wrapper for set_device_state (deviceId, serviceId, variable, value, dynamic))
Input:
- serviceId (string)
- variable (string)
- value (string)
- deviceId (number)
- dynamic (number): if 1, the variable's value is saved to lu_status (the value is lost after Luup is restarted), else, the variable's value is saved to user_data (requires restart to save the new value).
Output:
- true if the operation succeeded, false otherwise
_console (str)
Input:
- str (string): text to be written in the console. You need to have FireBug installed.
Output:
- nothing
set_panel_html (html)
Used in the tab rendering functions.
Input:
- html (string): The html to be used for generating the tab content.
Output:
- nothing