Skip to content

Commit

Permalink
Fixes for v1.4.2: Backend, cli, comfoair, enigma2, lirc, rcswitch, uz…
Browse files Browse the repository at this point in the history
…su; MQTT: Metadata documentation enhancements
  • Loading branch information
msinn committed Jan 1, 2018
1 parent d3754bc commit 0b2fa6a
Show file tree
Hide file tree
Showing 19 changed files with 480 additions and 55 deletions.
10 changes: 10 additions & 0 deletions backend/BackendItems.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
class BackendItems:


def __init__(self):

self.logger.debug("BackendItems __init__ {}".format(''))


# -----------------------------------------------------------------------------------
# ITEMS
# -----------------------------------------------------------------------------------
Expand Down Expand Up @@ -274,6 +279,10 @@ def item_detail_json_html(self, item_path):
if changed_by[-5:] == ':None':
changed_by = changed_by[:-5]

updated_by = item.updated_by()
if updated_by[-5:] == ':None':
updated_by = updated_by[:-5]

if item.prev_age() < 0:
prev_age = ''
else:
Expand Down Expand Up @@ -324,6 +333,7 @@ def item_detail_json_html(self, item_path):
'last_update': str(item.last_update()),
'last_change': str(item.last_change()),
'changed_by': changed_by,
'updated_by': updated_by,
'previous_value': prev_value,
'previous_age': prev_age,
'previous_update_age': prev_update_age,
Expand Down
47 changes: 43 additions & 4 deletions backend/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,53 @@ plugin:
description: # Alternative: description in multiple languages
de: 'Web Interface zur Anzeige von Informationen zum System und SmartHomeNG Backend-Daten'
en: 'webinterface for displaying system information and SmartHomeNG backend data'

description_long: # Alternative: long description in multiple languages
de: 'Dieses Plugin liefert Informationen über die aktuell laufende SmartHomeNG Installation. Bisher dient es vorwiegend als Support Tool um Anwendern zu helfen, deren Installation nicht richtig läuft.\n
\n
Einige Highlights:\n
\n
- eine Liste der installierten Python Module wird angezeigt und die Versionen werden gegenüber den Requirements und den verfügbaren Versions von PyPI abgeglichen\n
- eine Liste der Items und ihrer Attribute wird angezeigt. Für diverse Item Typen ist der Wert änderbar\n
- eine Liste der Logiken mit nächster Ausführungszeit wird angezeit\n
- Logiken können aktiviert/deaktiviert oder getriggert werden\n
- Logiken können erstellt und editiert werden\n
- eine Liste der aktuellen Scheduler und ihr nächster Ausführungszeitpunkt wird angezeigt\n
- Ein direktes Download der Sqlite Datenbank (nutzt das sqlite Plugins) und der SmartHomeNG Log-Dateien ist möglich\n
- Einige Informationen über häufig genutzte Daemons wie knxd bzw. eibd werden angezeigt\n
- Unterstützt Basic Authentication bei Web-Browser Zugriff\n
- Unterstützt mehrere Sprachen\n
\n
Es gibt bisher nur eine Basic Absicherung gegen nicht-authorisierten Zugriff oder Nutzung des Plugins. Deshalb ist Vorsicht geboten, wenn das Plugin im Netzwerk (evtl. sogar über WAN) zugreifbar ist.\n
\n
Der Aufruf des Backend-Webservers erfolgt standardmäßig durch: http://<ip of your SmartHomeNG server>:8383
'

en: 'This plugin delivers information about the current SmartHomeNG installation. Right now it serves as a support tool for helping other users with an installation that does not run properly.\n
\n
Some highlights:\n
\n
- a list of installed python modules is shown versus the available versions from PyPI\n
- a list of items and their attributes is shown\n
- a list of logics and their next execution time\n
- a list of current schedulers and their next execution time\n
- direct download of sqlite database (if plugin is used) and smarthome.log\n
- some information about frequently used daemons like knxd/eibd is included\n
- supports basic authentication\n
- multi-language support\n
\n
There is however only basic protection against unauthorized access or use of the plugin so be careful when enabling it with your network.\n
\n
Call the backend-webserver: http://<ip of your SmartHomeNG server>:8383
'
maintainer: psilo909, msinn, bmxp
tester: Sandman60
# keywords: iot xyz
# documentation: https://github.com/smarthomeNG/plugins/blob/develop/mqtt/README.md # url of documentation (wiki) page
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/959964-support-thread-für-das-backend-plugin

version: 1.4.9 # Plugin version
sh_minversion: 1.4.1 # minimum shNG version to use this plugin
sh_minversion: 1.4a # minimum shNG version to use this plugin
# sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest)
multi_instance: False # plugin supports multi instance
classname: BackendServer # class containing the plugin
Expand All @@ -29,10 +68,10 @@ parameters:

