/**
* -----------------------------------------------------------------------------
* @package smartVISU
* @author Martin Gleiß, changes for SV2.9 by Wolfram v. Hülsen
* @copyright 2012
* @license GPL [http://www.gnu.de]
* -----------------------------------------------------------------------------
*/
/**
* Displays a color selector
*
* @param {id=} unique id for this widget (optional)
* @param {item[?](num)} an item for the red value in RGB model or hue in HSL and HSV model, or single item containing list of all color values
* @param {item(num)=} an item for the green value in RGB model or saturation in HSL and HSV model
(to let blank if first item contains list of all values)
* @param {item(num)=} an item for the blue value in RGB model or lightness in HSL model / brightness in HSB model
(to let blank if first item contains list of all values)
* @param {value[?]=0} minimum value if the light is off; single value or list of values for each component (optional, default 0)
* @param {value[?]=255} maximum value if the light is full on; single value or list of values for each component (optional, default 255 for rgb, [360,100,100] for hsl & hsv)
* @param {value=7} number of shades per color (optional, default 7)
* @param {value=10} number of colored segments (optional, default 10)
* @param {text(disc,rect,slider)=disc} 'disc' for circular, 'rect' for rectangular view, 'slider' for HSV sliders (optional, default: disc)
* @param {text(rgb,hsl,hsv)=rgb} possible values: 'rgb', 'hsl' and 'hsv' (optional, default: rgb)
* @param {text=} popup-info of the rgb-selector (optional)
* @param {percent} icon position from left side
* @param {percent} icon position from top side
* @param {type=mini} type: 'micro', 'mini', 'midi' (optional, default: mini)
* @param {value=0} hide on mobile displays (optional value 1)
*
* @author Martin Gleiß and Stefan Widmer
* @info inspired by Marcus Popp
*/
{% macro color(id, item_r_h, item_g_s, item_b_l_v, min, max, steps, colors, style, colormodel, info, left, top, type, hide ) %}
{% set style = style|default('disc') %}
{% endif %}
{% endmacro %}
/**
* Period: A simple popup-widget for plotting charts
* to use together with the print-Widget
*
* @param {id=} unique id for this widget (optional)
* @param {text=} title of the chart (optional)
* @param {item[?](bool,num)} series of item(s); multiple items in array form: [ item1 , item2 ]
* @param {text[?](avg,sum,min,max,minmax,minmaxavg,raw,on)=} the aggregation mode (optional, default 'avg')
May be a single mode or an array with separate mode per item.
Available modes depend on backend, common ones are 'avg', 'sum', 'min', 'max', 'minmax', 'minmaxavg', 'on', 'raw'. See backend's documentation for further information.
* @param {duration=1h} the minimum time (x-axis): '1h', '2h'... (duration-format)
* @param {duration=now} the maximum time (x-axis): '', '1h', '2h'... (duration-format, default: now)
* @param {text[?]=} the minimum for each y-axis; multiples in array form: [ min_y-axis1, min_y-axis2, ...] (optional)
If the axis type is boolean the passed value will be the label of the low state (e.g. 'Off')
* @param {text[?]=} the maximum for each y-axis; multiples in array form: [ max_y-axis1, max_y-axis2, ...] (optional)
If the axis type is boolean the passed value will be the label of the high state (e.g. 'On')
* @param {value=100} the number of datapoints in the series (optional, default 100)
May be a single value or an array of separate counts per item.
* @param {text[?]=} label for each serie; multiples in array form (optional)
* @param {color[?]=} color for each serie; multiples in array form (optional, default: suitable for design)
* @param {text[?](line,stair,spline,area,areastair,areaspline,column)=line} type of each serie: 'line', 'stair', 'spline', 'area', 'areastair', 'areaspline', 'column'; multiples in array form (optional, default 'line')
* @param {text[?]=} title for the x-axis and y-axes in array form: [title_x-axis, title_y-axis1, title_y-axis2, ...] (optional)
* @param {duration(advanced)=} minimal time range while zooming or 'advanced' (optional, duration-format)
By passing 'advanced' a seaparate range selector is shown and data grouping for large amount of data is enabled
* @param {value[]=} assignment of the series to the y-axes; multiples in array form (optional)
* @param {value[]=} y-axes setup for left '0' and right '1' hand in array form (optional)
* @param {color[?]=} y-axes color; multiples in array form (optional)
* @param {text[?](linear,logarithmic,boolean)=linear} y-axes type, one of 'linear', 'logarithmic' or 'boolean'; multiples in array form (optional, default 'linear')
* @param {format[?]=} either a unit of the language file, an individual format string (PHP sprintf like) or a simple string as suffix. (optional)
* @param {unspecified[?]=} object with additional options for Highcharts, see https://api.highcharts.com/ (optional)
*
* @see misc/fundamentals#Array-Form
* @see misc/fundamentals#Duration-Format
*/
{% macro period(id, txt, item, mode, tmin, tmax, ymin, ymax, count, label, color, exposure, axis, zoom, assign, opposite, ycolor, ytype, unit, chartoptions) %}
{% set tmax = (tmax|default('now')|lower=='0h' or tmax==0 or tmax is empty) ? 'now' : tmax %}
{% set tmin = tmin|default('1h') %}
{% set mode = (mode is iterable ? mode : [mode|default('avg')]) %}
{% set count = (count is iterable ? count : [count|default(100)]) %}
{% set item = (item is iterable ? item : [item]) %}
{% set seriesitems = [] %}
{% for itemi in item %}
{% if mode|length < loop.index %}
{% set mode = mode|merge([mode|last]) %}
{% endif %}
{% set modei = mode[loop.index0] %}
{% if count|length < loop.index %}
{% set count = count|merge([count|last]) %}
{% endif %}
{% set counti = count[loop.index0] %}
{% if modei == 'minmax' %}
{% set seriesitems = seriesitems|merge([ implode(itemi, ['min', tmin, tmax, counti]), implode(itemi, ['max', tmin, tmax, counti]) ]) %}
{% elseif modei == 'minmaxavg' %}
{% set seriesitems = seriesitems|merge([ implode(itemi, ['min', tmin, tmax, counti]), implode(itemi, ['max', tmin, tmax, counti]), implode(itemi, ['avg', tmin, tmax, counti]) ]) %}
{% else %}
{% set seriesitems = seriesitems|merge([implode(itemi, [modei, tmin, tmax, counti])]) %}
{% endif %}
{% endfor %}
Schließen
{% if txt %}
{{ txt }}
{% endif %}
{% endmacro %}
/**
* prints value or text (optionally calculated and/or formatted) and provides link to a popup
*
* @param {id=} unique id for this widget (optional)
* @param {item[?]} one or more item(s). Multiple items in array-form: [item1, item2]
* @param {format=} either a unit of the language file, an individual format string (PHP sprintf like) or a simple string as suffix.
Use 'text' to display result as unformatted string, 'html' to render it as unescaped html or 'script' to just execute as JavaScript w/o displaying anything.
* @param {formula=VAR} any valid JavaScript expression with following variables and aggregate functions (optional, default: VAR)
- VAR1, VAR2, ... represent the corresponding item's value, VAR is an array of all item values
- SUM(VAR), AVG(VAR), SUB(VAR), MIN(VAR) and MAX(VAR) aggregate the values
* @param {value[]=} array of upper thresholds; the color according to greatest reached threshold is applied (optional)
* @param {color[?](icon0,icon1,hidden,blank)=} array of colors; 'icon1' or e. g. '#f00' for red (optional)
additionally you can use 'hidden' to not diplay at all or 'blank' to make it invisible but preserve the space that would be used.
the first one is the base color for values below first threshold, so pass one color more than thresholds.
* @param {text=} popup-info of the float value (optional)
* @param {percent} icon position from left side
* @param {percent} icon position from top side
* @param {text} unique id for the popup
* @param {value=0} hide on mobile displays (optional value 1)
*
* @see misc/fundamentals#Array-Form
*
* @author Stefan Widmer
* @info inspired by Martin Gleiß and Raik Alber
*/
{% macro print(id, item, format, formula, threshold, color, info, left, top, id_popup, hide) %}
{% import _self as ovbasic %}
{% import "@widgets/basic.html" as basic %}
{% set color = color|default('icon0') %}
-.-
{% endmacro %}
/**
* A versatile button/switch
* (supersedes .button, .dual, .hiddenswitch, .multistate and .switch)
*
* @param {id=} unique id for this widget (optional)
* @param {item(bool,num,list,scene)} an item
* @param {type=mini} valid types: 'micro', 'mini', 'midi', 'icon', 'text' (optional, default: mini)
* @param {text[?]=[0,1]} array of values (optional, default [0,1])
If the item has a value that is not part of the list, the state (icon, text, color) of the last value in the list will be shown.
* @param {image[?]=control_on_off} array of icons (optional, default just if text is empty: control_on_off.svg)
dynamic icons can be used, e.g. icon.light('', '', value_item); please note: these must not be wrapped by apostrophs (')
* @param {text[?]=} array of texts (optional)
* @param {color[?](icon0,icon1,hidden,blank)=} array of colors; 'icon1' or e. g. '#f00' for red (optional, default: icon0)
additionally you can use 'hidden' to not diplay at all or 'blank' to make it invisible but preserve the space that would be used.
* @param {color(icon0,icon1,blink)=} activity indicator which is active until response (or a timeout of 3 seconds is reached); pass either a color, 'icon1' or 'blink' (optional)
* @param {item(bool,num,list,scene)=} an item to which a value on longpress is sent (optional)
* @param {text=} the value to send on longpress (optional)
If this starts with a + or - sign the value is treated as offset to current stateswitch value.
* @param {text=} the value to send on releasing after a longpress (optional)
* @param {text=} popup-info of the button (optional)
* @param {percent} icon position from left side
* @param {percent} icon position from top side
*
* @see design/design_icons#Icons
*
* @author Stefan Widmer
* @info Based on work of Martin GLEISS and Pierre-Yves KERVIEL
*/
{% macro stateswitch(id, item, type, value, icon, text, color, indicator, item_longpress, value_longpress, value_longrelease, info, left, top) %}
{% import _self as ovbasic %}
{% import "@widgets/basic.html" as basic%}
{% set value = (value|default([0,1]) is iterable ? value|default([0,1]) : [value]) %}
{% set color = color|default(['icon0','icon1']) %}
{% set iconstyles = ['icon0', 'icon1', 'icon2', 'icon3', 'icon4', 'icon5'] %}
/** Work around for bug in jQuery Mobile, see https://knx-user-forum.de/forum/supportforen/smartvisu/31967-neues-widget-nur-aktive-lampen-anzeigen-ausschalten-ermöglichen?p=1145001#post1145001 */
{% for val in value %}
{% set pic = icon is iterable ? icon[loop.index0] : icon %}
{% if type != 'text' and text is empty %}{% set pic = pic|deficon('control_on_off.svg') %}{% endif %}
{% set col = (color is iterable ? color[loop.index0] : color)|default('icon0') %}
{% set txt = (text is iterable ? text[loop.index0] : text)|default('') %}
{%- if not pic is empty -%}{{ basic.icon(pic, col) }}{%- endif -%}
{{- txt|e -}}
{% endfor %}
/** placeholder for last moved control */
{% endmacro %}
/**
* An icon or text, with no writing to backend, only displayed when the value of item is equal to defined value. Symbols may be used in menus.
* If more than one item is given, they will be combined with formula.
*
* @param {id=} unique id for this widget (optional)
* @param {percent} icon position from left side
* @param {percent} icon position from top side
* @param {item[?](bool,num,list,scene)=} zero, one or more item(s). More items in array form: [item1, item2] (optional)
* @param {text[?]=} the text, printed when item has value val (optional)
* @param {image[?]=control_on_off} the icon shown when item has value val (optional, default 'control_on_off' if text is empty)
dynamic icons can be used, e.g. icon.light('', '', value_item); please note: these must not be wrapped by apostrophs (')
* @param {text[?]=1} comparative value(s) (default 1)
* @param {formula=or} 'or', 'and' or any JavaScript expression with following variables, result will be compared to comparative value above. Additionally you can use 'min' and 'max' to test if any of the defined items has a value >= or <= comparative value (default 'or')
VAR1, VAR2, ... represent the corresponding item's value, VAR is an array of all item values
If the formula starts with a greater than symbol '>' the value will be treated as threshold. The symbol (text, icon and color) according to greatest reached threshold will be shown. The first symbol is the base for values below first threshold, so pass one symbol more than values.
If '>' is not used, symbols will only be shown if the item value matches exactly one of the given value parameters
* @param {color[?](icon0,icon1)=icon0} the color 'icon1' or e. g. '#f00' for red (default 'icon0' of the design)
this only applies to text, if no icon is set (for backward compatibility)
* @param {text=} URL to use as link (optional)
* @param {text=} used in combination with href as data-rel attribute {e.g. to open a popup} (optional)
* @param {type=icon} icon type / size. valid types: 'micro','mini','midi','icon' (optional, default = 'icon')
*
* @see design/design_icons#Icons
*
* @author Martin Gleiß and Stefan Widmer
*/
{% macro symbol(id, left, top, items, text, icon, value, formula, color, href, rel, type) %}
{% import "@widgets/basic.html" as basic %}
{% if type not in ['micro','mini','midi'] %}{% set type = '' %}{% endif %}
{% set value = (value|default([1]) is iterable ? value|default([1]) : [value]) %}
{% set value = text|length > value|length or icon|length > value|length or color|length > value|length ? value|merge(['']) : value %} /** add an empty value if more icons/texts/colors as values are passed (used for threshold i.a.) */
{% set iconstyles = ['icon0', 'icon1', 'icon2', 'icon3', 'icon4', 'icon5'] %}
{% set color = color|default('icon0') %}
{% if rel == 'popup' %}{% set href = '#'~ uid(page, href) %} {% endif %}
<{% if href is empty %}span{% else %}a href="{{ href }}"{% if rel is not empty %} data-rel="popup"{% endif %}{% endif %}{% if not id is empty %} id="{{ uid(page, id) }}"{% endif %} data-widget="basic.symbol"
{% if not items is empty %}data-item="{{ implode(items) }}" style="display: none;" {% endif %}
data-val="{{ implode(value) }}" data-mode="{{ formula|default('or') }}" class="symbol">
{%- for val in value -%}
{%- set pic = icon is iterable ? icon[loop.index0] : icon -%}
{%- if text is empty %}{% set pic = pic|deficon('control_on_off.svg') %}{% endif -%}
{%- set col = (color is iterable ? color[loop.index0] : color)|default('icon0') -%}
{%- set txt = (text is iterable ? text[loop.index0] : text)|default('') -%}
{%- if pic %}{{ basic.icon(pic, col,'',type) }}{% endif -%}
{{- txt|raw -}}
{%- endfor -%}
{% if href is empty %}span{% else %}a{% endif %}>
{% endmacro %}
/**
* Displays window status and a simple shutter control assembly
*
* @param {id=} unique id for this widget
* @param {text=} title of the window (optional)
* @param {percent} icon position from left side
* @param {percent} icon position from top side
* @param {item(bool,num)} a gad/item for the up- and down- movement
* @param {item(bool,num)} a gad/item for stopping the movement (optional)
* @param {item(num)=} a gad/item for the position of the shutters
* @param {item(num)=} a gad/item to move the shutters to the shade position (optional)
* @param {item(num)=} a gad/item to display the window's right wing status (optional)
* @param {item(num)=} a gad/item to display the window's left wing status (optional)
* @param {type=micro} type: 'micro', 'mini', 'midi', 'icon' (optional, default: micro)
* @param {value=0} hide on mobile displays (optional value 1)
*/
{% macro win_shut (id, txt, left, top, gad_move, gad_stop, gad_pos, gad_shade, gad_window_r, gad_window_l, type, hide) %}
{% import "@widgets/basic.html" as basic %}
{% set uid = uid(page, id) %}
{% set min = 0 %}
{% set max = 100 %}
{{ basic.window(uid~'-icon', gad_pos, gad_window_r, gad_window_l, min, max, color) }}
{% endmacro %}
/**
*---------------------------------------------------------------------------------------------------
* deprecated. Change at a later date!
*---------------------------------------------------------------------------------------------------
*/
/**
* Element: Positioning an object / widget
*
* @param unique id for this widget
* @param title of the element (optional)
* @param icon position from left side
* @param icon position from top side
* @param a content
* @param width (optional)
* @param height (optional)
* @param hide on mobile displays (optional value 1)
*/
{% macro e (id, info, left, top, content, width, height, hide) %}
{{ content }}
{% endmacro %}