diff --git a/atom.xml b/atom.xml index 8e2d065c0f..991d59ead8 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/community/atom.xml b/blog/categories/community/atom.xml index cc4051e84c..1a342477df 100644 --- a/blog/categories/community/atom.xml +++ b/blog/categories/community/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Community | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/device-tracking/atom.xml b/blog/categories/device-tracking/atom.xml index beac600ad3..28093720c4 100644 --- a/blog/categories/device-tracking/atom.xml +++ b/blog/categories/device-tracking/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Device-Tracking | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/esp8266/atom.xml b/blog/categories/esp8266/atom.xml index f445f4a3e8..f3c7a893ef 100644 --- a/blog/categories/esp8266/atom.xml +++ b/blog/categories/esp8266/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: ESP8266 | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/how-to/atom.xml b/blog/categories/how-to/atom.xml index 4b7a065131..f0b5d81da5 100644 --- a/blog/categories/how-to/atom.xml +++ b/blog/categories/how-to/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: How-To | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/ibeacons/atom.xml b/blog/categories/ibeacons/atom.xml index 48fb8c8cc0..f92bc172ae 100644 --- a/blog/categories/ibeacons/atom.xml +++ b/blog/categories/ibeacons/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: iBeacons | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/internet-of-things/atom.xml b/blog/categories/internet-of-things/atom.xml index d8a85de14d..a8e7d8c480 100644 --- a/blog/categories/internet-of-things/atom.xml +++ b/blog/categories/internet-of-things/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Internet-of-Things | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/iot-data/atom.xml b/blog/categories/iot-data/atom.xml index f88b13b9b9..7d62193d5d 100644 --- a/blog/categories/iot-data/atom.xml +++ b/blog/categories/iot-data/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: IoT-Data | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/micropython/atom.xml b/blog/categories/micropython/atom.xml index 718e8a9b3e..f4831473ae 100644 --- a/blog/categories/micropython/atom.xml +++ b/blog/categories/micropython/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Micropython | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/mqtt/atom.xml b/blog/categories/mqtt/atom.xml index d570880dc0..2f4ccacf2b 100644 --- a/blog/categories/mqtt/atom.xml +++ b/blog/categories/mqtt/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: MQTT | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/organisation/atom.xml b/blog/categories/organisation/atom.xml index f3235e8111..5f3042d8aa 100644 --- a/blog/categories/organisation/atom.xml +++ b/blog/categories/organisation/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Organisation | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/owntracks/atom.xml b/blog/categories/owntracks/atom.xml index 5084c2f0e5..0e21941604 100644 --- a/blog/categories/owntracks/atom.xml +++ b/blog/categories/owntracks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: OwnTracks | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/presence-detection/atom.xml b/blog/categories/presence-detection/atom.xml index 00c62bbc80..49830c0c76 100644 --- a/blog/categories/presence-detection/atom.xml +++ b/blog/categories/presence-detection/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Presence-Detection | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/public-service-announcement/atom.xml b/blog/categories/public-service-announcement/atom.xml index 3570c6046c..552e1515cf 100644 --- a/blog/categories/public-service-announcement/atom.xml +++ b/blog/categories/public-service-announcement/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Public-Service-Announcement | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/release-notes/atom.xml b/blog/categories/release-notes/atom.xml index 437862ea47..c5169587a6 100644 --- a/blog/categories/release-notes/atom.xml +++ b/blog/categories/release-notes/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Release-Notes | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/survey/atom.xml b/blog/categories/survey/atom.xml index 1cc003707a..1ff485e096 100644 --- a/blog/categories/survey/atom.xml +++ b/blog/categories/survey/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Survey | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/talks/atom.xml b/blog/categories/talks/atom.xml index 0073da4bad..ca8cb862b6 100644 --- a/blog/categories/talks/atom.xml +++ b/blog/categories/talks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Talks | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/technology/atom.xml b/blog/categories/technology/atom.xml index b03830b7ef..6a54638a5e 100644 --- a/blog/categories/technology/atom.xml +++ b/blog/categories/technology/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Technology | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/user-stories/atom.xml b/blog/categories/user-stories/atom.xml index afb2e47368..a0634eab12 100644 --- a/blog/categories/user-stories/atom.xml +++ b/blog/categories/user-stories/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: User-Stories | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/video/atom.xml b/blog/categories/video/atom.xml index 7fe6521d5b..57e51e5bc0 100644 --- a/blog/categories/video/atom.xml +++ b/blog/categories/video/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Video | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/blog/categories/website/atom.xml b/blog/categories/website/atom.xml index 7631dc3eaa..cd61d4fddb 100644 --- a/blog/categories/website/atom.xml +++ b/blog/categories/website/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Website | Home Assistant]]> - 2016-10-11T12:25:29+00:00 + 2016-10-11T13:50:30+00:00 https://home-assistant.io/ diff --git a/getting-started/automation-create-first/index.html b/getting-started/automation-create-first/index.html index 95eadfd114..d24624eb28 100644 --- a/getting-started/automation-create-first/index.html +++ b/getting-started/automation-create-first/index.html @@ -96,6 +96,7 @@
# Example configuration.yaml entry
 automation:
   alias: Turn on light when sun sets
+  initial_state: True
   hide_entity: False
   trigger:
     platform: sun
@@ -105,7 +106,7 @@
 
-

Starting with 0.28 automation rules can be reloaded from the frontend and are shown by default. With hide_entity: you can control this behaviour. It’s is very handy if you are working on your rules but when a rule is finished and you don’t want to see that rule in your frontend, you can set hide_entity: to True.

+