developer_mode:
type: bool
default: no
default: False
description:
de: 'Entwickler Modus aktiviert'
en: 'Developer mode is activated'
de: 'Entwickler Modus aktivieren'
en: 'Activate developer mode'

pypi_timeout:
type: int
Expand Down
3 changes: 3 additions & 0 deletions backend/user_doc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ hilfreich sind. Inzwischen kann man damit auch eine Reihe von Administrationsauf
.. image:: assets/backend_systeminfo.jpg

Genauer ist das unter :doc:`/backend/backend` beschrieben.

Die Konfiguration de Plugins ist unter :doc:`/plugins_doc/config/backend` ausführlich beschrieben.

1 change: 1 addition & 0 deletions backend/webif/templates/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
temp = temp + '<tr><th>{{ _('Letzte Änderung') }}</th><td>'+element.last_change+'</td></tr>';
temp = temp + '<tr><th>{{ _('update_age') }}</th><td>'+element.update_age+'</td></tr>';
temp = temp + '<tr><th>{{ _('age') }}</th><td>'+element.age+'</td></tr>';
temp = temp + '<tr><th>{{ _('Update durch') }}</th><td>'+element.updated_by+'</td></tr>';
temp = temp + '<tr><th>{{ _('Geändert durch') }}</th><td>'+element.changed_by+'</td></tr>';
temp = temp + '<tr><th>{{ _('vorheriger Wert') }}</th><td>'+element.previous_value+'</td></tr>';
temp = temp + '<tr><th>{{ _('previous update') }}</th><td>'+element.previous_update+'</td></tr>';
Expand Down
2 changes: 1 addition & 1 deletion backend/webif/templates/log_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3>SmarthomeNG {{ _('Logfile') }}: {{ logfile }}</h3><br/>
</select>
</div>
<button type="button" class="btn btn-default" style="float:left; margin-left: 10px;" onclick="location.href='log_view.html?logfile={{ logfile }}&text_filter='+$('#text_filter').val()+'&log_level_filter='+$('#log_level_filter').val()">{{ _('Filter anwenden','button') }}</button>
<button type="button" title="{{ _('Neu Laden', 'button') }}" class="btn btn-default" style="float:left; margin-left: 10px;" onclick="location.href='log_view.html?logfile={{ logfile }}&text_filter='+$('#text_filter').val()+'&log_level_filter='+$('#log_level_filter').val()+'&page={{ current_page }}'"><i class="fa fa-refresh" aria-hidden="true"></i></button>
<button type="button" title="{{ _('Neu Laden', 'button') }}" class="btn btn-default" style="float:left; margin-left: 10px;" onclick="location.href='log_view.html?logfile={{ logfile }}&text_filter='+$('#text_filter').val()+'&log_level_filter='+$('#log_level_filter').val()+'&page={{ current_page }}'"><i class="fas fa-sync" aria-hidden="true"></i></button>
<button type="button" title="{{ _('Nach unten scrollen', 'button') }}" class="btn btn-default" style="float:left; margin-left: 10px;" onclick="document.getElementById('log_print').scrollTop = 9999999;"><i class="fa fa-arrow-circle-down" aria-hidden="true"></i></button>
</div>
<br style="clear:both;"/>
Expand Down
8 changes: 4 additions & 4 deletions cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,11 @@ def _cli_ll(self, handler, parameter, source):
handler.push("Logics:\n")
for logic in sorted(self.logics.return_loaded_logics()):
data = []
nt = self.sh.scheduler.return_next(logic)
if self.logics.is_logic_enabled(logic) == False:
info = self.logics.get_logic_info(logic)
if not info['enabled']:
data.append("disabled")
if nt is not None:
data.append("scheduled for {0}".format(nt.strftime('%Y-%m-%d %H:%M:%S%z')))
if 'next_exec' in info:
data.append("scheduled for {0}".format(info['next_exec']))
handler.push("{0}".format(logic))
if len(data):
handler.push(" ({0})".format(", ".join(data)))
Expand Down
27 changes: 27 additions & 0 deletions cli/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ plugin:

parameters:
# Definition of parameters to be configured in etc/plugin.yaml
update:
type: bool
default: False
description:
de: 'Wenn dieser Parameter False ist, ist der CLI Zugriff rein lesend. Um Updates duchführen zu können, muss dieser Parameter auf True gesetzt werden.'
en: 'Restrict the access of the items to read only (false) or allows read/write access (true).'

