smartvisu - Widget Assistant

Table of Content

  1. How it works
  2. Hot-Keys
  3. Known issues
  4. Logics to create masteritem.json from shNG
  5. Script to create masteritem.json for FHEM

How it works

This tool should help you to create widgets for your smartvisu-Web-Interface. It will assist you with autocompletes for widgets, items, icons and colors. The autocomplete mode can be selected.

Just start entering a widget name in the editor or press CTRL-Space to open the widget autocomplete. After you have selected a widget (like basic.symbol...) and enter the opening bracket you will get a tooltip for this widget. The actual parameter is highlighted in red and all the available details will be shown in the tooltip-window. For icons and colors you will see a preview in the tooltip-window. Autocompletes will insert the parameters with quotes. If no autocomplete is present or you do not use it make sure to enter the quotes manually. After completing the wiget you can render it in a new window. The widget in the rendered window is fully working. If there is a syntax error in the created widget, you will get a TWIG-Error. The final widget including the brackets "{{" + "}}" will be stored on rendering to the clipboard. You can paste the widget-code directly to your html-file.

You can render multiple widgets by separating them by a <br>-TAG

Example :

plot.period('', ['licht.og.terrasse.screens.warm.dimmen', 'licht.og.terrasse.screens.kalt.dimmen', 'licht.og.terrasse.decke.dimmen'], 'max', '1w', 'now', '0', '110', '1000', ['Screens warm', 'Screens kalt', 'Decke'], ['#daa', '#aad', '#955'], ['stair', 'stair', 'stair'], ['Uhrzeit', 'Helligkeit'], 'advanced', '', '', '', '', '', { yAxis: [ { tickInterval: 40 } ], legend: {align: 'right', verticalAlign: 'top', y: 50, layout: 'vertical'}, chart: { marginRight: 110} })
<br>
basic.stateswitch('','OG.Bad.Licht','midi','','light_ceiling_light','Licht Bad','','','','','')
<br>
quad.dimmer('Lueftungsstufe1', 'Lüftungsstufe', 'Haustechnik.Lueftung', 'Haustechnik.Lueftung.stufe', 0, 100, 5, icon.ventilation(), icon.ventilation('','','Haustechnik.Lueftung.stufe'), '', '', '', 0, 100, '', '', '', '',   '', '', '', '', '', '', '', '', '', ['switch', 'value_popup']) 

Hot-Keys

Shortcut function
STRG+1 only Items in autocomplete-Dict
STRG+2 only Widgets in autocomplete-Dict
STRG+3 only Icons in autocomplete-Dict
STRG+4 all in autocomplete-Dict
STRG+5 only Colors in autocomplete-Dict
STRG+6 autocomplete-Dict is OFF
STRG+9 switch ON/OFF Wildcard search in autocomplete dict
STRG+Space opens the actual autocomplete-Dict
STRG+F find value in widgets
STRG+SHIFT+R replace value in widgets - use ENTER to go to replacement-value

Known Issues

It is possible to render the new widget into the iframe on the actual page. But this will destroy the loaded index.php. You will get in trouble when you want to use the navigation of smartvisu again. No solution right now. You can reload the page with bypassing the cache, then everthing is working again. (STRG+F5 / CTRL + Shift + R)

Logic to create masteritem.json from shNG

Only needed for smarthomeNG <= v1.7.2. As of v1.8 the smartvisu plugin writes the file as default.

#!/usr/bin/env python3
# create_master_item.py
import json
from lib.item import Items
items = Items.get_instance()
items_sorted = sorted(items.return_items(), key=lambda k: str.lower(k['_path']), reverse=False)
item_list = []
for item in items_sorted:
    item_list.append(item._path + "|" + item._type )
f = open("/var/www/html/smartvisu/pages/YOUR_PAGES/masteritem.json", "w")
f.write(json.dumps(item_list))
f.close()

Script to create masteritem.json for FHEM

A script can be found in the fronthem / smartVISU Forum
https://forum.fhem.de/index.php/topic,118508.msg1135044.html#msg1135044