<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 working python environment (for details see <ahref="https://docs.python.org/2.7/using/index.html">Python Setup and Usage</a>)</p>
<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>
<li>To backup or restore configurations from or 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>). This is the Tasmota default.</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>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> parameter.<br>This file will be created by <em>decode-config.py</em> using the <code>--backup-file</code> with <code>--backup-type json</code> parameter, this is the default.</p>
<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>The .bin file contains the same information as the original .dmp file from Tasmota "Backup/Restore Configuration" but it is decrpted and 4 byte longer than an original (it is a prefix header at the beginning). .bin file data starting at address 4 contains 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>
<p>You don't need to append exensions for your file name as <em>decode-config.py</em> uses auto extension as default. The extension will be choose based on file contents and <code>--backup-type</code> parameter.
If you do not want using auto extensions use the <code>--no-extension</code> parameter.</p>
<p>After download don't forget to set the executable flag under linux with <code>chmod +x decode-config.py</code> or call the program using <code>python decode-config.py...</code>.</p>
<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>To save the output as backup file use <code>--backup-file <filename></code>, you can use placeholder for Version, Friendlyname and Hostname: </p>
</code></pre><p>will create a file like <code>Config_Sonoff_6.4.0.json</code> (the part <code>Sonoff</code> and <code>6.4.0</code> will choosen related to your device configuration). Because the default backup file format is JSON, you can read and change it with any raw text editor.</p>
<p>Reading back a saved (and possible changed) backup file use the <code>--restore-file <filename></code> parameter. This will read the (changed) configuration data from this file and send it back to the source device or filename.</p>
<p>The default output format is <ahref="decode-config.md#-json-format">JSON</a>. You can force JSON output using the <code>--output-format json</code> parameter.</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>
<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>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>
Backup/<spanclass="hljs-keyword">Restore</span> Sonoff-Tasmota configuration data. <spanclass="hljs-keyword">Args</span> that start with '--'
(eg. -f) can also be <spanclass="hljs-keyword">set</span><spanclass="hljs-keyword">in</span> a config <spanclass="hljs-keyword">file</span> (specified via -c). Config <spanclass="hljs-keyword">file</span>
<spanclass="hljs-keyword">syntax</span> allows: key=value, flag=true, stuff=[a,b,c] (<spanclass="hljs-keyword">for</span> details, see <spanclass="hljs-keyword">syntax</span> at
https:<spanclass="hljs-comment">//goo.gl/R74nmi). If an arg is specified in more than one place, then</span>
limit data processing to command groups (default <spanclass="hljs-keyword">no</span>
filter)
--ignore-warnings <spanclass="hljs-keyword">do</span> not <spanclass="hljs-keyword">exit</span><spanclass="hljs-keyword">on</span> warnings. Not recommended, used <spanclass="hljs-keyword">by</span> your
-<spanclass="hljs-keyword">h</span>, --<spanclass="hljs-keyword">help</span> show usage <spanclass="hljs-keyword">help</span> message and <spanclass="hljs-keyword">exit</span>
-<spanclass="hljs-keyword">H</span>, --full-<spanclass="hljs-keyword">help</span> show full <spanclass="hljs-keyword">help</span> message and <spanclass="hljs-keyword">exit</span>
-v, --verbose produce <spanclass="hljs-keyword">more</span> output <spanclass="hljs-keyword">about</span> what the <spanclass="hljs-keyword">program</span> does
-V, --<spanclass="hljs-keyword">version</span> show <spanclass="hljs-keyword">program</span>'s <spanclass="hljs-keyword">version</span> number and <spanclass="hljs-keyword">exit</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>