ip:
type: ip
default: 127.0.0.1
description:
de: 'Legt festm auf welchen Netzwerk Interfaces CLI nach Verbindungen lauscht (127.0.0.1 für localhost, 0.0.0.0 für alle Netzwerk Interfaces)'
en: 'used network interface, e.g. 127.0.0.1 (localhost) or listen on all network interfaces: 0.0.0.0'

port:
type: num
default: 2323
description:
de: 'Netzwerk Port der für die Verbindung genutzt wird'
en: 'used network port'

hashed_password:
type: str
description:
de: "Hash (SHA-512) des Passwortes zum Login. Hashes können durch das backend Plugin erzeugt werden. Wenn kein Passwort verwendet werden soll wird eine Warnung geloggt. Soll dieses Log unterbleiben, muss für diesen Parameter 'none' eingegeben werden."
en: "password that needs to be entered on login. SHA-512 hashed. Hashes can be created via the backend plugin. If you don't use a password, a warning will be logged. If you don't want that log entry, this parameter must be set to 'none'."


item_attributes:
# Definition of item attributes defined by this plugin
Expand Down
2 changes: 1 addition & 1 deletion comfoair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def update_item(self, item, caller=None, source=None, dest=None):
self.send_command(readcommandname)

# If commands should be triggered after this write
if self.has_iattr_value(item.conf, 'comfoair_trigger'):
if self.has_iattr(item.conf, 'comfoair_trigger'):
trigger = self.get_iattr_value(item.conf, 'comfoair_trigger')
if trigger == None:
self.log_err('Item {} contains invalid trigger command list \'{}\'!'.format(item, trigger))
Expand Down
74 changes: 66 additions & 8 deletions comfoair/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,81 @@ plugin:
type: interface # plugin type (gateway, interface, protocol, system, web)
description:
de: 'Unterstützung für Zehnder ComfoAir 350 & 500 KWL'
en: ''
en: 'Suppprt for Zehnder ComfoAir 350 & 500 KWL'
maintainer: '? (SvStefan)'
tester: ohinckel
# keywords: kwd1 kwd2 # keywords, where applicable
documentation: https://github.com/smarthomeNG/smarthome/wiki/Comfoair-Plugin # url of documentation (wiki) page
support: https://knx-user-forum.de/forum/supportforen/smarthome-py/31291-neues-plugin-comfoair-kwl-wohnraumlüftung-zehnder-paul-wernig

# Following entries are for Smart-Plugins:
# version: 1.3.3 # Plugin version
# sh_minversion: 1.3 # minimum shNG version to use this plugin
version: 1.3.0 # Plugin version
sh_minversion: 1.3 # minimum shNG version to use this plugin
# sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest)
# multi_instance: False
multi_instance: False
classname: ComfoAir # class containing the plugin

#parameters:
parameters:
# Definition of parameters to be configured in etc/plugin.yaml
kwltype:
type: str
default: comfoair350
description:
de: 'Legt den Typ des KWL Systems fest'
en: 'The type of the KWL system'
valid_list:
- comfoair350
- comfoair500
host:
type: ip
description:
de: 'Netzwerverbindung: Hostname/IP des KWL Systems'
en: 'Network connection: Hostname/IP of KWL system'
port:
type: num
description:
de: 'Netzwerkverbindung: Port des KWL Systems'
en: 'Network connection: Port of KWL system'
serialport:
type: str
description:
de: 'Serielle Verbindung: Device/Port der serielle Schnittstelle zum KWL Systems'
en: 'Serial connection: Device/port of serial interface to KWL system'

#item_attributes:
item_attributes:
# Definition of item attributes defined by this plugin

comfoair_send:
type: str
description:
de: 'Änderung des Items wird mit konfiguriertem Kommando an das KWL System geschickt.'
en: 'Changes to this item result in sending the configured command to the KWL system.'
comfoair_read:
type: str
description:
de: 'Liest Wert mit konfiguriertem Kommand aus dem KWL System aus.'
en: 'The item value should be read by using the configured command.'
comfoair_read_afterwrite:
type: num
description:
de: 'Konfiguriert eine Verzögerung in Sekunden nachdem ein Lesekommando nach einem Schreibkommando an das KWL System geschickt wird.'
en: 'Configures delay in seconds to issue a read command after write command.'
comfoair_read_cycle:
type: num
description:
de: 'Konfiguriert ein Interval in Sekunden für das Lesekommando.'
en: 'Configures a interval in seconds for the read command.'
comfoair_init:
type: bool
description:
de: 'Konfiguriert ob der Wert aus dem KWL System initialisiert werden soll.'
en: 'Configures to initialize the item value with the value from the KWL system.'
comfoair_trigger:
type: list(string)
description:
de: 'Konfiguriert Lesekommandos die nach einem Schreibvorgang auf das Item aufgerufen werden.'
en: 'Configures read commands after an update to the item.'
comfoair_trigger_afterwrite:
type: num
description:
de: 'Konfiguriert eine Verzögerung in Sekunden bis ein Trigger ausgeführt werden soll nachdem ein Wert gesetzt wurde.'
en: 'Configures delay in seconds to run trigger commands after item update.'

