/** * ----------------------------------------------------------------------------- * @package smartVISU * @author Martin Gleiß and others * @copyright 2012 - 2016 * @license GPL [http://www.gnu.de] * ----------------------------------------------------------------------------- */ {% macro _icon(pic, color, id, class) %} {% if (pic matches '#^icons/../.*\.png$#') and not isfile(pic) and isfile(pic|slice(0, 6) ~ 'ws' ~ pic|slice(8,-4) ~ '.svg') %} {% if pic|slice(6, 2) != 'ws' %} {% set color = pic|slice(6, 2) %} {% endif %} {% set pic = pic|slice(0, 6) ~ 'ws' ~ pic|slice(8,-4) ~ '.svg' %} {% endif %} {% if (color == 'icon0') or (color is empty) %} {% elseif color == 'icon1' %} {% else %} {% set presetColors = {'or': '#f9a028', 'gn': '#84c929', 'bl': '#4176a9', 'sw': '#000'} %} {% if presetColors[color] is defined %} {% set color = presetColors[color] %} {% endif %} {% endif %} {% endmacro %} _ /** * A button * * @param unique id for this widget * @param a item * @param text printed on the button (optional) * @param a icon or a inline pic: 'arrow-l', 'arrow-r', 'arrow-u', 'arrow-d', 'delete', 'plus', 'minus', 'check', 'gear', 'refresh', 'forward', 'back', 'grid', 'star', 'alert', 'info', 'home', 'search' (optional) * @param value send if the button is pressed (optional, default 1) * @param type: 'micro', 'mini', 'midi' (optional, default: mini) * @param the color 'icon1' or e. g. '#f00' for red (default 'icon0' of the design) */ {% macro button(id, item, txt, pic, val, type, color) %} {% set suffix = pic|slice(-4, 4) %} {% import _self as basic %} {{ txt|e }} {% elseif suffix != '.svg' and suffix != '.png' and not txt %} data-icon="{{ pic }}" data-iconpos="notext"> {% elseif suffix != '.svg' and suffix != '.png' and txt %} data-icon="{{ pic }}" data-iconpos="top">{{ txt|e }} {% elseif type == 'midi' and txt %} >{{ basic._icon(pic|deficon, color) }}
{{ txt|e }}
{% else %} data-iconpos="center">{{ basic._icon(pic|deficon, color) }} {% endif %}
{% endmacro %} /** * Displays a checkbox * * @param unique id for this widget * @param a item * @param text printed on the checkbox */ {% macro checkbox(id, item, txt) %} {% endmacro %} /** * Displays a colordisc-rgb-selector * * @param unique id for this widget * @param a item for the r - value (0-255) * @param a item for the g - value (0-255) * @param a item for the b - value (0-255) * @param the minimum value if the light is off (optional, for future use) * @param the maximum value if the light is full on (optional, default 255) * @param the granularity of the rings (optional, default 8) * @param the number of colored segments (optional, default 10) * * @info inspired by Marcus Popp */ {% macro colordisc(id, item_r, item_g, item_b, min, max, step, colors) %} {% set uid = uid(page, id) %}
{% endmacro %} /** * A switch with to states displayed as a button * * @param unique id for this widget * @param a item * @param the pic for the 'on' state (optional) * @param the pic for the 'off' state (optional) * @param value send for the 'on' state (optional, default 1) * @param value send for the 'off' state (optional, default 0) * @param type: 'micro', 'mini', 'midi' (optional, default: mini) * @param the color_on: e.g. '#f00' for red (default 'icon1' of the design) * @param the color_off: e.g. '#f00' for red (default 'icon0' of the design) */ {% macro dual(id, item, pic_on, pic_off, val_on, val_off, type, color_on, color_off) %} {% set uid = uid(page, id) %} {% import _self as basic %} {{ basic._icon(pic_off|deficon('control_on_off.svg'), color_off, uid ~ '-off') }} {{ basic._icon(pic_on|deficon('control_on_off.svg'), color_on|default('icon1'), uid ~ '-on', 'hide') }} {% endmacro %} /** * A multi states button to extend the basic.dual behavior * * @param unique id for this widget * @param a item for command * @param array of values * @param array of icons path and name * @param type: 'micro', 'mini', 'midi' (optional, default: mini) * * @author Pierre-Yves KERVIEL */ {% macro multistate(id, item, val, img, type) %} {% endmacro %} /** * Displays a flip-switch * * @param unique id for this widget * @param a item * @param text for the 'on' state (optional, default 'On') * @param text for the 'off' state (optional, default 'Off') */ {% macro flip(id, item, txt_on, txt_off) %} {% endmacro %} /** * Displays a value as float * * @param unique id for this widget * @param a item * @param a unit, tries to get the format for that unit from the language-file (optional) * @param the parent html-tag for the value (optional, default 'span') */ {% macro float(id, item, unit, tag) %} <{{ tag|default('span') }} id="{{ uid(page, id) }}" data-widget="basic.float" data-item="{{ item }}" data-unit="{{ unit }}">-.- {{ unit }} {% endmacro %} /** * calculate values and display * * @param unique id for this widget * @param one or more item(s). More items in array-form: [ item1 , item2 ] * @param unit for displaying, if that unit is found in the language-file that formating is been used (optional) * @param formula to use: SUM(VAR), AVG(VAR), SUB(VAR), VAR1 + VAR2, ... "VAR" is replaced with all item(s), "VAR1", "VAR2"... is replaced with the appropriate item of the list (optional, default: SUM(VAR)) * * @see misc/fundamentals#Array-Form * @info inspired by Raik Alber */ {% macro formula(id, item, unit, formula) %} --- {% endmacro %} /** * Used to glue to widgets together. Only needed if you don't use 'Realtime'! * If you click the 'from'-widget, the 'to'-widget will be reloaded and updated after a delay. * * @param id from the element that is been clicked * @param id from the element that contain a item that might be changed */ {% macro glue(id_from, id_to) %} {% endmacro %} /** * Displays a rgb-selector * * @param unique id for this widget * @param a item for the r - value (0-255) * @param a item for the g - value (0-255) * @param a item for the b - value (0-255) * @param the minimum value if the light is off (optional, for future use) * @param the maximum value if the light is full on (optional, default 255) * @param step (for future use) * @param the number of colors (default 10) */ {% macro rgb(id, item_r, item_g, item_b, min, max, step, colors) %} {% set uid = uid(page, id) %}
{% endmacro %} /** * A switch, build of a series of icons. The series may be a iconseries (NAME_00.svg, NAME_10.svg, NAME_20.svg...) or may be a dynamic svg-icon (icon.NAME) * * @param unique id for this widget * @param a item for the switch (optional) * @param a item for the value * @param the iconseries or dynamic icon for the 'on' state * @param the icon for the 'off' state (optional) * @param the minimum value if it is off (optional, for future use) * @param the maximum value if it is on (optional, default 255) * * @see design/design_icons#Dynamic Icons and Static Icons */ {% macro shifter(id, item_switch, item_value, pic_on, pic_off, min, max) %} {% import "icon.html" as icon %} {% if pic_on|slice(0, 5) == 'icon.' %} {{ attribute(icon, pic_on|slice(5), [id, item_switch, item_value, min, max]) }} {% else %} {% endif %} {% endmacro %} /** * Displays a shutter-control * * @param unique id for this widget * @param a item for the actual position of the blinds * @param a item for the actual angle of the blinds (optional, readonly) * @param the minimum value for close (optional, default 0) * @param the maximum value for open (optional, default 255) * @param step between two values (optional, default 5) * @param the mode: 'half' blade turns from -1 to +1, or 'full' blade turns from 0 to +1 (optional, default 'half') * * @info inspired by Jörg Gutowski */ {% macro shutter(id, item_pos, item_angle, min, max, step, mode) %} {% set uid = uid(page, id) %}
{% if item_angle != '' %}
 
