<li><p><ahref="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>)<br>This program is written in <ahref="https://en.wikipedia.org/wiki/Python_(programming_language">Python</a>) so you need to install a python environment (for details see <ahref="https://docs.python.org/2.7/using/index.html">Python Setup and Usage</a>)</p>
</li>
<li><p><ahref="https://github.com/arendst/Sonoff-Tasmota">Sonoff-Tasmota</a><ahref="https://github.com/arendst/Sonoff-Tasmota/releases">Firmware</a> with Web-Server enabled:</p>
<ul>
<li>To backup or restore configurations from/to a Sonoff-Tasmota device you need a firmare with enabled web-server in admin mode (command <ahref="https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#wifi">WebServer 2</a>).</li>
<li>If using your own compiled firmware be aware to enable the web-server (<code>#define USE_WEBSERVER</code> and <code>#define WEB_SERVER 2</code>).</li>
<p><em>decode-config.py</em> can handle the following backup file types: </p>
<h3id="-dmp-format">.dmp Format</h3>
<p>Configuration data as used by Tasmota "Backup/Restore Configuration" web interface.<br>This format is binary and encrypted.</p>
<h3id="-json-format">.json Format</h3>
<p>Configuration data in <ahref="http://www.json.org/">JSON</a>-format.<br>This format is decrypted, human readable and editable and can also be used for the <code>--restore-file</code> command.<br>This file will becreated by <em>decode-config.py</em> using <code>--backup-file</code> with <code>--backup-type json</code> parameter (default).</p>
<h3id="-bin-format">.bin Format</h3>
<p>Configuration data in binary format.<br>This format is binary decryptet, editable (e.g. using a hex editor) and can also be used for <code>--restore-file</code> command.<br>It will be created by <em>decode-config.py</em> using <code>--backup-file</code> with <code>--backup-type bin</code>.<br>Note:<br>This file is 4 byte longer than an original .dmp file due to an prefix header at the beginning. The file data starting at address position 4 are containing the same as the <strong>struct SYSCFG</strong> from Tasmota <ahref="https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/settings.h">settings.h</a> in decrypted format.</p>
<h4id="file-extensions">File extensions</h4>
<p><em>decode-config.py</em> uses auto extension as default for backup filenames; you don't need to append extensions to your backup file, it will be selected based on <code>--backup-type</code> argument.<br>If you want using your own extension use the <code>--no-extension</code> argument.</p>
<h2id="usage">Usage</h2>
<p>After download don't forget to set exec flag under linux with <code>chmod +x decode-config.py</code> or call the program using <code>python decode-config.py...</code>.</p>
<h3id="basics">Basics</h3>
<p>At least pass a source where you want to read the configuration data from using <code>-f <filename></code> or <code>-d <host></code>:</p>
<p>The source can be either </p>
<ul>
<li>a Tasmota device hostname or IP by passing it using the <code>-d <host></code> arg</li>
</code></pre><p>will create a file like <code>Config_Sonoff_x.x.x.json</code>. Because it is in JSON format, you can read and edit the file with any raw text editor.</p>
<p>Reading back a saved (and possible changed) backup file use the <code>--restore-file <filename></code> arg. This will read the (changed) configuration data from this file and send it back to the source device or filename.</p>
<p>To restore the previously save backup file <code>Config_Sonoff_6.2.1.json</code> to device <code>sonoff-4281</code> use: </p>
<p><em>decode-config.py</em> is able to translate the configuration data to (most all) Tasmota commands. To output your configuration as Tasmota commands use <code>--output-format cmnd</code> or <code>--output-format command</code>.</p>
</code></pre><p>Note: A few very specific module commands like MPC230xx, KNX and some Display commands are not supported. These are still available by JSON output.</p>
<h3id="filter-data">Filter data</h3>
<p>The huge number of Tasmota configuration data can be overstrained and confusing, so the most of the configuration data are grouped into categories. </p>
<p>With <em>decode-config.py</em> the following categories are available: <code>Display</code>, <code>Domoticz</code>, <code>Internal</code>, <code>KNX</code>, <code>Led</code>, <code>Logging</code>, <code>MCP230xx</code>, <code>MQTT</code>, <code>Main</code>, <code>Management</code>, <code>Pow</code>, <code>Sensor</code>, <code>Serial</code>, <code>SetOption</code>, <code>SonoffRF</code>, <code>System</code>, <code>Timers</code>, <code>Wifi</code></p>
<p>These are similary to the categories on <ahref="Tasmota Command Wiki">https://github.com/arendst/Sonoff-Tasmota/wiki/Commands</a>.</p>
<p>To filter outputs to a subset of groups use the <code>-g</code> or <code>--group</code> arg concatenating the grooup you want, e. g.</p>
<p>Each argument that start with <code>--</code> (eg. <code>--file</code>) can also be set in a config file (specified via -c). Config file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at <ahref="https://pypi.org/project/ConfigArgParse/">https://pypi.org/project/ConfigArgParse</a>).</p>
<p>If an argument is specified in more than one place, then commandline values override config file values which override defaults. This is usefull if you always use the same argument or a basic set of arguments.</p>
<p>The http authentication credentials <code>--username</code> and <code>--password</code> is predestinated to store it in a file instead using it on your command line as argument:</p>
<p>For better reading each short written arg (minus sign <code>-</code>) has a corresponding long version (two minus signs <code>--</code>), eg. <code>--device</code> for <code>-d</code> or <code>--file</code> for <code>-f</code> (note: not even all <code>--</code> arg has a corresponding <code>-</code> one).</p>
<spanclass="hljs-type">Backup</span>/<spanclass="hljs-type">Restore</span><spanclass="hljs-type">Sonoff</span>-<spanclass="hljs-type">Tasmota</span> configuration <spanclass="hljs-class"><spanclass="hljs-keyword">data</span>. <spanclass="hljs-type">Args</span> that start with '<spanclass="hljs-comment">--'</span></span>
(eg. -f) can also be set <spanclass="hljs-keyword">in</span> a config file (specified via -c). <spanclass="hljs-type">Config</span> file
<spanclass="hljs-title">syntax</span> allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at
<spanclass="hljs-title">https</span>://goo.gl/<spanclass="hljs-type">R74nmi</span>). <spanclass="hljs-type">If</span> an arg is specified <spanclass="hljs-keyword">in</span> more than one place, <spanclass="hljs-keyword">then</span>
<spanclass="hljs-title">commandline</span> values override config file values which override defaults.
limit <spanclass="hljs-class"><spanclass="hljs-keyword">data</span> processing to command groups (<spanclass="hljs-title">default</span><spanclass="hljs-title">no</span>
<spanclass="hljs-title">filter</span>)</span>
<spanclass="hljs-comment">--ignore-warnings do not exit on warnings. Not recommended, used by your</span>
</code></pre><p>will produce JSON configuration files for host sonoff1, sonoff2 and sonoff3 using friendly name and Tasmota firmware version for backup filenames.</p>
<li>Filename replacement macros <strong>@h</strong> and <strong>@H</strong>:<ul>
<li><strong>@h</strong><br>The <strong>@h</strong> replacement macro uses the hostname configured with the Tasomta Wifi <code>Hostname <host></code> command (defaults to <code>%s-%04d</code>). It will not use the network hostname of your device because this is not available when working with files only (e.g. <code>--file <filename></code> as source).<br>To prevent having a useless % in your filename, <strong>@h</strong> will not replaced by configuration data hostname if this contains '%' characters.</li>
<li><strong>@H</strong><br>If you want to use the network hostname within your filename, use the <strong>@H</strong> replacement macro instead - but be aware this will only replaced if you are using a network device as source (<code>-d</code>, <code>--device</code>, <code>--host</code>); it will not work when using a file as source (<code>-f</code>, <code>--file</code>)</li>