15 changes: 15 additions & 0 deletions enigma2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,23 @@ timeout: Number of seconds the message should stay on the device, default: 10
sh.vusolo2.send_message("Testnachricht",1,10)
</pre>
### set_power_state(value)
Sets the power state to a specific value:
0 = Toggle Standby
1 = Deepstandby
2 = Reboot
3 = Restart Enigma2
4 = Wakeup from Standby
5 = Standby
E.g. toggle standby:
<pre>
sh.vusolo2.set_power_state(0)
</pre>
### get_answer()
This function checks for an answer to a sent message. If you call this method, take into account the timeout until the message can be answered and e.g. set a "while (count < 0)"
<pre>
sh.vusolo2.get_answer()
</pre>
23 changes: 22 additions & 1 deletion enigma2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,28 @@ def set_volume(self, value):
:param value: value of the volume (int from 0 to 100)
"""
xml = self.box_request(self._url_suffix_map['vol'], 'set=set%s' % (value))
xml = self.box_request(self._url_suffix_map['vol'], 'set=set%s' % value)

e2result_xml = xml.getElementsByTagName('e2result')
e2resulttext_xml = xml.getElementsByTagName('e2resulttext')
if len(e2resulttext_xml) > 0 and len(e2result_xml) > 0:
if not e2resulttext_xml[0].firstChild is None and not e2result_xml[0].firstChild is None:
if e2result_xml[0].firstChild.data == 'True':
self.logger.debug(e2resulttext_xml[0].firstChild.data)

def set_power_state(self, value):
"""
Sets the power state to a specific value
0 = Toggle Standby
1 = Deepstandby
2 = Reboot
3 = Restart Enigma2
4 = Wakeup from Standby
5 = Standby
:param value: value of the power state (int from 0 to 5)
"""
xml = self.box_request(self._url_suffix_map['powerstate'], 'newstate=%s' % value)

e2result_xml = xml.getElementsByTagName('e2result')
e2resulttext_xml = xml.getElementsByTagName('e2resulttext')
Expand Down
4 changes: 2 additions & 2 deletions lirc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ lirc1:
class_name: LIRC
class_path: plugins.lirc
instance: "livingroom"
lirc_Host: "127.0.0.1"
# lirc_Port: 6610
lirc_host: "127.0.0.1"
# lirc_port: 6610
lirc2:
class_name: LIRC
Expand Down
8 changes: 4 additions & 4 deletions lirc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
class LIRC(lib.connection.Client,SmartPlugin):

ALLOW_MULTIINSTANCE = True
PLUGIN_VERSION = "1.3.1"
PLUGIN_VERSION = "1.4.1"

def __init__(self, sh, lirc_Host, lirc_Port=8765):
def __init__(self, sh, lirc_host, lirc_port=8765):
self.instance = self.get_instance_name()
self.logger = logging.getLogger(__name__)
self.lircHost = lirc_Host
self.lircPort = lirc_Port
self.lircHost = lirc_host
self.lircPort = lirc_port
lib.connection.Client.__init__(self, self.lircHost, self.lircPort, monitor=True)
self._sh = sh
self._cmd_lock = threading.Lock()
Expand Down
9 changes: 1 addition & 8 deletions lirc/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugin:
# documentation: https://github.com/smarthomeNG/plugins/blob/develop/lirc/....md
# support:

version: 1.3.1 # Plugin version
version: 1.4.1 # Plugin version
sh_minversion: 1.3 # minimum shNG version to use this plugin
# sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest)
multi_instance: True # plugin supports multi instance
Expand All @@ -21,13 +21,6 @@ plugin:
parameters:
# Definition of parameters to be configured in etc/plugin.yaml

instance:
type: str
mandatory: True
description:
de: 'Name der Plugin Instanz (SmartHomeNG Standard-Parameter). Die Angabe ist notwendig um den passenden lircd zu ermitteln wenn ein Befehl versendet werden soll.'
en: 'Name of the plugin instance (SmartHomeNG standard parameter). This is mandatory to identify the matching lircd for a pending command.'

lirc_host:
type: str
mandatory: True
Expand Down
Loading

0 comments on commit 0b2fa6a

Please sign in to comment.