Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	doc/user/source/ideen_kommendes_release.rst
  • Loading branch information
msinn committed May 2, 2022
2 parents 8133e71 + 6514205 commit cc57a0a
Show file tree
Hide file tree
Showing 89 changed files with 2,076 additions and 860 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ cache: pip

jobs:
include:
- python: 3.6
dist: bionic
- python: 3.7
dist: bionic
- python: 3.8
dist: focal
- python: 3.9
dist: focal
- python: 3.10
dist: focal

env:
- REPOSITORY_ORIGIN=smarthome
Expand Down
30 changes: 17 additions & 13 deletions bin/shngversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,28 @@
# Update auf 1.7.2b wg. Einführung von valid_list_ci in den Metadaten
# Update auf 1.7.2c wg. SmartPlugin Erweiterung: Update etc/plugin.yaml section

# Update auf 1.8 wg. Release
# Update auf 1.8a wg. Kennzeichnung des Stands als "nach dem v1.8 Release"
# Update auf 1.8 wg. Release
# Update auf 1.8a wg. Kennzeichnung des Stands als "nach dem v1.8 Release"

# Update auf 1.8.1 wg. Release
# Update auf 1.8.1a wg. Kennzeichnung des Stands als "nach dem v1.8.1 Release"
# Update auf 1.8.1 wg. Release
# Update auf 1.8.1a wg. Kennzeichnung des Stands als "nach dem v1.8.1 Release"

# Update auf 1.8.2 wg. Release
# Update auf 1.8.2a wg. Kennzeichnung des Stands als "nach dem v1.8.2 Release"
# Update auf 1.8.2b wg. Erweiterung des Item Loggings"
# Update auf 1.8.2c wg. Wegen Anpassungen an mem-logging / lib.log
# Update auf 1.8.2d wg. Unterstützung für User-Functions
# Update auf 1.8.2 wg. Release
# Update auf 1.8.2a wg. Kennzeichnung des Stands als "nach dem v1.8.2 Release"
# Update auf 1.8.2b wg. Erweiterung des Item Loggings"
# Update auf 1.8.2c wg. Wegen Anpassungen an mem-logging / lib.log
# Update auf 1.8.2d wg. Unterstützung für User-Functions

# Update auf 1.9.0 wg. Release
# Update auf 1.9a wg. Kennzeichnung des Stands als "nach dem v1.9.0 Release"
# Update auf 1.9.0 wg. Release
# Update auf 1.9a wg. Kennzeichnung des Stands als "nach dem v1.9.0 Release"

# Update auf 1.9.1 wg. Release
# Update auf 1.9.1 wg. Release
# Update auf 1.9.1.1 wg. Kennzeichnung des Stands als "nach dem v1.9.1 Release"
# Update auf 1.9.1.2 wg. zusätzlicher Log Level"

shNG_version = '1.9.1'
# Update auf 1.9.2 wg. Release

shNG_version = '1.9.2'
shNG_branch = 'master'

# ---------------------------------------------------------------------------------
Expand Down
12 changes: 8 additions & 4 deletions bin/smarthome.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
arggroup.add_argument('-i', '--interactive', help='open an interactive shell with tab completion and with verbose logging to the logfile', action='store_true')
arggroup.add_argument('-l', '--logics', help='reload all logics', action='store_true')
arggroup.add_argument('-r', '--restart', help='restart SmartHomeNG', action='store_true')
arggroup.add_argument('-R', '--restart_pid0', help='restart SmartHomeNG w/o PID 0 warning', action='store_true')
arggroup.add_argument('-s', '--stop', help='stop SmartHomeNG', action='store_true')
arggroup.add_argument('-V', '--version', help='show SmartHomeNG version', action='store_true')
arggroup.add_argument('--start', help='start SmartHomeNG and detach from console (default)', default=True, action='store_true')
Expand Down Expand Up @@ -123,23 +124,23 @@
# if we didn't change the working dir (yet), for example...
# command = [python_bin] + sys.argv
command = [python_bin, os.path.join(BASE, 'bin', 'smarthome.py')]

# if started with parameter to stay in foreground, don't fork
if args.foreground or args.interactive or args.debug:
try:
print(f"os.execv: python_bin={python_bin}, sys.argv={sys.argv}")
# function call doesn't return; this process is replaced by the new one
os.execv(python_bin, [python_bin] + sys.argv)
except OSError as e:
print(f'Restart command {command} failed with error {e}')
exit(0)