{% endif %}
{% for i in 1..12 %}
{% endfor %}
{% endmacro %} /** * Displays a slider-control * * @param unique id for this widget * @param a item * @param the minimum value if the slider is moved to total left (optional, default 0) * @param the maximum value if the slider is moved to total right (optional, default 255) * @param step between two values (optional, default 5) * @param the orientation ('none', 'vertical', 'bottomup', 'semicircle') */ {% macro slider(id, item, min, max, step, mode) %} {% endmacro %} /** * A switch, build of two pics * * @param unique id for this widget * @param a item * @param the pic for the 'on' state (optional) * @param the pic for the 'off' state (optional) * @param value send for the 'on' state (optional, default 1) * @param value send for the 'off' state (optional, default 0) * @param the color_on 'icon1' or e. g. '#f00' for red (default 'icon1' of the design) * @param the color_off e. g. '#f00' for red (default 'icon0' of the design) */ {% macro switch(id, item, pic_on, pic_off, val_on, val_off, color_on, color_off) %} {% set uid = uid(page, id) %} {% import _self as basic %} {% if not pic_on or pic_on|slice(-4, 4) == '.svg' %} {{ basic._icon(pic_off|deficon('control_on_off.svg'), color_off, uid ~ '-off') }} {{ basic._icon(pic_on|deficon('control_on_off.svg'), color_on|default('icon1'), uid ~ '-on', 'hide') }} {% else %} {% endif %} {% endmacro %} /** * A symbol, with no writing to knx, only displayed when the value of item is equal to val. Symbols may be used in menus. * If more than one item is given, they will be combined with mode ('or' / 'and'). * * @param unique id for this widget * @param one or more item(s). More items in array form: [ item1 , item2 ] * @param the text, printed when item has value val (optional) * @param the pic, shown when item has value val * @param value (default 1) * @param the mode, 'or', 'and' (default 'or') * @param the color 'icon1' or e. g. '#f00' for red (default 'icon0' of the design) */ {% macro symbol(id, items, txt, pic, val, mode, color) %} {% import _self as basic %} {{ basic._icon(pic|deficon('control_on_off.svg'), color) }} {{ txt }} {% endmacro %} /** * Displays a (partly) filled tank * * @param unique id for this widget * @param a item for the actual position of filled tank * @param the minimum value for empty (optional, default 0, for future use) * @param the maximum value for full (optional, default 255) * @param step between two values (optional, default 5, for future use) * @param the mode: 'none', 'cylinder', 'water', 'pallets' (optional, default 'none') * @param the color of the filling e. g. '#f00' for red (optional, default grey) */ {% macro tank(id, item_pos, min, max, step, mode, color) %}
 
{% endmacro %} /** * A dymanic text depending on a item * * @param unique id for this widget * @param a item * @param the text for the 'on' state (optional) * @param the text for the 'off' state (optional) * @param value send for the 'on' state (optional, default 1) * @param value send for the 'off' state (optional, default 0) * * @info inspired by Marco Fleischer */ {% macro text(id, item, txt_on, txt_off, val_on, val_off) %} {% endmacro %} /** * A widget to trigger a logic (e. g. in SmartHome.py) * * @param unique id for this widget * @param the name of the trigger (logic) * @param text printed on the button (optional) * @param a icon or a inline pic: 'arrow-l', 'arrow-r', 'arrow-u', 'arrow-d', 'delete', 'plus', 'minus', 'check', 'gear', 'refresh', 'forward', 'back', 'grid', 'star', 'alert', 'info', 'home', 'search' (optional) * @param value send if the button is pressed (optional, default 1) * @param type: 'micro', 'mini', 'midi' (optional, default: mini) */ {% macro trigger(id, name, txt, pic, val, type) %} {% set suffix = pic|slice(-4, 4) %} {{ txt|e }} {% elseif suffix != '.svg' and suffix != '.png' and not txt %} data-icon="{{ pic }}" data-iconpos="notext"> {% elseif suffix != '.svg' and suffix != '.png' and txt %} data-icon="{{ pic }}" data-iconpos="top">{{ txt|e }} {% elseif type == 'midi' and txt %} >
{{ txt|e }}
{% else %} data-iconpos="center"> {% endif %}
{% endmacro %} /** * display a value * * @param unique id for this widget * @param a item * @param a unit (optional) * @param the parent html-tag for the value (optional, default 'span') */ {% macro value(id, item, unit, tag) %} <{{ tag|default('span') }} id="{{ uid(page, id) }}" data-widget="basic.value" data-item="{{ item }}" data-unit="{{ unit }}">--- {{ unit }} {% endmacro %}