Starting with 0.28 automation rules can be reloaded from the frontend and are shown by default. With hide_entity: you can control this behaviour. It’s is very handy if you are working on your rules but when a rule is finished and you don’t want to see that rule in your frontend, you can set hide_entity: to True. To set an automation to be disabled when HASS starts set initial_state: to False.

After a few days of running this automation rule you come to realize that this automation rule is not good enough. It was already dark when the lights went on and the one day you weren’t home, the lights turned on anyway. Time for some tweaking. Let’s add an offset to the sunset trigger and a condition to only turn on the lights if anyone is home.

diff --git a/sitemap.xml b/sitemap.xml index 9bae2ae07c..d4c084d567 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2164,63 +2164,66 @@ https://home-assistant.io/topics/webserver_details/ +https://home-assistant.io/topics/database/ + + https://home-assistant.io/demo/frontend.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/index.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-event.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-info.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-service.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-state.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-template.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-history.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-iframe.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-logbook.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/demo/panels/ha-panel-map.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/googlef4f3693c209fe788.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/static/fonts/roboto/DESCRIPTION.en_us.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/static/fonts/robotomono/DESCRIPTION.en_us.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 https://home-assistant.io/static/mdi-demo.html -2016-10-11T12:24:48+00:00 +2016-10-11T13:49:47+00:00 diff --git a/topics/database/index.html b/topics/database/index.html new file mode 100644 index 0000000000..228ca5f158 --- /dev/null +++ b/topics/database/index.html @@ -0,0 +1,331 @@ + + + + + + + + + + Home Assistant Database - Home Assistant + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+ + + +
+
+ +
+ + +
+ + + + + + +
+

+ Home Assistant Database +

+
+
+ + +

The default database that is used for Home Assistant is SQLite and is stored in your configuration directory, eg. <path to config dir>/.homeassistant/home-assistant_v2.db. You will need an installation of sqlite3, the command-line for SQLite database, or DB Browser for SQLite which provide an editor for executing SQL commands. +First load your database with sqlite3.

+ +
$ sqlite3 home-assistant_v2.db 
+SQLite version 3.13.0 2016-05-18 10:57:30
+Enter ".help" for usage hints.
+sqlite> 
+
+
+ +

It helps to set some options to make the output better readable.

+ +
sqlite> .header on
+sqlite> .mode column
+
+
+ +

You could also start sqlite3 and attach the database later. Not sure what database you are working with? Check it, especially if you are going to delete data.

+ +
sqlite> .databases
+seq  name             file
+---  ---------------  ----------------------------------------------------------
+0    main             /home/fab/.homeassistant/home-assistant_v2.db 
+
+
+ +

Schema

+ +

Get all available tables from your current Home Assistant database.

+ +
sqlite> SELECT sql FROM sqlite_master;
+
+-------------------------------------------------------------------------------------
+CREATE TABLE events (
+	event_id INTEGER NOT NULL, 
+	event_type VARCHAR(32), 
+	event_data TEXT, 
+	origin VARCHAR(32), 
+	time_fired DATETIME, 
+	created DATETIME, 
+	PRIMARY KEY (event_id)
+)
+CREATE INDEX ix_events_event_type ON events (event_type)
+CREATE TABLE recorder_runs (
+	run_id INTEGER NOT NULL, 
+	start DATETIME, 
+	"end" DATETIME, 
+	closed_incorrect BOOLEAN, 
+	created DATETIME, 
+	PRIMARY KEY (run_id), 
+	CHECK (closed_incorrect IN (0, 1))
+)
+CREATE TABLE states (
+	state_id INTEGER NOT NULL, 
+	domain VARCHAR(64), 
+	entity_id VARCHAR(64), 
+	state VARCHAR(255), 
+	attributes TEXT, 
+	event_id INTEGER, 
+	last_changed DATETIME, 
+	last_updated DATETIME, 
+	created DATETIME, 
+	PRIMARY KEY (state_id), 
+	FOREIGN KEY(event_id) REFERENCES events (event_id)
+)
+CREATE INDEX states__significant_changes ON states (domain, last_updated, entity_id)
+CREATE INDEX states__state_changes ON states (last_changed, last_updated, entity_id)
+CREATE TABLE sqlite_stat1(tbl,idx,stat) 
+
+
+ +

To only show the details about the states table as we are using that one in the next examples.

+ +
sqlite> SELECT sql FROM sqlite_master WHERE type = 'table' AND tbl_name = 'states';
+
+
+ +

Query

+ +

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.

+ +
sqlite> .width 30, 10,
+sqlite> SELECT entity_id, COUNT(*) as count FROM states GROUP BY entity_id ORDER BY count DESC LIMIT 10;
+entity_id                       count
+------------------------------  ----------
+sensor.cpu                      28874
+sun.sun                         21238
+sensor.time                     18415
+sensor.new_york                 18393
+cover.kitchen_cover             17811
+switch.mystrom_switch           14101
+sensor.internet_time            12963
+sensor.solar_angle1             11397
+sensor.solar_angle              10440
+group.all_switches              8018 
+
+
+ +

Delete

+ +

If you don’t want to keep certain entities, you can delete them permanently.

+ +
sqlite> DELETE FROM states WHERE entity_id="sensor.cpu";
+
+
+ +

The VACUUM command cleans the your database.

+ +
sqlite> VACUUM;
+
+
+ +

For a more interactive way to work with the database or the create statistics, checkout our Jupyther notebooks.

+ + + +
+ + +
+ + + + +
+
+ + + + + + \ No newline at end of file diff --git a/topics/index.html b/topics/index.html index fafe907d06..352063270e 100644 --- a/topics/index.html +++ b/topics/index.html @@ -103,6 +103,9 @@
  • Events

  • +
  • +

    Home Assistant Database

    +
  • Splitting up the configuration