try:
command.append('-r')
command = command[0] + ' ' + command[1] + ' -R'
p = subprocess.Popen(command, shell=True)
print('Waiting for restart...')
except subprocess.SubprocessError as e:
print("Restart command '{}' failed with error {}".format(command,e))
time.sleep(10)
print()
time.sleep(15)
exit(0)
elif core_reqs == -1:
print("ERROR: Unable to install core requirements")
Expand Down Expand Up @@ -215,6 +216,9 @@ def _reload_logics():
if args.restart:
time.sleep(5)
lib.daemon.kill(PIDFILE, 30)
elif args.restart_pid0:
time.sleep(5)
lib.daemon.kill(PIDFILE, 30, pid0_warning=False)
elif args.interactive:
MODE = 'interactive'
import code
Expand Down
17 changes: 14 additions & 3 deletions dev/sample_mqttplugin/user_doc.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
Sample Plugin <- hier den Namen des Plugins einsetzen
=====================================================
.. index:: Plugins; sample_mqtt
.. index:: sample_mqtt

===========
sample_mqtt
===========

.. image:: webif/static/img/plugin_logo.png
:alt: plugin logo
:width: 300px
:height: 300px
:scale: 50 %
:align: left


Anforderungen
-------------
Expand Down Expand Up @@ -63,4 +75,3 @@ Web Interface
SmartHomeNG liefert eine Reihe Komponenten von Drittherstellern mit, die für die Gestaltung des Webinterfaces genutzt werden können. Erweiterungen dieser Komponenten usw. finden sich im Ordner ``/modules/http/webif/gstatic``.

Wenn das Plugin darüber hinaus noch Komponenten benötigt, werden diese im Ordner ``webif/static`` des Plugins abgelegt.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions dev/sample_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def __init__(self, sh):
# get the parameters for the plugin (as defined in metadata plugin.yaml):
# self.param1 = self.get_parameter_value('param1')

# webif_pagelength should be included in all plugins using a web interface
# It is used to overwrite the default max number of entries per page in the tables
# self.webif_pagelength = self.get_parameter_value('webif_pagelength')

# cycle time in seconds, only needed, if hardware/interface needs to be
# polled for value changes by adding a scheduler entry in the run method of this plugin
# (maybe you want to make it a plugin parameter?)
Expand Down
24 changes: 24 additions & 0 deletions dev/sample_plugin/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ plugin:

parameters:
# Definition of parameters to be configured in etc/plugin.yaml (enter 'parameters: NONE', if section should be empty)

# This parameter should be included if plugin provides a web interface. It lets users configure the standard number of entries per page
webif_pagelength:
type: int
default: 100
valid_list:
- -1
- 0
- 25
- 50
- 100
description:
de: 'Anzahl an Items, die standardmäßig in einer Web Interface Tabelle pro Seite angezeigt werden.
0 = automatisch, -1 = alle'
en: 'Amount of items being listed in a web interface table per page by default.
0 = automatic, -1 = all'
description_long:
de: 'Anzahl an Items, die standardmäßig in einer Web Interface Tabelle pro Seite angezeigt werden.\n
Bei 0 wird die Tabelle automatisch an die Höhe des Browserfensters angepasst.\n
Bei -1 werden alle Tabelleneinträge auf einer Seite angezeigt.'
en: 'Amount of items being listed in a web interface table per page by default.\n
0 adjusts the table height automatically based on the height of the browser windows.\n
-1 shows all table entries on one page.'

param1:
type: str
description:
Expand Down
16 changes: 14 additions & 2 deletions dev/sample_plugin/user_doc.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
Sample Plugin <- hier den Namen des Plugins einsetzen
=====================================================
.. index:: Plugins; sample
.. index:: sample

======
sample
======

.. image:: webif/static/img/plugin_logo.png
:alt: plugin logo
:width: 300px
:height: 300px
:scale: 50 %
:align: left


Anforderungen
-------------
Expand Down
7 changes: 6 additions & 1 deletion dev/sample_plugin/webif/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ def index(self, reload=None):
:return: contents of the template after beeing rendered
"""
tmpl = self.tplenv.get_template('index.html')
# Setting pagelength (max. number of table entries per page) for web interface
try:
pagelength = self.plugin.webif_pagelength
except Exception:
pagelength = 100
# add values to be passed to the Jinja2 template eg: tmpl.render(p=self.plugin, interface=interface, ...)
return tmpl.render(p=self.plugin,
webif_pagelength=pagelength,
items=sorted(self.items.return_items(), key=lambda k: str.lower(k['_path'])),
item_count=0)

Expand Down Expand Up @@ -101,4 +107,3 @@ def get_data_html(self, dataSet=None):
# except Exception as e:
# self.logger.error("get_data_html exception: {}".format(e))
return {}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 55 additions & 14 deletions dev/sample_plugin/webif/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
{% set update_interval = 0 %}

<!--
Additional styles go into this block
Additional styles go into this block. Examples are for datatables
-->
{% block pluginstyles %}
<style>
table th.value {
width: 100px;
}
These are used for highligt effect in web interface when a value changes. If you don't want to overwrite the
default color, you can remove the entries here as the classes are already defined in smarthomeng.css
*/
.shng_effect_highlight {
background-color: #FFFFE0;
}
.shng_effect_standard {
background-color: none;
}
</style>
{% endblock pluginstyles %}

Expand All @@ -27,7 +36,12 @@
myProto = document.getElementById(dataSet);
for (item in objResponse) {
/*
shngInsertText (item+'_value', objResponse[item]['value'], 'maintable');
Parameters for shngInsertText:
0: mandatory, ID of the HTML element, e.g. the table cell
1: mandatory, Value to be written - taken from the objResponse dict
2: optional, If element of parameter 0 is in a (data)table, the ID of the table has to be put here
3: optional, If you want a visual highlight effect when a value changes, provide the duration in seconds.
shngInsertText (item+'_value', objResponse[item]['value'], 'maintable', 5);
*/
}
}
Expand All @@ -46,21 +60,48 @@
Of course you can also overwrite defaults by putting the option declarations in {} below.
*/
$(window).trigger('datatables_defaults');
try
{
$('#maintable').DataTable( {} ); // put options into {} if needed
$('#<table_id>').DataTable( {} ); // delete or change name
}
catch (e)
{
console.log("Datatable JS not loaded, showing standard table without reorder option " + e)
}
try {
/* get pagelength from plugin. Also see hidden span element in headtable block! */
webif_pagelength = parseInt(document.getElementById('webif_pagelength').innerHTML);
if (webif_pagelength == 0) {
resize = true;
webif_pagelength = -1;
}
else {
resize = false;
}
}
catch (e) {
webif_pagelength = 100;
resize = false;
console.log("Using default values for page length " + webif_pagelength + ", pageResize: " + resize);
}
try {
/*
Copy this part for every datatable on your page. Adjust options if necessary.
pageLength and pageResize should be included as they are to adjust it based on the plugin settings
*/
table = $('#maintable').DataTable( {
/* If you want to define your own columnDefs options (e.g. for hiding a column by default), use the concat function shown here.
columnDefs: [{ "targets": [8], "className": "none"}].concat($.fn.dataTable.defaults.columnDefs),
*/
pageLength: webif_pagelength,
pageResize: resize});
}
catch (e) {
console.log("Datatable JS not loaded, showing standard table without reorder option " + e);
}
});
</script>
{% endblock pluginscripts %}


{% block headtable %}
<!--
This span needs to be put somewhere on the page to read the table pagelength from the plugin / users' plugin.yaml
-->
<span id='webif_pagelength' style="display:none">{{ webif_pagelength }}</span>

<table class="table table-striped table-hover">
<tbody>
<tr>
Expand Down Expand Up @@ -122,19 +163,19 @@
-->
{% set tab1title = "<strong>" ~ p.get_shortname() ~ " Items</strong> (" ~ item_count ~ ")" %}
{% block bodytab1 %}
<div class="container-fluid m-2">
<div class="container-fluid m-2 table-resize">
{{ _('Hier kommt der Inhalt des Webinterfaces hin.') }}

<!-- set id accordingly -->
<table id="maintable" class="table table-striped table-hover pluginList display">
<table id="maintable" class="table table-striped table-hover pluginList dataTableAdditional">
<thead>
<tr>
<th>{{ _('Item') }}</th>
<th class="value">{{ _('Wert') }}</th>
</tr>
</thead>
<tbody>
{% for item in p.get_items() %}
{% for item in items %}
{% if p.has_iattr(item.conf, '<plugin_attribute>') %}
<tr>
<td class="py-1" id="{{ item._path }}">{{ item._path }}</td>
Expand Down
Loading

0 comments on commit cc57a0a

Please sign in to comment.