Configuration: Unterschied zwischen den Versionen

Aus FHEMWiki
K (internen Link funktionsfähig gemacht)
K (Haupt-Kategorie FHEM entfernt; ist bereits über Kategoriebaum abgedeckt.)
 
(4 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
{{Baustelle}}{{Todo|Auf englisch übersetzen}}
The '''configuration''' of a [[Systemübersicht|FHEM-system (de)]] is usually saved in a configuration-file, called <code>fhem.cfg</code><ref>The term ''fhem.cfg'' is also used, if the configuration is split into multiple files or saved in a database</ref>.
The '''configuration''' of a [[Systemübersicht|FHEM-system (de)]] is usually saved in a configuration-file (''fhem.cfg'') which can be found in the installation directory of FHEM.


== Basics ==
== Basics ==
Using a default-installation of FHEM, all configuration is stored in the file ''fhem.cfg''. This file can be found in the installation directory (e.g. ''/opt/fhem'').
When starting FHEM, the last saved configuration is loaded. By default this configuration is stored in a file called ''fhem.cfg''. Alternatively it can be stored in a [[#Configuration in a SQL Database|database]]. Also a different file can be used. This has to be specified when starting FHEM.
 
If desired, a different file can be used. This has to be specified when starting FHEM.


== Autocreate ==
== Autocreate ==
In case the '''autocreate'''-function is enabled (<code>define autocreate autocreate</code>), particular objects are created automatically (further details: [[Quick-Start/en#autocreate|Quick Start]]).
In case the [[Quick-Start/en#autocreate|autocreate]]-function is enabled (<code>define autocreate autocreate</code>), particular objects are created automatically. These definitions get stored in the configuration file used at startup.


"autocreate" is enabled after a default-installation of FHEM.
''autocreate'' is enabled after a default-installation of FHEM.


== Editing the Configuration ==
== Editing the Configuration ==
[[Bild:saveConfig.png|mini|120px|links|"Button" to save configuration changes]]
[[Bild:saveConfig.png|mini|120px|links|"Button" to save configuration changes]]
[[Bild:saveConfigChangeList.png|mini|220px|rechts|Example of a list of unsaved configuration changes]]
[[Bild:saveConfigChangeList.png|mini|220px|rechts|Example of a list of unsaved configuration changes]]
FHEMs configuration can be edited in several ways. The recommended way is using the [[#Command-Field|command-field]] and the [[#Detailed View of an Object|object-details]]. Or use the options of [[Import von Code Snippets|Raw definition]]. All of the three offer syntax-highlighting and syntax check (to some extend).
FHEMs configuration can be edited in several ways. The recommended way is using the [[#Command-Field|command-field]] and the [[#Detailed View of an Object|object-details]]. Or use the options of [[Import von Code Snippets|Raw definition]], that can be accessed direcly by clicking the "+" left of the command field. All of the three offer syntax-highlighting and syntax check (to some extend).


Using the methods [[#Internal Editor|internal editor]] and particulary [[Configuration#External Editor|external editor]] should be seen as expert-mode and only used in special cases. Many of the (error checking-) automatics can't be used in this two modes.
Using the methods [[#Internal Editor|internal editor]] and particulary [[Configuration#External Editor|external editor]] should be seen as expert-mode and only used in special cases. Many of the (error checking-) automatics can't be used in this two modes.
Zeile 47: Zeile 44:


=== Syntaxhighlighting ===
=== Syntaxhighlighting ===
[[Bild:ConfEditDEFAutocomplete.png|mini|300px|rechts|Automatische Vervollständigung / Befehlsauswahlfenster ("se" getippt, dann Strg+Leertaste gedrückt)]]
[[Bild:ConfEditDEFAutocomplete.png|mini|300px|rechts|Autocomplete in command selection window ("se" has been typed, followed by Ctrl+Space)]]
FHEM besitzt Syntaxhervorhebungs-, Befehlsauswahl- und Befehlsvervollständigungsfunktionen.
FHEM offers syntax highlighting, command selection and command auocompletion features.


Um die Funktionalität zu aktivieren, muss folgendes Attribut auf die entsprechende FHEMWEB-Instanz gesetzt werden:
To activate this functionality, set
:<code>attr TYPE=FHEMWEB JavaScripts codemirror/fhem_codemirror.js</code>
:<code>attr TYPE=FHEMWEB JavaScripts codemirror/fhem_codemirror.js</code>


Im erweiterten Editor ist Suchen und Ersetzen mit folgenden Tastenkombinationen möglich:
Shortcuts for search and replace:
* 'STRG + F' => Suche starten
* 'STRG + F' => start search
* 'STRG + G' => Zum nächsten Treffer
* 'STRG + G' => next hit
* 'SHIFT + Ctrl + G' => Zum vorherigen Treffer
* 'SHIFT + Ctrl + G' => previous hit
* 'SHIFT + Ctrl + F' => Einzeln Ersetzen
* 'SHIFT + Ctrl + F' => replace single hit
* 'SHIFT + Ctrl + R' => Im gesamten Dokument Ersetzen
* 'SHIFT + Ctrl + R' => replace all hits in document


Folgende hilfreiche Tastenkombinationen werden desweiteren automatisch erstellt:
Additional shortcuts you might find helpful:
* 'TAB' => Einrücken von Text, auch mehrerer markierter Zeilen auf einmal, oder mindestens einer komplett markierten Zeile.
* 'TAB' => Indent text, also for multiple marked lines; al least one complete line
* 'SHIFT + TAB' => Verringern der Einrückung der aktuellen Zeile, oder auch mehrerer markierter Zeilen auf einmal.
* 'SHIFT + TAB' => do the opposite, also possible for multiple marked lines
* 'STRG + Q' => Auskommentieren oder Kommentar der Zeile entfernen in welcher sich der Cursor gerade befindet, oder mehrerer markierter Zeilen auf einmal.
* 'Ctrl + Q' => Comment respective uncomment current line or all marked lines
* 'STRG + UP' oder 'STRG + DOWN' => Hoch-/Runterscrollen des Textes ohne den Cursor umzusetzen.
* 'Ctrl + UP' oder 'Ctrl + DOWN' => Scroll up or down, do not move cursor
* 'ALT + G' => Jump-To-Line, falls das Modul jump-to-line.js über den entsprechenden codemirrorParam geladen wurde.
* 'ALT + G' => Jump-To-Line (extension jump-to-line.js has to be added as codemirrorParam first)




Der Editor kann mit dem FHEMWEB-Attribut ''codemirrorParam'' und den Parametern, welche auf der [https://codemirror.net/doc/manual.html#config codemirror Seite] zu finden sind, noch weiter angepasst werden, z.B.:   
Have a look at the FHEMWEB attribut ''codemirrorParam'' also as well as additional parameters documented on the [https://codemirror.net/doc/manual.html#config codemirror website]. Examples:   
:<code>attr TYPE=FHEMWEB codemirrorParam { "indentWithTabs":false, "indentUnit":2, "autocomplete":false, "height":"auto" }</code>
:<code>attr TYPE=FHEMWEB codemirrorParam { "indentWithTabs":false, "indentUnit":2, "autocomplete":false, "height":"auto" }</code>
In diesem Beispiel würde der Text statt mit Tabulatoren mit Leerzeichen und statt der standardmäßigen vier Leerzeichen, nur noch mit zwei Leerzeichen bei Verwenden von 'TAB' oder 'SHIFT+TAB' eingerückt werden, und Autovervollständigung mit STRG+SPACE wird deaktiviert (die Dateien show-hint.js und show-hint.css werden nicht mehr geladen); darüber hinaus wird die Höhe des Editors automatisch dem Inhalt angepasst.
This would change behaviour of ''TAB'' key to set 2 space characters (default: 4); also 'SHIFT+TAB' will only go back 2 space characters and auto completion (Ctrl+SPACE) will be deactivated (to be exact: show-hint.js and show-hint.css will not be loaded any longer); additionally, the highth of the editor field will be extended automatically to keep the entire content.


Folgende codemirror-Parameter werden standardmäßig gesetzt und können unter anderen mit dem Attribut ''codemirrorParam'' überschrieben werden:
Defaults used by FHEMWEB (can be changed by setting the corresponding parameters in ''codemirrorParam'' attribute):
{| class="wikitable"
{| class="wikitable"
|-
|-
! Parameter !! Standardwert !! Wert !! Bemerkungen
! Parameter !! Default !! Wert !! Remarks
|-
|-
| "matchBrackets"
| "matchBrackets"
| true
| true
| boolean
| boolean
| Lädt das Modul ''matchbrackets.js'' und aktiviert die Markierung zusammengehörender Klammern.
| Load module ''matchbrackets.js'' and activates bracket highlighting.
|-
|-
| "autoRefresh"
| "autoRefresh"
| true
| true
| boolean
| boolean
| Lädt das Modul ''autorefresh.js'', durch welches unter anderem verhindert wird, dass beim zweiten Aufruf von Codemirror ein schwarzer Editor ohne Inhalt angezeigt wird.
| Loads module ''autorefresh.js''; this will especially prevent a "just black" editor field will be shown when the editor is opened a second time.
|-
|-
| "search"
| "search"
| true
| true
| boolean
| boolean
| Lädt die Module ''search.js, searchcursor.js, dialog.js'', sowie den stylesheet ''dialog.css'' und aktiviert die Suchen & Ersetzen Funktionalität.
| Loads modules  ''search.js, searchcursor.js, dialog.js'', and stylesheet ''dialog.css'' to activate search and replace functionality.
|-
|-
| "comment"
| "comment"
| true
| true
| boolean
| boolean
| Lädt das Modul ''comment.js'' und aktiviert die Funktionalität mit STRG+Q Zeilen auszukommentieren / Kommentare zu entfernen.
| Loads module ''comment.js'' offering commenting/uncommenting by shortkey Ctrl+Q.
|-
|-
| "autocomplete"
| "autocomplete"
| true
| true
| boolean
| boolean
| Lädt das Modul ''show-hint.js'' sowie den stylesheet ''show-hint.css'' und aktiviert die Funktionalität, mit STRG+SPACE die Autovervollständigung zu verwenden.
| Loads module ''show-hint.js'' and stylesheet ''show-hint.css'' for autocomletion witz Ctrl+SPACE.
|-
|-
| "autocompleteAlways"
| "autocompleteAlways"
| false
| false
| boolean
| boolean
| Wenn zusätzlich zu "autocomplete" aktiviert, wird die Befehlsvervollständigung bei jedem Tastendruck durchgeführt (nicht nur durch STRG+SPACE).
| Extends "autocomplete" for autocompletion without need for additional Ctrl+SPACE.
|-
|-
| "autoCloseBrackets"
| "autoCloseBrackets"
| true
| true
| boolean
| boolean
| Lädt das Modul ''closebrackets.js'' und aktiviert die Funktionalität, dass ()[]{}''"" automatisch geschlossen werden.
| Loads module ''closebrackets.js'' - ()[]{}''"" will be added automatically pairwise .
|-
|-
| "jumpToLine"
| "jumpToLine"
| false
| false
| boolean
| boolean
| Lädt das Modul ''jump-to-line.js'' und aktiviert die Funktionalität, dass mit ALT+G zu bestimmten Zeilen gesprungen werden kann.
| Loads module ''jump-to-line.js'' - allowes shortcut ALT+G to jump to a specified line.
|-
|-
| "jumpToLine_extraKey"
| "jumpToLine_extraKey"
| false
| false
| z.B. "ALT-H"
| z.B. "ALT-H"
| Hierdurch lässt sich die Standardtastenbelegung ALT+G für jumpToLine anpassen.
| Change default shortcut ALT+G for jumpToLine.  
|-
|-
| "keyMap"
| "keyMap"
| false
| false
| "vim"
| "vim"
| Hierdurch wird wie in dem Beispiel die Datei fhem/www/codemirror/vim.js oder eine andere in diesem Ordner befindliche *.js Datei geladen.
| Load fhem/www/codemirror/vim.js or a other *.js file in this folder.
|-
|-
| "indentUnit"
| "indentUnit"
| 4
| 4
| integer
| integer
| Gibt an, wieviele Leerzeichen ein TAB-Block umfasst.
| How many space characters a TAB will include.
|-
|-
| "type"
| "type"
| "fhem"
| "fhem"
| string
| string
| Der Standard codemirror-mode, default wird hier die ''fhem.js'' geladen.  
| Standard codemirror-mode, defaults to ''fhem.js''.  
|-
|-
| "theme"
| "theme"
| "blackboard"
| "blackboard"
| string
| string
| Das Standard codemirrer-theme, default wird hier die ''blackboard.css'' geladen.
| Standard codemirrer-theme, defaults to ''blackboard.css''.
|-
|-
| "indentWithTabs"
| "indentWithTabs"
| true
| true
| boolean
| boolean
| Wenn aktiviert, wird mit Tabulator statt Leerzeichen eingerückt.
| When activated, tabs will be used instead of space characters.
|-
|-
| "autofocus"
| "autofocus"
| true
| true
| boolean
| boolean
| Wenn aktiviert, wird der Fokus beim laden von codemirror automatisch in das Editor-Fenster gesetzt.
| When activated, focus will be set inside the editor area when codemirror is loaded.
|-
|-
| "lineNumbers"
| "lineNumbers"
| true
| true
| boolean
| boolean
| Wenn aktiviert, werden die Zeilennummern im Editor angezeigt.
| When activated, line numbers will be shown inside the editor.
|-
|-
| "smartIndent"
| "smartIndent"
| false
| false
| boolean
| boolean
| Kontext-sensitive Einrückung (''true'') oder "gleiche Einrückung wie vorherige Zeile" (''false'').
| Context sensitive indent (''true'') or "same indent als previous line" (''false'').
|-
|-
| "height"
| "height"
| false
| false
| integer / "auto"
| integer / "auto"
| Entweder die standard, automatische, oder benutzerdefinierte Höhe des Editorfensters verwenden. (Im DEF sowie bei Attributen)
| Use automatic (default) or user definded highth of for the editor window. (In DEF and also in attribute editing)
|}
|}


Die Syntaxhervorhebung / Befehlsvervollständigung, sofern aktiviert, ist wirksam für
If syntax highlighting / autocompletion is activated, this affects
* Bearbeitung der [[Konfiguration#Objektdetails|Objektdetails]]
* editing the [[Configuration#Detailed View of an Object|object details]]
* [[Konfiguration#Integrierter Editor|Integrierter Editor]]
* [[Configuration#Internal Editor|Internal editor]]


Darüber hinaus wird (wie im Bildauschnitt dargestellt) über Strg+Leertaste eine Befehlsauswahl bzw. automatische Befehlsvervollständigung angeboten.
Additionally, Ctrl+Space offers command selection and auto completion as already mentionned.


Der Forums-Thread unter der Überschrift {{Link2Forum|Topic=20444|LinkText=Javascript Editor einbinden}} enthält die Diskussion zum Entwicklungsprozess.
Discussion on codemirror in {{Link2Forum|Topic=20444|LinkText=the forum}}.


=== External Editor ===
=== External Editor ===
Zeile 192: Zeile 189:


== Configuration in a SQL Database ==
== Configuration in a SQL Database ==
Since FHEM version 5079 it's possible to store the configuration in a database instead of a text-file. This is done by using [[configDB (Modul)]] and [[configdb|configDB (Befehl)]].
Since FHEM version 5079 it's possible to store the configuration in a database instead of a text-file. This is done by using {{Link2CmdRef|Anker=configDB|Lang=en|Label=configDB (module)}} and {{Link2CmdRef|Anker=configdb|Lang=en|Label=configdb (command)}}


More information can be found in the {{Link2CmdRef|Anker=configDB|Lang=en|Label=CommandReference}}.
== References ==
<references/>


[[Kategorie:FHEM]]
[[Kategorie:FHEM-Verwendung]]
[[Kategorie:FHEM-Verwendung]]

Aktuelle Version vom 4. Dezember 2019, 12:28 Uhr

The configuration of a FHEM-system (de) is usually saved in a configuration-file, called fhem.cfg[1].

Basics

When starting FHEM, the last saved configuration is loaded. By default this configuration is stored in a file called fhem.cfg. Alternatively it can be stored in a database. Also a different file can be used. This has to be specified when starting FHEM.

Autocreate

In case the autocreate-function is enabled (define autocreate autocreate), particular objects are created automatically. These definitions get stored in the configuration file used at startup.

autocreate is enabled after a default-installation of FHEM.

Editing the Configuration

"Button" to save configuration changes
Example of a list of unsaved configuration changes

FHEMs configuration can be edited in several ways. The recommended way is using the command-field and the object-details. Or use the options of Raw definition, that can be accessed direcly by clicking the "+" left of the command field. All of the three offer syntax-highlighting and syntax check (to some extend).

Using the methods internal editor and particulary external editor should be seen as expert-mode and only used in special cases. Many of the (error checking-) automatics can't be used in this two modes. Especially mixing the editing-methods can result in unexpected or unwanted effects. E.g. no save config before rereading the configuration or restarting FHEM.


Info blue.png
To see a list of unsaved changes, click on the red question mark next to the save config-link.


Command-Field

Command-Input-Field

Using the command-input-field, which can be found on top of the page, is a quick and simple way to edit the configuration (e.g. define new or edit existing devices (de), create or edit attributes (de), etc.). The changes take effect right after pushing the Enter-key.


Info blue.png
To save your changes, type save into the command-field or use the Save config-link on the left side of the page. Else all changes are lost after a restart of FHEM.


Detailed View of an Object

When clicking on the name of an object, it's details are shown on a new page. Depending on the type of the object, there are serveral ways to manipulate it's properties:

  • DEF-Editor
    DEF-Editor to edit it's definition
  • List of Attributes
    attributes / attribut-values from select lists
  • some more or other actions depending on the type

Changes to definitions take effect right after pushing the modify-button. When altering attributes or their values don't forget to use the attr-button.


Info blue.png
To save your changes, type save into the command-field or use the Save config-link on the left side of the page. Else all changes are lost after a restart of FHEM.


Internal Editor

Calling the internal editor
Editor-window (extract) with syntax-highlighting

If it's deemed necessary to edit the config-file manually, it's possible to use the internal editor. Sticking to the exact syntax of commands and definitions is inevitable, partially there are some special actions needed (escaping special characters, doubling semicolons, ...). After saving the changes, they get active immediately.

Using the internal editor to edit the configuration is locked by default. If you think it's absolutely neccesary to unlock this feature, have a look at the options of FHEMWEB in the command reference.

Syntaxhighlighting

Autocomplete in command selection window ("se" has been typed, followed by Ctrl+Space)

FHEM offers syntax highlighting, command selection and command auocompletion features.

To activate this functionality, set

attr TYPE=FHEMWEB JavaScripts codemirror/fhem_codemirror.js

Shortcuts for search and replace:

  • 'STRG + F' => start search
  • 'STRG + G' => next hit
  • 'SHIFT + Ctrl + G' => previous hit
  • 'SHIFT + Ctrl + F' => replace single hit
  • 'SHIFT + Ctrl + R' => replace all hits in document

Additional shortcuts you might find helpful:

  • 'TAB' => Indent text, also for multiple marked lines; al least one complete line
  • 'SHIFT + TAB' => do the opposite, also possible for multiple marked lines
  • 'Ctrl + Q' => Comment respective uncomment current line or all marked lines
  • 'Ctrl + UP' oder 'Ctrl + DOWN' => Scroll up or down, do not move cursor
  • 'ALT + G' => Jump-To-Line (extension jump-to-line.js has to be added as codemirrorParam first)


Have a look at the FHEMWEB attribut codemirrorParam also as well as additional parameters documented on the codemirror website. Examples:

attr TYPE=FHEMWEB codemirrorParam { "indentWithTabs":false, "indentUnit":2, "autocomplete":false, "height":"auto" }

This would change behaviour of TAB key to set 2 space characters (default: 4); also 'SHIFT+TAB' will only go back 2 space characters and auto completion (Ctrl+SPACE) will be deactivated (to be exact: show-hint.js and show-hint.css will not be loaded any longer); additionally, the highth of the editor field will be extended automatically to keep the entire content.

Defaults used by FHEMWEB (can be changed by setting the corresponding parameters in codemirrorParam attribute):

Parameter Default Wert Remarks
"matchBrackets" true boolean Load module matchbrackets.js and activates bracket highlighting.
"autoRefresh" true boolean Loads module autorefresh.js; this will especially prevent a "just black" editor field will be shown when the editor is opened a second time.
"search" true boolean Loads modules search.js, searchcursor.js, dialog.js, and stylesheet dialog.css to activate search and replace functionality.
"comment" true boolean Loads module comment.js offering commenting/uncommenting by shortkey Ctrl+Q.
"autocomplete" true boolean Loads module show-hint.js and stylesheet show-hint.css for autocomletion witz Ctrl+SPACE.
"autocompleteAlways" false boolean Extends "autocomplete" for autocompletion without need for additional Ctrl+SPACE.
"autoCloseBrackets" true boolean Loads module closebrackets.js - ()[]{}"" will be added automatically pairwise .
"jumpToLine" false boolean Loads module jump-to-line.js - allowes shortcut ALT+G to jump to a specified line.
"jumpToLine_extraKey" false z.B. "ALT-H" Change default shortcut ALT+G for jumpToLine.
"keyMap" false "vim" Load fhem/www/codemirror/vim.js or a other *.js file in this folder.
"indentUnit" 4 integer How many space characters a TAB will include.
"type" "fhem" string Standard codemirror-mode, defaults to fhem.js.
"theme" "blackboard" string Standard codemirrer-theme, defaults to blackboard.css.
"indentWithTabs" true boolean When activated, tabs will be used instead of space characters.
"autofocus" true boolean When activated, focus will be set inside the editor area when codemirror is loaded.
"lineNumbers" true boolean When activated, line numbers will be shown inside the editor.
"smartIndent" false boolean Context sensitive indent (true) or "same indent als previous line" (false).
"height" false integer / "auto" Use automatic (default) or user definded highth of for the editor window. (In DEF and also in attribute editing)

If syntax highlighting / autocompletion is activated, this affects

Additionally, Ctrl+Space offers command selection and auto completion as already mentionned.

Discussion on codemirror in the forum.

External Editor

It's also possible - though not recommended - to edit the configuration with an external editor. E.g.

  • Notepad++ (with the nppFTP-Plugin)
  • nano in a Telnet session
  • editor integrated in wsftp

Sticking to the exact syntax of commands and definitions is inevitable, partically there are some special actions need (escaping special characters, doubling semicolons, ...).

Syntax-Highlighting can be used with different editors. More about this under Syntax Highlighting with external editors (de).

Changes to the file will only take effect after rereading the configuration (rereadcfg) or restarting FHEM.

Splitting fhem.cfg into Multiple Files

If needed, fhem.cfg can be splitted into multiple files. All files then have to be included in fhem.cfg with the command include (de). This is considered as "expert mode" and should (if at all) only be used by advanced users.

Configuration in a SQL Database

Since FHEM version 5079 it's possible to store the configuration in a database instead of a text-file. This is done by using configDB (module) and configdb (command)

References

  1. The term fhem.cfg is also used, if the configuration is split into multiple files or saved in a database