Site updated at 2017-10-21 23:33:52 UTC
This commit is contained in:
parent
b95006b9eb
commit
a6fbc15960
1416 changed files with 21669 additions and 4045 deletions
|
@ -23,7 +23,7 @@
|
|||
<meta name="twitter:title" content="Database">
|
||||
<meta name="twitter:description" content="Details about the database which Home Assistant is using.">
|
||||
<meta name="twitter:image" content="https://home-assistant.io/images/default-social.png">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection, print" rel="stylesheet">
|
||||
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
|
||||
<link rel='shortcut icon' href='/images/favicon.ico' />
|
||||
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
|
||||
|
@ -75,15 +75,15 @@
|
|||
</h1>
|
||||
</header>
|
||||
<hr class="divider">
|
||||
<p>The default database that is used for Home Assistant is <a href="https://www.sqlite.org/">SQLite</a> and is stored in your <a href="/getting-started/configuration/">configuration directory</a>, eg. <code class="highlighter-rouge"><path to config dir>/.homeassistant/home-assistant_v2.db</code>. You will need an installation of <code class="highlighter-rouge">sqlite3</code>, the command-line for SQLite database, or <a href="http://sqlitebrowser.org/">DB Browser for SQLite</a> which provide an editor for executing SQL commands.
|
||||
First load your database with <code class="highlighter-rouge">sqlite3</code>.</p>
|
||||
<p>The default database that is used for Home Assistant is <a href="https://www.sqlite.org/">SQLite</a> and is stored in your <a href="/getting-started/configuration/">configuration directory</a> (e.g., <code class="highlighter-rouge"><path to config dir>/.homeassistant/home-assistant_v2.db</code>). You will need an installation of <code class="highlighter-rouge">sqlite3</code>, the command-line for SQLite database, or <a href="http://sqlitebrowser.org/">DB Browser for SQLite</a>, which provides an editor for executing SQL commands.
|
||||
First load your database with <code class="highlighter-rouge">sqlite3</code>:</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>sqlite3 home-assistant_v2.db
|
||||
SQLite version 3.13.0 2016-05-18 10:57:30
|
||||
Enter <span class="s2">".help"</span> <span class="k">for </span>usage hints.
|
||||
<span class="gp">sqlite> </span>
|
||||
</code></pre>
|
||||
</div>
|
||||
<p>It helps to set some options to make the output better readable.</p>
|
||||
<p>It helps to set some options to make the output more readable:</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">sqlite> </span>.header on
|
||||
<span class="gp">sqlite> </span>.mode column
|
||||
</code></pre>
|
||||
|
@ -96,7 +96,7 @@ seq name file
|
|||
</code></pre>
|
||||
</div>
|
||||
<h3><a class="title-link" name="schema" href="#schema"></a> Schema</h3>
|
||||
<p>Get all available tables from your current Home Assistant database.</p>
|
||||
<p>Get all available tables from your current Home Assistant database:</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">sqlite> </span>SELECT sql FROM sqlite_master;
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
|
@ -137,12 +137,12 @@ CREATE INDEX states__state_changes ON states <span class="o">(</span>last_change
|
|||
CREATE TABLE sqlite_stat1<span class="o">(</span>tbl,idx,stat<span class="o">)</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
<p>To only show the details about the <code class="highlighter-rouge">states</code> table as we are using that one in the next examples.</p>
|
||||
<p>To only show the details about the <code class="highlighter-rouge">states</code> table (since we are using that one in the next examples):</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">sqlite> </span>SELECT sql FROM sqlite_master WHERE <span class="nb">type</span> <span class="o">=</span> <span class="s1">'table'</span> AND tbl_name <span class="o">=</span> <span class="s1">'states'</span>;
|
||||
</code></pre>
|
||||
</div>
|
||||
<h3><a class="title-link" name="query" href="#query"></a> Query</h3>
|
||||
<p>The identification of the available columns in the table is done and we are now able to create a query. Let’s list of your Top 10 entities.</p>
|
||||
<p>The identification of the available columns in the table is done and we are now able to create a query. Let’s list your Top 10 entities:</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">sqlite> </span>.width 30, 10,
|
||||
<span class="gp">sqlite> </span>SELECT entity_id, COUNT<span class="o">(</span><span class="k">*</span><span class="o">)</span> as count FROM states GROUP BY entity_id ORDER BY count DESC LIMIT 10;
|
||||
entity_id count
|
||||
|
@ -160,7 +160,7 @@ group.all_switches 8018
|
|||
</code></pre>
|
||||
</div>
|
||||
<h3><a class="title-link" name="delete" href="#delete"></a> Delete</h3>
|
||||
<p>If you don’t want to keep certain entities, you can delete them permanently.</p>
|
||||
<p>If you don’t want to keep certain entities, you can delete them permanently:</p>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">sqlite> </span>DELETE FROM states WHERE <span class="nv">entity_id</span><span class="o">=</span><span class="s2">"sensor.cpu"</span>;
|
||||
</code></pre>
|
||||
</div>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<meta name="twitter:title" content="Backend of Home Assistant">
|
||||
<meta name="twitter:description" content="Backend of Home Assistant.">
|
||||
<meta name="twitter:image" content="https://home-assistant.io/images/default-social.png">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection, print" rel="stylesheet">
|
||||
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
|
||||
<link rel='shortcut icon' href='/images/favicon.ico' />
|
||||
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<meta name="twitter:title" content="Updater">
|
||||
<meta name="twitter:description" content="Details what the updater component is reporting about your Home Assistant instance.">
|
||||
<meta name="twitter:image" content="https://home-assistant.io/images/default-social.png">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet">
|
||||
<link href="/stylesheets/screen.css" media="screen, projection, print" rel="stylesheet">
|
||||
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
|
||||
<link rel='shortcut icon' href='/images/favicon.ico' />
|
||||
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue