/**
* -----------------------------------------------------------------------------
* @package smartVISU
* @author Martin Gleiß and others
* @copyright 2012 - 2022
* @license GPL [http://www.gnu.de]
* -----------------------------------------------------------------------------
*/
/**
* Standard blind
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the blind
* @param {item(bool,num)=} an item for the up and down movement (optional, value_top/value_bottom will be sent to item_pos if omitted)
* @param {item(bool,num)=} an item for stopping the movement (optional)
* @param {item(num)} an item for the absolute position of the blinds
* @param {item(bool,num)=} an item for increase and decrease of the blade (optional)
* @param {item(num)=} an item for the absolute angle of the blade (optional)
* @param {value=0} the value for opened (optional, default 0)
* @param {value=255} the value for closed (optional, default 255)
* @param {value=5} step between two values (optional, default: 5)
*
* @info inspired by Frank Berlenz
*/
{% macro blind(id, txt, item_move, item_stop, item_pos, item_shift, item_angle, value_top, value_bottom, step) %}
{% import "@widgets/basic.html" as basic %}
{% endmacro %}
/**
* The Codepad is used to protect some widgets. You have to enter a correct code to use the widgets for a time.
* You may specify a global code in the config.php for all codepads.
*
* @param {id} unique id for this widget
* @param {value=} code to be entered (optional, default in config)
* @param {text=} a title for the pad (optional)
* @param {duration=10s} how long should the widgets be unlocked (optional, default: 10 seconds)
*/
{% macro codepad(id, code, title, duration) %}
{% endmacro %}
/**
* Standard dimmer with switching and dimming function
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the dimmer
* @param {item(bool,num)} an item for switching
* @param {item(num)} an item for dimming
* @param {value=0} the minimum value if the slider is moved to total left (optional, default: 0)
* @param {value=255} the maximum value if the slider is moved to total right (optional, default: 255)
* @param {value=5} step between two values (optional, default: 5)
* @param {image=light_light} the pic for the 'on' state (optional)
* @param {image=light_light} the pic for the 'off' state (optional)
* @param {color(icon0to5)=icon1} the color for the 'on' state (optional)
* @param {color(icon0to5)=icon0} the color for the 'off' state (optional)
* @param {text(input,handle,both,none)=none} how should the value be shown; possible options: 'input', 'handle', 'both', 'none' (optional, default 'none')
* @param {value=} the minimum value to display if the slider is moved to total left if this should differ from sent/received value (optional, default like min)
* @param {value=} the maximum value to display if the slider is moved to total right if this should differ from sent/received value (optional, default like max)
* @param {text(left,right)=left} position of the switch: left (default) or right
*/
{% macro dimmer(id, txt, item_switch, item_value, min, max, step, pic_on, pic_off, color_on, color_off, value_display, min_display, max_display, picpos) %}
{% import "@widgets/basic.html" as basic %}
{% if picpos is empty or picpos=='left' %}
{% endmacro %}
/**
* Roof window
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the window
* @param {item(bool,num)=} an item for the open and close movement (optional, value_top/value_bottom will be sent to item_pos if omitted)
* @param {item(bool,num)=} an item for stopping the movement (optional)
* @param {item(num)} an item for the absolute position
* @param {item(num)=} an item for some saved positions (optional)
* @param {value=0} the value for closed (optional, default 0)
* @param {value=255} the value for opened (optional, default 255)
* @param {value=5} step between two values (optional, default 5)
* @param {value=0} the value to send for position 1 (optional, default 0)
* @param {value=1} the value to send for position 2 (optional, default 1)
* @param {text=Pos1} the text printed on button for position 1 (optional, default Pos1)
* @param {text=Pos2} the text printed on button for position 2 (optional, default Pos2)
*
* @author Stefan Widmer
*/
{% macro roofwindow(id, txt, item_move, item_stop, item_pos, item_saved, value_closed, value_opened, step, value_pos_1, value_pos_2, text_pos_1, text_pos_2) %}
{% import "@widgets/basic.html" as basic %}
{% import "@widgets/icon.html" as icon %}
{% endmacro %}
/**
* Standard RTR (Room Temperatur Regulator)
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the rtr
* @param {item(num)} an item for the actual temperature
* @param {item(num)} an item for the set temperature
* @param {item(bool,num)=} an item for comfort / standby (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for night (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for frost (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for the current state of the actuator (optional)
* @param {item(str)=} an item for a text (some rtr have a text-display), (optional)
* @param {value=0.5} step for plus/minus buttons (optional, default: 0.5)
* @param {item(num)=} an item for the offset temperature (optional, if provided set temperature changes will be written to this item instead of 'item_set')
* @param {text[]=} list of additional widgets / content to display
*/
{% macro rtr(id, txt, item_actual, item_set, item_comfort, item_night, item_frost, item_state, item_txt, step, item_offset, supplements) %}
{% import "@widgets/basic.html" as basic %}
{% endif %}
{% if item_comfort is not empty or item_night is not empty or item_frost is not empty or item_state is not empty or supplements is not empty %}
{% if item_comfort is not empty and (item_comfort == item_night or item_night is empty) and (item_comfort == item_frost or item_frost is empty) %}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['comfort', 'standby'] : [1, 2]), ['user_available.svg', 'user_away.svg'], '', ['icon1', 'icon0']) }}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['night', 'standby'] : [3, 2]), ['scene_night.svg', 'scene_night.svg'], '', ['icon1', 'icon0']) }}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['frost', 'standby'] : [4, 2]), ['weather_frost.svg', 'weather_frost.svg'], '', ['icon1', 'icon0']) }}
{% else %}
{% if item_comfort is not empty %}
{{ basic.stateswitch('', item_comfort, 'icon', '', ['user_away.svg', 'user_available.svg']) }}
{% endif %}
{% if item_night is not empty %}
{{ basic.stateswitch('', item_night, 'icon', '', ['scene_night.svg', 'scene_night.svg']) }}
{% endif %}
{% if item_frost is not empty %}
{{ basic.stateswitch('', item_frost, 'icon', '', ['weather_frost.svg', 'weather_frost.svg']) }}
{% endif %}
{% endif %}
{% if item_state is not empty %}
{{ basic.stateswitch('', item_state, 'icon', '', 'sani_heating.svg') }}
{% endif %}
{% for supplement in supplements %}
{{ supplement|raw }}
{% endfor %}
{% endif %}
{% endmacro %}
/**
* Displays a round slider for RTR
* @param {id} unique id for this widget (mandatory)
* @param {item(num)} an item for the actual temperature
* @param {item(num)} an item for the set temperature
* @param {item(bool,num)=} an item for comfort / standby (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for night (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for frost (3x bit or 1x byte, optional)
* @param {item(bool,num)=} an item for the current state of the actuator (optional)
* @param {value=18} the minimum value if the slider is moved to total left (optional, default: 18)
* @param {value=28} the maximum value if the slider is moved to total right (optional, default: 28)
* @param {value=.1} step between two values (optional, default: .1)
* @param {text(false,true)=false} display a scale with values along the slider (optional, default='true')
* @param {value=1} scale-integer, the scale-divider for the scale
* @param {item(num)=} an item for the offset temperature (optional, if provided set temperature changes will be written to this item instead of 'item_set')
* @param {text[]=} list of additional widgets / content to display
* @param {value=0} tolerance by which values entered with +/- buttons are allowed to exeed min/max values (optional, default: limiting to min/max)
*
* @author Bonze, Wolfram v. Hülsen
*/
{% macro rtrslider(id, item_actual, item_set, item_comfort, item_night, item_frost, item_state, min, max, step, scale, scale_interval, item_offset, supplements, tolerance) %}
{% import "@widgets/basic.html" as basic %}
/** set displayed decimals to decimals of step parameter */
{% set setformat = lang ('format', 'temp') %}
{% set stepparts = step|default('.1')|split('.') %}
{% set decs = (stepparts[1] >0 ? stepparts[1]|length : 0) %} {% set setformat = setformat|replace(',1f', ','~decs~'f') %}
/** pseudo divs, to get styles **/
/** double slider with texts **/
Soll: {{ basic.print('', item_set, setformat ) }}
/** elements copied from device.rtr **/
{% if item_set %}
{% if tolerance is empty %} {% set tolerance = '0' %} {% endif %}
{% set min = min | default('18') - tolerance %}
{% set max = max | default('28') + tolerance %}
{% endif %}
{% if item_comfort is not empty or item_night is not empty or item_frost is not empty or item_state is not empty or supplements is not empty %}
{% if item_comfort is not empty and (item_comfort == item_night or item_night is empty) and (item_comfort == item_frost or item_frost is empty) %}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['comfort', 'standby'] : [1, 2]), ['user_available.svg', 'user_away.svg'], '', ['icon1', 'icon0']) }}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['night', 'standby'] : [3, 2]), ['scene_night.svg', 'scene_night.svg'], '', ['icon1', 'icon0']) }}
{{ basic.stateswitch('', item_comfort, 'icon', (config_driver == 'linknx' ? ['frost', 'standby'] : [4, 2]), ['weather_frost.svg', 'weather_frost.svg'], '', ['icon1', 'icon0']) }}
{% else %}
{% if item_comfort is not empty %}
{{ basic.stateswitch('', item_comfort, 'icon', '', ['user_away.svg', 'user_available.svg']) }}
{% endif %}
{% if item_night is not empty %}
{{ basic.stateswitch('', item_night, 'icon', '', ['scene_night.svg', 'scene_day.svg']) }}
{% endif %}
{% if item_frost is not empty %}
{{ basic.stateswitch('', item_frost, 'icon', '', ['weather_frost.svg', 'weather_frost.svg']) }}
{% endif %}
{% endif %}
{% if item_state is not empty %}
{{ basic.stateswitch('', item_state, 'icon', '', 'sani_heating.svg') }}
{% endif %}
{% for supplement in supplements %}
{{ supplement|raw }}
{% endfor %}
{% endif %}
{% endmacro %}
/**
* Standard shutter
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the shutter
* @param {item(bool,num)=} an item for the up and down movement (optional, value_top/value_bottom will be sent to item_pos if omitted)
* @param {item(bool,num)=} an item for stopping the movement (optional)
* @param {item(num)} an item for the absolute position of the blinds
* @param {item(bool,num)=} an item for increase and decrease of the blade (optional, for future use)
* @param {item(num)=} an item for the absolute angle of the blade (optional)
* @param {item(num)=} an item for some saved positions (optional)
* @param {value=0} the value for opened (optional, default 0)
* @param {value=255} the value for closed (optional, default 255)
* @param {value=5} step between two values (optional, default 5)
* @param {text(half,full)=} 'half' blade turns from -1 to +1, 'full' blade turns from 0 to +1 (optional, default 'half')
* @param {image=} a background image url (relative to smartVISU directory or absolute); optimal size is 100px x 180px (optional)
* @param {value=0} the value to send for position 1 (optional, default 0)
* @param {value=1} the value to send for position 2 (optional, default 1)
* @param {text=Pos1} the text printed on button for position 1 (optional, default Pos1)
* @param {text=Pos2} the text printed on button for position 2 (optional, default Pos2)
*
* @info inspired by Joerg Gutowski
*/
{% macro shutter(id, txt, item_move, item_stop, item_pos, item_shift, item_angle, item_saved, value_top, value_bottom, step, mode, background, value_pos_1, value_pos_2, text_pos_1, text_pos_2) %}
{% import "@widgets/basic.html" as basic %}
{% endmacro %}
/**
* Displays a simple shutter control assembly in table format
*
* @param {id=} unique id for this widget (optional)
* @param {text=} name of the shutter
* @param {item(bool,num)} a gad/item for long move
* @param {item(bool,num)} a gad/item for stopping movement
* @param {item(num)} a gad/item for the actual position 0=open / 255=closed
* @param {item(bool, num)=} a gad/item to activate a saved position in the actuator (bool) or send a fixed position value (num) (optional)
* @param {type=micro} valid types: 'micro', 'mini', 'midi' (optional, default: micro)
* @param {value=1} a value to send to item_saved in order to trigger a saved position in the actuator (bool) or send a position value (num) (optional, default=1)
*
* @author Michael Stemmer and Wolfram v. Huelsen
*/
{% macro smallshut(id, txt, item_move, item_stop, item_position, item_saved, type, value_saved) %}
{% import "@widgets/basic.html" as basic %}
{% import "@widgets/icon.html" as icon %}
{% set uid = uid(page, id) %}
{% endmacro %}
/**
* Graphical widget for usage of UZSU plugin.
Drag points, add new ones by clicking on background and edit or delete them.
*
* @param {id=} unique id for this widget (optional)
* @param {item(dict)} the item of the UZSU (NOT the item which is switched by UZSU)
* @param {text=UZSU} title of graph (optional, default: UZSU)
* @param {value(0,1)=0} set to '1' in order to allow changes by dragging points (optional, default: 0)
* @param {text(bool,num)=bool} supported types are 'bool' and 'num' (optional, default: bool)
* @param {text[]=} valueParameterList depending on valueType (optional):
bool: ['text on','text off'] or ['text1:value1','text2:value2'],
num: [min, max, step]
* @param {text(false,true)=true} shows a scrollbar below the x-Axis (optional, default: true)
* @param {value=} identifier for the backend: 0=smarthomeNG style, 2= fhem style (not necessary, default is derived from io driver)
*
* @author Stefan Widmer
*/
{% macro uzsugraph(id, item, headline, editable, valueType, valueParameterList, scrollbar, _backend) %}
{% import "@widgets/basic.html" as basic %}
{% endmacro %}
/**
* Widget for usage of UZSU plugin
*
* @param {id=} unique id for this widget (optional)
* @param {item(dict)} the item of the UZSU (NOT the item which is switched by UZSU)
* @param {text=UZSU} headline of popup (optional, default: UZSU)
* @param {image=time_timer_switch} the pic for the 'on' state (optional)
* @param {image=time_timer_switch} the pic for the 'off' state (optional)
* @param {text(bool,num,list,text)=bool} supported types are 'bool', 'num', 'list', 'text' (optional, default: bool)
* @param {text[?]=} valueParameterList depending on valueType (optional):
bool: ['text on','text off'] or ['text1:value1','text2:value2'],
num: [min, max, step],
list: ['value1','value2','value3'] or ['text1:value1','text2:value2','text3:value3'],
text: no value parameter
* @param {color(icon0to5)=icon1} the color for the 'on' state, e.g. '#f00' for red (default 'icon1' of the design)
* @param {color(icon0to5)=icon0} the color for the 'off' state, e.g. '#f00' for red (default 'icon0' of the design)
* @param {type=icon} button sized 'micro', 'mini' or 'midi' or icon (optional, default = 'icon')
* @param {value=} identifier for the backend: 0=smarthomeNG style, 2= fhem style (not necessary, default is derived from io driver)
*
* @author Michael Wuertenberger
*/
{% macro uzsuicon(id, item, headline, pic_on, pic_off, valueType, valueParameterList, color_on, color_off, type, _backend) %}
{% import "@widgets/basic.html" as basic %}
{% if type not in ['micro','mini','midi'] %}
{% set type = 'icon' %}
{% else %}
{% set uitype = 'ui-'~type %}
{% endif %}
{{ basic.icon(pic_off|deficon('time_timer_switch.svg'), color_off) }}{{ basic.icon(pic_on|deficon('time_timer_switch.svg'), color_on|default('icon1')) }}
{% endmacro %}
/**
* UZSU-Timetable widget for usage with the UZSU-Plugin
*
* @param {id=} unique id for this widget (optional)
* @param {item(dict)} the item of the UZSU (NOT the item which is switched by UZSU)
* @param {text=} headline of Table (optional, default: empty)
* @param {value[?]=1} value for 'on' state (optional), if using array form keep in mind to get color array same length, if not last color would be used for missing entries - for correct tool-tip valueparameter list should include all values
* @param {value[?]=0} value for 'off' state (optional), if using array form keep in mind to get color array same length, if not last color would be used for missing entries - for correct tool-tip valueparameter list should include all values
* @param {color[?]=green} the color for the 'on' state, e.g. '#f00' for red (default 'green' of the design)
* @param {color[?]=red} the color for the 'off' state, e.g. '#f00' for red (default 'red' of the design)
* @param {color=lightgrey} the color for the 'off' state for disabled entries, e.g. '#f00' for red (default 'lightgrey' of the design)
* @param {color=grey} the color for the 'off' state for disabled entries, e.g. '#f00' for red (default 'grey' of the design)
* @param {text(false,true)=true} fill the times from ON to OFF with ON-color (default 'true' )
* @param {duration=1h} granularity of the timetable, valid values '5m', '10m','15m','30m','1h' (default '1h' )
* @param {text[?]=solid} style of the cell border, valid values solid,horizontal,hourly, none (default 'solid' )
also valid: combination with granularity as a list: ['5m:solid','10m:hourly','15m:hourly','30m:horizontal','1h:horizontal']
* @param {text(false,true)=true} show the zoom button for different granularity (default 'true' )
* @param {text(false,true)=true} show the switching times in a tooltip (default 'true' )
* @param {text(false,true)=true} show the sunrise/sunset-times as line on the table (default 'true' )
* @param {text(false,true)=true} show the actual time as line on the table (default 'true' )
* @param {value(1,2,3)=1} style of inactive-mode 1=opacity 50% / 2=Text "Inactive". You can combine 1+2=3 (default '1' )
* @param {text(bool,num,list,text)=bool} supported types are 'bool', 'num', 'list', 'text' (optional, default: bool)
* @param {text[]=} depending on valueType (optional):
bool: ['text on','text off'] or ['text1:value1','text2:value2'],
num: [min, max, step],
list: ['value1','value2','value3'] or ['text1:value1','text2:value2','text3:value3'],
text: no value parameter
* @param {value=} identifier for the backend: 0=smarthomeNG style, 2= fhem style (not necessary, default is derived from io driver)
*
* @author Andre Kohler
*/
{% macro uzsutable(id, item, headline, value_on, value_off, color_on, color_off, color_on_disabled, color_off_disabled, fill, granularity, borderstyle, showzoombutton, showtooltip, showsun, showactualtime, inactivestyle, valueType, valueparameterlist, _backend) %}
{% if showzoombutton == 'true' or showzoombutton == 'True' %}
{% endif %}
{% endmacro %}
/**
* Displays window status and a simple shutter control assembly in a popup
*
* @param {id=} unique id for this widget
* @param {text=} title of the window (optional)
* @param {item(bool,num)} item for the up- and down- movement of the shutter
* @param {item(bool,num)} item for stopping the movement of the shutter (optional)
* @param {item(num)=} item for the position of the shutter (optional)
* @param {item(num)=} item to move the shutters to the shade position (optional)
* @param {item(num)=} item to display the window's right wing status (optional)
* @param {item(num)=} item to display the window's left wing status (optional)
* @param {type=micro} type: 'micro', 'mini', 'midi', 'icon' (optional, default: mini)
* @param {value=0} the value for opened (optional, default 0)
* @param {value=255} the value for closed (optional, default 255)
* @param {value=5} step between two values (optional, default 5)
* @param {color[?](icon0to5,!)=icon1} colors for the 'closed' and 'open' state, e.g. ['icon2','icon3'] or '#f00' or ['green,'red']. Prepend a '!' to make the color constant ('!#f00'). (optional, default ['icon0','icon1'])
*
* @author Wolfram v. Hülsen
*/
{% macro window (id, txt, item_move, item_stop, item_pos, item_shade, item_window_r, item_window_l, type, min, max, step, color ) %}
{% import "@widgets/basic.html" as basic %}
{% set uid = uid(page, id) %}
{{ basic.window (uid~'-icon', item_pos, item_window_r, item_window_l, min, max, color) }}